@@ -19,7 +19,7 @@ export async function sendCommunicationToEHR(
1919 // Create patient object from REMS case
2020 const patient : Patient = {
2121 resourceType : 'Patient' ,
22- id : ` ${ remsCase . patientFirstName } - ${ remsCase . patientLastName } ` . replace ( / \s + / g , '-' ) ,
22+ id : remsCase . remsPatientId ,
2323 name : [
2424 {
2525 given : [ remsCase . patientFirstName ] ,
@@ -151,20 +151,37 @@ export async function sendCommunicationToEHR(
151151 return ;
152152 }
153153
154- if ( config . fhirServerConfig . auth . dockered_ehr_container_name ) {
155- const originalEhrEndpoint = ehrEndpoint ;
154+ const originalEhrEndpoint = ehrEndpoint . toString ( ) . replace ( / \/ $ / , '' ) ;
155+ logger . info ( config . fhirServerConfig . auth ) ;
156+ if (
157+ config . fhirServerConfig . auth . dockered_ehr_container_name &&
158+ originalEhrEndpoint . includes ( config . fhirServerConfig . auth . dockered_ehr_port )
159+ ) {
156160 ehrEndpoint = originalEhrEndpoint
157161 . replace ( / l o c a l h o s t / g, config . fhirServerConfig . auth . dockered_ehr_container_name )
158162 . replace ( / 1 2 7 \. 0 \. 0 \. 1 / g, config . fhirServerConfig . auth . dockered_ehr_container_name ) ;
159163 logger . info (
160- `Running locally in Docker, converting EHR url from ${ originalEhrEndpoint } to ${ ehrEndpoint } `
164+ `Running locally in Docker to ehr, converting EHR url from ${ originalEhrEndpoint } to ${ ehrEndpoint } `
165+ ) ;
166+ } else if (
167+ config . fhirServerConfig . auth . dockered_interemediary_container_name &&
168+ originalEhrEndpoint . includes ( config . fhirServerConfig . auth . dockered_intermediary_port )
169+ ) {
170+ ehrEndpoint = originalEhrEndpoint
171+ . replace ( / l o c a l h o s t / g, config . fhirServerConfig . auth . dockered_interemediary_container_name )
172+ . replace (
173+ / 1 2 7 \. 0 \. 0 \. 1 / g,
174+ config . fhirServerConfig . auth . dockered_interemediary_container_name
175+ ) ;
176+ logger . info (
177+ `Running locally in Docker to intermediary, converting EHR url from ${ originalEhrEndpoint } to ${ ehrEndpoint } `
161178 ) ;
162179 }
163180
164181 // Send Communication to EHR
165- logger . info ( `Sending Communication to EHR: ${ ehrEndpoint } ` ) ;
182+ logger . info ( `Sending Communication to EHR: ${ ehrEndpoint } Communication ` ) ;
166183
167- const response = await axios . post ( `${ ehrEndpoint } / Communication` , communication , {
184+ const response = await axios . post ( `${ ehrEndpoint } Communication` , communication , {
168185 headers : {
169186 'Content-Type' : 'application/fhir+json'
170187 }
0 commit comments