Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pilot testing updates #110

Merged
merged 7 commits into from
Jun 12, 2024
Merged
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
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
#yarn lint-staged
3 changes: 3 additions & 0 deletions build-dev-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /usr/bin/env bash

docker-compose -f debug.docker-compose.yml build
12 changes: 11 additions & 1 deletion config/config_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@
"kafka:9092"
]
},
"retryConfig": {
"translatorMaxRetries": 5,
"translatorRetryDelay": 10000,
"hl7MaxRetries": 5,
"hl7RetryDelay": 10000,
"kafkaMaxRetries": 5,
"kafkaRetryDelay": 10000
},
"bwConfig": {
"pimsSystemUrl": "https://api.openconceptlab.org/orgs/I-TECH-UW/sources/PIMSLAB/",
"ipmsSystemUrl": "https://api.openconceptlab.org/orgs/I-TECH-UW/sources/IPMSLAB/",
"cielSystemUrl": "https://openconceptlab.org/orgs/CIEL/sources/CIEL",
"loincSystemUrl": "https://api.openconceptlab.org/orgs/Regenstrief/sources/LOINC/",
"omangSystemUrl": "http://moh.bw.org/ext/identifier/omang",
"brdsSystemUrl": "http://moh.bw.org/ext/identifier/bcn",
"bdrsSystemUrl": "http://moh.bw.org/ext/identifier/bcn",
"labOrderSystemUrl": "http://moh.bw.org/ext/identifier/lab-order-id",
"mrnSystemUrl": "http://moh.bw.org/ext/identifier/mrn",
"immigrationSystemUrl": "http://moh.bw.org/ext/identifier/ppn",
"oclUrl": "https://api.openconceptlab.org",
"facilityCodeSystemUrl": "http://moh.bw.org/ext/identifier/facility-code",
Expand Down
Binary file modified config/ipms_facility_mappings.xlsx
Binary file not shown.
Binary file added config/ipms_facility_mappings_v2.xlsx
Binary file not shown.
Binary file added config/ipms_facility_mappings_v3.xlsx
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"sprintf-js": "^1.1.2",
"urijs": "^1.19.11",
"uuid": "^3.3.3",
"uuid4": "^1.1.4",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^4.4.2"
},
Expand Down
18 changes: 18 additions & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ export async function hapiPassthrough(targetUri: any, res: Response): Promise<an
}
}

export async function hapiGet(resource: string, options: any): Promise<any> {
const targetUri = config.get('fhirServer:baseURL') + '/' + resource

logger.info(`Getting ${targetUri}`)

// Merge options
const sendOptions = {...options, username: config.get('fhirServer:username'), password: config.get('fhirServer:password')}

try {
const result = got.get(targetUri, sendOptions)

return await result.json()
} catch (error) {
logger.error(`Could not get ${targetUri}:\n${JSON.stringify(error)}`)
return null
}
}

export function getHapiPassthrough(): any {
return async (req: Request, res: Response) => {
const targetUri = config.get('fhirServer:baseURL') + req.url
Expand Down
7 changes: 4 additions & 3 deletions src/lib/hl7MllpSender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { MllpServer } from '@i-tech-uw/mllp-server'
import logger from './winston'
import { WorkflowHandler, topicList } from '../workflows/botswana/workflowHandler'
import { config } from '../lib/config'

export default class Hl7MllpSender {
targetIp: string
Expand All @@ -19,9 +20,9 @@ export default class Hl7MllpSender {
this.mllpServer = new MllpServer(targetIp, targetPort, logger)
}

public static getInstance(targetIp: string, targetPort: number): Hl7MllpSender {
public static getInstance(targetIp: string, targetPort: number, retries?: number, retryInterval?: number): Hl7MllpSender {
if (!Hl7MllpSender.instance) {
Hl7MllpSender.instance = new Hl7MllpSender(targetIp, targetPort)
Hl7MllpSender.instance = new Hl7MllpSender(targetIp, targetPort, retries, retryInterval)
}
return Hl7MllpSender.instance
}
Expand Down Expand Up @@ -81,6 +82,6 @@ export default class Hl7MllpSender {
}
}

const hl7Sender = Hl7MllpSender.getInstance('127.0.0.1', 3000)
const hl7Sender = Hl7MllpSender.getInstance('127.0.0.1', 3000, config.get("retryConfig:hl7MaxRetries"), config.get("retryConfig:hl7RetryDelay"));

export { hl7Sender }
8 changes: 4 additions & 4 deletions src/lib/kafkaConsumerUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Consumer, EachBatchPayload, Kafka, KafkaConfig, Message } from 'kafkajs'
import logger from './winston'
import { WorkflowHandler, WorkflowResult, topicList } from '../workflows/botswana/workflowHandler'

import { config } from '../lib/config'
export type EachMessageCallback = (
topic: string,
partition: number,
Expand Down Expand Up @@ -61,9 +61,9 @@ export class KafkaConsumerUtil {
`Consumer | Recieved message from topic ${topic} on partition ${partition} with offset ${message.offset}`,
)

const maxRetries = 2
const maxRetries = config.get("retryConfig:kafkaMaxRetries") || 2
let retryCount = 0
let retryDelay = 2000
let retryDelay = config.get("retryConfig:kafkaRetryDelay") || 1000
let res: WorkflowResult | null = null

while (retryCount < maxRetries) {
Expand All @@ -77,7 +77,7 @@ export class KafkaConsumerUtil {
await heartbeat()
break // Break the loop if processing succeeds }
} else {
logger.error(`Workflow result did not succeed: ${res.result}`)
logger.error(`Workflow result did not succeed: ${JSON.stringify(res.result)}`)
}
} catch (error) {
logger.error(`Error processing message ${message.offset}: ${error}`)
Expand Down
12 changes: 7 additions & 5 deletions src/lib/locationMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import * as Excel from 'exceljs'

type FacilityMapping = {
index: number
orderingFacility: string
orderingFacilityMflCode: string
orderingFacilityName: string
receivingFacility: string
provider: string
patientType: string
Expand Down Expand Up @@ -33,11 +34,12 @@ async function getFacilityMappings() {
const mappings = rows.map((row: Excel.Row): FacilityMapping => {
return {
index: parseInt(getCellValue(row, 1)),
orderingFacility: getCellValue(row, 4),
orderingFacilityMflCode: getCellValue(row, 4),
orderingFacilityName: getCellValue(row, 5),
receivingFacility: getCellValue(row, 2),
provider: getCellValue(row, 6),
patientType: getCellValue(row, 8),
patientStatus: getCellValue(row, 7),
provider: getCellValue(row, 7),
patientType: getCellValue(row, 9),
patientStatus: getCellValue(row, 8),
xLocation: getCellValue(row, 3),
}
})
Expand Down
Loading
Loading