Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ WHITELIST = *
SERVER_NAME = CodeX REMS Administrator Prototype
FULL_RESOURCE_IN_APP_CONTEXT = false
DOCKERED_EHR_CONTAINER_NAME = false
DOCKERED_INTERMEDIARY_CONTAINER_NAME = false
INTERMEDIARY_PORT=3003
EHR_PORT=8080

#Frontend Vars
FRONTEND_PORT=9090
Expand Down
5 changes: 4 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
auth: {
// This server's URI
resourceServer: env.get('RESOURCE_SERVER').required().asUrlString(),
dockered_ehr_container_name: env.get('DOCKERED_EHR_CONTAINER_NAME').asString()
dockered_ehr_container_name: env.get('DOCKERED_EHR_CONTAINER_NAME').asString(),
dockered_interemediary_container_name: env.get('DOCKERED_INTERMEDIARY_CONTAINER_NAME').asString(),

Check failure on line 46 in src/config.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `.get('DOCKERED_INTERMEDIARY_CONTAINER_NAME')` with `⏎········.get('DOCKERED_INTERMEDIARY_CONTAINER_NAME')⏎········`

Check failure on line 46 in src/config.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `.get('DOCKERED_INTERMEDIARY_CONTAINER_NAME')` with `⏎········.get('DOCKERED_INTERMEDIARY_CONTAINER_NAME')⏎········`
dockered_ehr_port: env.get('EHR_PORT').asInt(),
dockered_intermediary_port: env.get('INTERMEDIARY_PORT').asInt()
//
// if you use this strategy, you need to add the corresponding env vars to docker-compose
//
Expand Down
2 changes: 1 addition & 1 deletion src/fhir/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,4 @@
drugCode: 1
});

export const remsCaseCollection = model<RemsCase>('RemsCaseCollection', remsCaseCollectionSchema);
export const remsCaseCollection = model<RemsCase>('RemsCaseCollection', remsCaseCollectionSchema);

Check failure on line 164 in src/fhir/models.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`

Check failure on line 164 in src/fhir/models.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`
20 changes: 14 additions & 6 deletions src/lib/communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// Create patient object from REMS case
const patient: Patient = {
resourceType: 'Patient',
id: `${remsCase.patientFirstName}-${remsCase.patientLastName}`.replace(/\s+/g, '-'),
id: remsCase.remsPatientId,
name: [
{
given: [remsCase.patientFirstName],
Expand Down Expand Up @@ -151,18 +151,26 @@
return;
}

if (config.fhirServerConfig.auth.dockered_ehr_container_name) {
const originalEhrEndpoint = ehrEndpoint;
const originalEhrEndpoint = ehrEndpoint.toString().replace(/\/$/, '') ;

Check failure on line 154 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `·`

Check failure on line 154 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `·`
logger.info(config.fhirServerConfig.auth);
if (config.fhirServerConfig.auth.dockered_ehr_container_name && originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_ehr_port)) {

Check failure on line 156 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `config.fhirServerConfig.auth.dockered_ehr_container_name·&&·originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_ehr_port)` with `⏎······config.fhirServerConfig.auth.dockered_ehr_container_name·&&⏎······originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_ehr_port)⏎····`

Check failure on line 156 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `config.fhirServerConfig.auth.dockered_ehr_container_name·&&·originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_ehr_port)` with `⏎······config.fhirServerConfig.auth.dockered_ehr_container_name·&&⏎······originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_ehr_port)⏎····`
ehrEndpoint = originalEhrEndpoint
.replace(/localhost/g, config.fhirServerConfig.auth.dockered_ehr_container_name)
.replace(/127\.0\.0\.1/g, config.fhirServerConfig.auth.dockered_ehr_container_name);
logger.info(
`Running locally in Docker, converting EHR url from ${originalEhrEndpoint} to ${ehrEndpoint}`
`Running locally in Docker to ehr, converting EHR url from ${originalEhrEndpoint} to ${ehrEndpoint}`
);
} else if (config.fhirServerConfig.auth.dockered_interemediary_container_name && originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_intermediary_port)) {

Check failure on line 163 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `config.fhirServerConfig.auth.dockered_interemediary_container_name·&&·originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_intermediary_port)` with `⏎······config.fhirServerConfig.auth.dockered_interemediary_container_name·&&⏎······originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_intermediary_port)⏎····`

Check failure on line 163 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `config.fhirServerConfig.auth.dockered_interemediary_container_name·&&·originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_intermediary_port)` with `⏎······config.fhirServerConfig.auth.dockered_interemediary_container_name·&&⏎······originalEhrEndpoint.includes(config.fhirServerConfig.auth.dockered_intermediary_port)⏎····`
ehrEndpoint = originalEhrEndpoint
.replace(/localhost/g, config.fhirServerConfig.auth.dockered_interemediary_container_name)
.replace(/127\.0\.0\.1/g, config.fhirServerConfig.auth.dockered_interemediary_container_name);

Check failure on line 166 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `/127\.0\.0\.1/g,·config.fhirServerConfig.auth.dockered_interemediary_container_name` with `⏎··········/127\.0\.0\.1/g,⏎··········config.fhirServerConfig.auth.dockered_interemediary_container_name⏎········`

Check failure on line 166 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Replace `/127\.0\.0\.1/g,·config.fhirServerConfig.auth.dockered_interemediary_container_name` with `⏎··········/127\.0\.0\.1/g,⏎··········config.fhirServerConfig.auth.dockered_interemediary_container_name⏎········`
logger.info(
`Running locally in Docker to intermediary, converting EHR url from ${originalEhrEndpoint} to ${ehrEndpoint}`
);
}

// Send Communication to EHR
logger.info(`Sending Communication to EHR: ${ehrEndpoint}`);
logger.info(`Sending Communication to EHR: ${ehrEndpoint}/Communication`);

const response = await axios.post(`${ehrEndpoint}/Communication`, communication, {
headers: {
Expand All @@ -179,4 +187,4 @@
logger.error(`Failed to send Communication to EHR: ${error.message}`);
throw error;
}
}
}

Check failure on line 190 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`

Check failure on line 190 in src/lib/communication.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`
9 changes: 8 additions & 1 deletion src/lib/etasu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@
const patientLastName = patient.name?.[0].family || '';
const patientDOB = patient.birthDate || '';
const case_number = uid();

Check failure on line 199 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `··`

Check failure on line 199 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `··`
// Extract patientId from the patientReference (e.g., "Patient/pat017" -> "pat017")
const patientId = patientReference.includes('/')

Check failure on line 201 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `·`

Check failure on line 201 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Delete `·`
? patientReference.split('/').pop() || patientReference
: patientReference;

// Fetch the full medication from database to get NDC code
const fullMedication = await medicationCollection
Expand Down Expand Up @@ -225,6 +230,7 @@
const remsRequest: Pick<
RemsCase,
| 'case_number'
| 'remsPatientId'
| 'status'
| 'dispenseStatus'
| 'drugName'
Expand All @@ -242,6 +248,7 @@
| 'metRequirements'
> & { originatingFhirServer?: string } = {
case_number: case_number,
remsPatientId: patientId,
status: 'Pending',
dispenseStatus: 'Pending',
drugName: medicationData?.name,
Expand Down Expand Up @@ -1013,4 +1020,4 @@

export { getResource, getQuestionnaireResponse };

export default router;
export default router;

Check failure on line 1023 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`

Check failure on line 1023 in src/lib/etasu.ts

View workflow job for this annotation

GitHub Actions / Check tsc, lint, and prettier

Insert `⏎`
Loading