Skip to content

Commit

Permalink
Fixes and updates for BW IPMS lab workflows (#53)
Browse files Browse the repository at this point in the history
* Updates

* Fix

* Small translation fix
  • Loading branch information
pmanko authored May 23, 2022
1 parent 62f8cec commit 718a489
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 56 deletions.
8 changes: 4 additions & 4 deletions config/config_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
"pimsSystemUrl": "https://api.openconceptlab.org/orgs/B-TECHBW/sources/PIMS-LAB-TEST-DICT/",
"omangSystemUrl": "http://moh.bw.org/ext/identifier/omang",
"oclUrl": "https://api.openconceptlab.org",
"requestTimeout": 5000,
"requestTimeout": 10000,
"toIpmsAdtTemplate": "ADT_A04_TO_IPMS.hbs",
"fromIpmsAdtTemplate": "ADT_A04_FROM_IPMS.hbs",
"toIpmsOrmTemplate": "ORM_O01_TO_IPMS.hbs",
"fromIpmsOruTemplate": "ORU_R01_FROM_IPMS",
"fromIpmsOruTemplate": "ORU_R01_FROM_IPMS.hbs",
"mllp": {
"targetIp": "shr",
"targetPort": 3001
"targetIp": "172.17.0.1",
"targetPort": 2100
}
}
}
2 changes: 1 addition & 1 deletion config/config_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"toIpmsAdtTemplate": "ADT_A04_TO_IPMS.hbs",
"fromIpmsAdtTemplate": "ADT_A04_FROM_IPMS.hbs",
"toIpmsOrmTemplate": "ORM_O01_TO_IPMS.hbs",
"fromIpmsOruTemplate": "ORU_R01_FROM_IPMS",
"fromIpmsOruTemplate": "ORU_R01_FROM_IPMS.hbs",
"mllp": {
"targetIp": "shr",
"targetPort": 3001
Expand Down
3 changes: 2 additions & 1 deletion debug.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ services:
- NODE_AUTH_TOKEN
ports:
- 3000:3000
- 3001:3001
- '9229:9229'
environment:
- NODE_ENV=docker
volumes:
- ./config/config_docker.json:/app/config/config_docker.json
# - ./config/mediator_ci.json:/app/config/mediator_docker.json
entrypoint: node --inspect-brk=0.0.0.0:9229 ./dist/app.js
entrypoint: node --inspect=0.0.0.0:9229 ./dist/app.js
# tty: true
# stdin_open: true
# entrypoint: bash
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@b-techbw/mllp": ">=3.1.0",
"@types/got": "^9.6.12",
"acorn": ">=7.1.1",
"async": "^3.1.0",
"async": "^3.2.1",
"axios": "^0.21.1",
"cookie-parser": "^1.4.5",
"damerau-levenshtein": "^1.0.5",
Expand Down
2 changes: 1 addition & 1 deletion src/workflows/hl7WorkflowsBw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class Hl7WorkflowsBw {
headers: {
'content-type': 'text/plain',
},
body: hl7Message,
body: hl7Message.replace(/\r/g, '\n'),
method: 'POST',
https: {
rejectUnauthorized: false,
Expand Down
103 changes: 55 additions & 48 deletions src/workflows/labWorkflowsBw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,66 +318,73 @@ export class LabWorkflowsBw extends LabWorkflows {
}

public static async handleAdtFromIpms(registrationBundle: R4.IBundle): Promise<R4.IBundle> {
let options = {
timeout: config.get('bwConfig:requestTimeout'),
searchParams: {},
}
try {
let options = {
timeout: config.get('bwConfig:requestTimeout'),
searchParams: {},
}

let patient: IPatient, omang: String
let patEntry = registrationBundle.entry!.find(entry => {
return entry.resource && entry.resource.resourceType == 'Patient'
})
let patient: IPatient, omang: String
let patEntry = registrationBundle.entry!.find(entry => {
return entry.resource && entry.resource.resourceType == 'Patient'
})

if (patEntry) {
patient = <IPatient>patEntry
if (patEntry) {
patient = <IPatient>patEntry

let omangEntry = patient.identifier?.find(
i => i.system && i.system == config.get('bwConfig:omangSystemUrl'),
)
let omangEntry = patient.identifier?.find(
i => i.system && i.system == config.get('bwConfig:omangSystemUrl'),
)

if (omangEntry) {
omang = omangEntry.value!
} else {
omang = ''
}
if (omangEntry) {
omang = omangEntry.value!
} else {
omang = ''
}

// Find all patients with this Omang.
options.searchParams = {
identifier: `${config.get('bwConfig:omangSystemUrl')}|${omang}`,
_revinclude: 'Task:patient',
}
// Find all patients with this Omang.
options.searchParams = {
identifier: `${config.get('bwConfig:omangSystemUrl')}|${omang}`,
_revinclude: 'Task:patient',
}

let patientTasks: IBundle
try {
patientTasks = await got.get(`${config.get('fhirServer:baseURL')}/Patient`, options).json()
} catch (e) {
patientTasks = { resourceType: 'Bundle' }
logger.error(e)
}
let patientTasks: IBundle
try {
patientTasks = await got
.get(`${config.get('fhirServer:baseURL')}/Patient`, options)
.json()
} catch (e) {
patientTasks = { resourceType: 'Bundle' }
logger.error(e)
}

if (patientTasks && patientTasks.entry) {
// Get all Tasks with `requested` status
for (const e of patientTasks.entry!) {
if (
e.resource &&
e.resource.resourceType == 'Task' &&
e.resource.status == TaskStatusKind._requested
) {
// Grab bundle for task:
options.searchParams = {
_include: '*',
_id: e.resource.id,
if (patientTasks && patientTasks.entry) {
// Get all Tasks with `requested` status
for (const e of patientTasks.entry!) {
if (
e.resource &&
e.resource.resourceType == 'Task' &&
e.resource.status == TaskStatusKind._requested
) {
// Grab bundle for task:
options.searchParams = {
_include: '*',
_id: e.resource.id,
}

let taskBundle: IBundle = await got
.get(`${config.get('fhirServer:baseURL')}/Task`, options)
.json()

sendPayload(taskBundle, topicList.SEND_ORM_TO_IPMS)
}

let taskBundle: IBundle = await got
.get(`${config.get('fhirServer:baseURL')}/Task`, options)
.json()

sendPayload(taskBundle, topicList.SEND_ORM_TO_IPMS)
}
}
}
} catch (e) {
logger.error(e)
}

// let obrMessage = await Hl7WorkflowsBw.getFhirTranslation(labBundle, 'OBR.hbs')

// let obrResult = await sender.send(obrMessage)
Expand Down

0 comments on commit 718a489

Please sign in to comment.