Skip to content

Commit 63307a0

Browse files
committed
ncpdp endpoint implimentation
1 parent 3293b19 commit 63307a0

6 files changed

Lines changed: 586 additions & 36 deletions

File tree

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ VSAC_API_KEY = changeMe
1212
WHITELIST = *
1313
SERVER_NAME = CodeX REMS Administrator Prototype
1414
FULL_RESOURCE_IN_APP_CONTEXT = false
15+
DOCKERED_EHR_CONTAINER_NAME = false
1516

1617
#Frontend Vars
1718
FRONTEND_PORT=9090

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ Following are a list of modifiable paths:
118118
| WHITELIST | `http://localhost, http://localhost:3005` | List of valid URLs for CORS. Should include any URLs the server accesses for resources. |
119119
| SERVER_NAME | `CodeX REMS Administrator Prototype` | Name of the server that is returned in the card source. |
120120
| FULL_RESOURCE_IN_APP_CONTEXT | 'false' | If true, the entire order resource will be included in the appContext, otherwise only a reference will be. |
121+
| DOCKERED_EHR_CONTAINER_NAME | '' | String of the EHR container name for local docker networking communication |
122+
121123
| FRONTEND_PORT | `9080` | Port that the frontend server should run on, change if there are conflicts with port usage. |
122124
| VITE_REALM | `ClientFhirServer` | Keycloak realm for frontend authentication. |
123125
| VITE_AUTH | `http://localhost:8180` | Keycloak authentication server URL for frontend. |

src/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ export default {
4141
fhirServerConfig: {
4242
auth: {
4343
// This server's URI
44-
resourceServer: env.get('RESOURCE_SERVER').required().asUrlString()
44+
resourceServer: env.get('RESOURCE_SERVER').required().asUrlString(),
45+
dockered_ehr_container_name: env.get('DOCKERED_EHR_CONTAINER_NAME').asString()
4546
//
4647
// if you use this strategy, you need to add the corresponding env vars to docker-compose
4748
//

src/lib/communication.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,21 @@ export async function sendCommunicationToEHR(
143143
};
144144

145145
// Determine EHR endpoint: use originatingFhirServer if available, otherwise default
146-
const ehrEndpoint =
146+
let ehrEndpoint =
147147
remsCase.originatingFhirServer || config.fhirServerConfig?.auth?.resourceServer;
148148

149149
if (!ehrEndpoint) {
150150
logger.warn('No EHR endpoint configured, Communication not sent');
151151
return;
152152
}
153153

154+
if (config.fhirServerConfig.auth.dockered_ehr_container_name) {
155+
const originalEhrEndpoint = ehrEndpoint;
156+
ehrEndpoint = originalEhrEndpoint.replace(/localhost/g, config.fhirServerConfig.auth.dockered_ehr_container_name)
157+
.replace(/127\.0\.0\.1/g, config.fhirServerConfig.auth.dockered_ehr_container_name);
158+
logger.info(`Running locally in Docker, converting EHR url from ${originalEhrEndpoint} to ${ehrEndpoint}`);
159+
}
160+
154161
// Send Communication to EHR
155162
logger.info(`Sending Communication to EHR: ${ehrEndpoint}`);
156163

src/lib/winston.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,30 @@ const applicationTransports = [];
1616
const transportConsole = new transports.Console({
1717
level: logConfig.level,
1818
format: winston.format.combine(
19-
winston.format.prettyPrint(),
20-
winston.format.json(),
21-
winston.format.splat()
19+
winston.format.timestamp(),
20+
winston.format.json()
2221
)
2322
});
2423

2524
applicationTransports.push(transportConsole);
25+
2626
if (logConfig.directory) {
2727
const transportDailyFile = new transports.DailyRotateFile({
2828
filename: path.join(logConfig.directory, 'application-%DATE%.log'),
2929
datePattern: 'YYYY-MM-DD-HH',
3030
level: logging.level,
3131
zippedArchive: true,
32-
maxSize: '20m'
32+
maxSize: '20m',
33+
format: winston.format.combine(
34+
winston.format.timestamp(),
35+
winston.format.json()
36+
)
3337
});
3438
applicationTransports.push(transportDailyFile);
3539
}
40+
3641
// Add a default application logger
3742
container.add('application', {
38-
format: format.combine(format.timestamp(), format.logstash()),
3943
transports: applicationTransports
4044
});
4145

@@ -44,4 +48,4 @@ container.add('application', {
4448
* @static
4549
* @summary Logging container for the application
4650
*/
47-
export default container;
51+
export default container;

0 commit comments

Comments
 (0)