Skip to content

Commit

Permalink
Fixing MLLP port setup and adding MLLP testing for #27 (#28)
Browse files Browse the repository at this point in the history
* Mllp work

* Updates

* Config fix

* attempted workflow fix

* Openhim config fix

* version bump and workflow fix

* Small fix
  • Loading branch information
pmanko authored Dec 10, 2021
1 parent 4f71ff0 commit 0208ca3
Show file tree
Hide file tree
Showing 16 changed files with 562 additions and 492 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ jobs:

- name: Show containers
run: docker-compose -f "ci.docker-compose.yml" ps


- name: Show OpenHIM Log
run: docker-compose -f "ci.docker-compose.yml" logs openhim-core

# Newman Container Approach
- name: Run General Tests Collection
env:
Expand All @@ -138,6 +141,9 @@ jobs:
POSTMAN_COLLECTION: https://www.getpostman.com/collections/2ee8ebff39c078bac256
run: docker-compose -f ci.docker-compose.yml up --exit-code-from newman newman

- name: Run MLLP Tests
run: docker-compose -f ci.docker-compose.yml up --exit-code-from mllp_tests mllp_tests

- name: Show SHR Log
run: docker-compose -f "ci.docker-compose.yml" logs shr

Expand All @@ -157,11 +163,13 @@ jobs:

- name: Publish Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
if: github.event_name == 'release'
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }}:${{steps.package-version.outputs.current-version}}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}
build-args: NODE_AUTH_TOKEN=${{ secrets.NPM_TOKEN }}

6 changes: 5 additions & 1 deletion .github/workflows/script/build-test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
docker build ./ -t test-image:latest --build-args NODE_AUTH_TOKEN
docker build --build-arg NODE_AUTH_TOKEN=$env:NODE_AUTH_TOKEN ./ -t test-image:latest

docker-compose -f ci.docker-compose.yml pull shr-fhir openhim-core mongo-db newman kafka zookeeper
docker-compose -f ci.docker-compose.yml up -d shr-fhir mongo-db openhim-core kafka zookeeper

Expand All @@ -14,6 +15,8 @@ docker-compose -f ci.docker-compose.yml up -d shr

docker-compose -f ci.docker-compose.yml ps

docker-compose -f ci.docker-compose.yml up mllp_tests

declare -a tests=("https://www.getpostman.com/collections/481bb6cc8e1e964fd8bd"
"https://www.getpostman.com/collections/ff5183adca5b5e720338"
"https://www.getpostman.com/collections/2ee8ebff39c078bac256"
Expand All @@ -27,4 +30,5 @@ do
docker-compose -f ci.docker-compose.yml up --exit-code-from newman newman
done


# docker-compose -f ci.docker-compose.yml down -v
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ ARG NODE_ENV=docker
ENV NODE_ENV=$NODE_ENV

EXPOSE 3000
EXPOSE 3001

CMD sh -c './wait-for shr=-fhir:8080 -- '
CMD sh -c './wait-for shr-fhir:8080 -- '
ENTRYPOINT node dist/app.js
18 changes: 13 additions & 5 deletions ci.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ services:
container_name: shr
hostname: shr
image: test-image:latest
ports:
- 3000:3000
- 3001:3001
environment:
- NODE_ENV=docker
ports:
- 3001:3001
volumes:
- ./config/config_ci.json:/app/config/config_docker.json
- ./config/mediator_ci.json:/app/config/mediator_docker.json
Expand Down Expand Up @@ -55,7 +54,7 @@ services:
# OpenHIM Config
openhim-config:
container_name: openhim-config
image: ghcr.io/i-tech-uw/openhim-config:latest
image: ghcr.io/i-tech-uw/openhim-config:v0.0.0
volumes:
- ./config/openhim/ci-openhim-config.json:/app/test-openhim-config.json

Expand All @@ -68,6 +67,13 @@ services:
- ./.postman:/.postman
entrypoint: newman run $POSTMAN_COLLECTION -e /.postman/ci.postman_environment.json --insecure --timeout-request 10000 --delay-request 10000

# MLLP Tests
mllp_tests:
container_name: mllp_tests
image: ghcr.io/b-techbw/mllp-tester:main
volumes:
- ./test/mllp:/test

# Task Runner
zookeeper:
image: 'bitnami/zookeeper:latest'
Expand All @@ -78,10 +84,12 @@ services:
image: 'bitnami/kafka:latest'
hostname: kafka
container_name: kafka
ports:
- 9092:9092
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
Expand Down
5 changes: 1 addition & 4 deletions config/config_ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
"mpiURL": "https://openhim-core:5000/CR/fhir",
"baseURL": "http://shr-fhir:8080/fhir"
},
"fhirConverterUrl": "https://openhim-core:5000/72f",
"taskRunner": {
"brokers" : ["kafka:9092"]
}
"fhirConverterUrl": "https://openhim-core:5000/72f"
}
2 changes: 1 addition & 1 deletion config/config_development.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
},
"fhirConverterUrl": "http://localhost:5001/72f",
"taskRunner": {
"workers" : ["localhost:9092"]
"brokers" : ["localhost:9092"]
}
}
14 changes: 13 additions & 1 deletion dev.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,24 @@ services:
# OpenHIM Config
openhim-config:
container_name: openhim-config
image: ghcr.io/i-tech-uw/openhim-config:latest
image: ghcr.io/i-tech-uw/openhim-config:v0.0.0
volumes:
- ./config/openhim/dev-openhim-config.json:/app/test-openhim-config.json
profiles: ["dev"]
networks:
- hie

# MLLP Testing
mllp_tests:
container_name: mllp_tests
image: ghcr.io/b-techbw/mllp-tester:main
networks:
- hie
volumes:
- ./test/mllp:/test
# tty: true
# stdin_open: true
# entrypoint: bash
volumes:
mongo-data:
hapi-data:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shared-health-registry",
"version": "0.4.0",
"version": "0.4.1",
"description": "Open Implementation of an OpenHIE Shared Health Record",
"main": "app.js",
"scripts": {
Expand All @@ -20,7 +20,7 @@
"license": "ISC",
"dependencies": {
"@ahryman40k/ts-fhir-types": "^4.0.34",
"@b-techbw/mllp": "^3.0.1",
"@b-techbw/mllp": ">=3.0.6",
"@types/got": "^9.6.12",
"acorn": ">=7.1.1",
"async": "^3.1.0",
Expand Down
4 changes: 1 addition & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ if (require.main === module) {
}

// TODO: Extract to separate project / package
if (true) { //config.get("app:taskRunner:brokers")) {

if (config.get("taskRunner:brokers")) {
run().catch(logger.error)

}
}
2 changes: 1 addition & 1 deletion src/routes/hl7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ router.post('/oru', async (req: Request, res: Response) => {
return res.status(200).json(resultBundle)

} catch (error) {
logger.error(`Could not translate and save ORU message to SHR!\n${error}`)
logger.error(`/oru: failed!\n${error}`)
return res.status(500).json(error)
}

Expand Down
3 changes: 3 additions & 0 deletions src/server/kafkaWorkers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import logger from '../lib/winston'
import { LaboratoryWorkflowsBw } from '../workflows/lab-bw';
import { IBundle } from '@ahryman40k/ts-fhir-types/lib/R4';
import { saveLabBundle } from "../hapi/lab";
import { Consumer } from "kafkajs";
const errorTypes = ['unhandledRejection', 'uncaughtException']
const signalTraps: NodeJS.Signals[] = ['SIGTERM', 'SIGINT', 'SIGUSR2']

Expand All @@ -20,6 +21,8 @@ const signalTraps: NodeJS.Signals[] = ['SIGTERM', 'SIGINT', 'SIGUSR2']
*/

export async function run() {
let k: Consumer = consumer

await consumer.connect()

await consumer.subscribe({ topic: "map-concepts", fromBeginning: true })
Expand Down
20 changes: 14 additions & 6 deletions src/workflows/hl7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@ import URI from "urijs";
import { saveLabBundle } from "../hapi/lab";
import config from "../lib/config";
import logger from "../lib/winston";
import { IBundle, BundleTypeKind } from '@ahryman40k/ts-fhir-types/lib/R4';
export default class Hl7Workflows {

private static errorBundle: IBundle = {
resourceType: "Bundle",
type: BundleTypeKind._transactionResponse,
entry: [{
response: {
status: "500 Server Error"
}
}]
}

// GET Lab Orders via HL7v2 over HTTP - ORU Message
static async saveOruMessage(hl7Msg: string): Promise<R4.IBundle> {
try {
Expand All @@ -34,8 +44,7 @@ export default class Hl7Workflows {

} catch (error: any) {
logger.error(`Could not translate and save ORU message!\n${JSON.stringify(error)}`)

throw new Error(`Could not translate ORU message!\n${JSON.stringify(error)}`)
return this.errorBundle
}
}

Expand Down Expand Up @@ -65,8 +74,7 @@ export default class Hl7Workflows {

} catch (error: any) {
logger.error(`Could not translate and save ORU message!\n${JSON.stringify(error)}`)

throw new Error(`Could not translate ORU message!\n${JSON.stringify(error)}`)
return this.errorBundle
}
}

Expand Down Expand Up @@ -101,4 +109,4 @@ export default class Hl7Workflows {
}
} while (nextExists);
}
}
}
10 changes: 10 additions & 0 deletions test/mllp/messages/example-adt.hl7
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MSH|^~\&|||||202109211304||ADT^A04|54200|D|2.4|||AL|NE|
EVN||202109211304|||MT^MEDITECH|202109211304|
PID|1||GG00001280^^^^MR^GGC~OMANG123^^^^SS^GGC~GG1403^^^^PI^GGC~MOH0004687^^^^HUB^GGC||Test^ADT^Message^^^^L||19790921|F|||PLOT 123^^Gaborone^B^0101||00267891608025|||S||XG0000002195|
NK1|1|Test^Test|BR^Brother|Plot 123^^Gaborone^B^0101|00267891608029||NOK|
PV1|1|O|HGGMMO|RF|||K^Naicker^Kalvin^^^^^^^^^^XX|||||||||||CLI||U|||||||||||||||||||GGC||REG|||202109211304|
PV2|||||||||||1||||||||||||||RF|||||||||||N|
ROL|1|AD|AT|K^Naicker^Kalvin^^^^^^^^^^XX|
ROL|2|AD|PP|GENPRI00^Doctor^Private^^^^^^^^^^XX|
GT1|1||Test^ADT^Message||PLOT 123^^Gaborone^B^0101|00267891608025|||||SF|OMANG123|
IN1|1|Citizens||Citizens|Botswana Government^Ministry of Health^Gaborone^B^0101|
9 changes: 9 additions & 0 deletions test/mllp/messages/example-oru.hl7
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MSH|^~\&|LAB|GGC|||202106101550||ORU^R01|165293.1|D|
PID|1|TEST0062404|GG00042482^^^^MR^GGC~GG5714^^^^PI^GGC~TEST0062404^^^^HUB^GGC||Murambi^Tawanda||19880616|M||CT|Plot 1011^^Gaborone^Botswana^00267|||||M|| ZG0000044218|
OBR|1|MOH001^LAB|68222^LAB|COVID^SARS-CoV-2 PCR^L|||202106031400|||||||202106101545||ZZHGGMMO^Healthpost^Mmopane||00049731||||||LAB|F||^^^^^R|
OBX|1|ST|SARS-CoV-2 PCR^SARS-CoV-2 PCR^L||INCONCLUSIVE|||N||A^S|F||||GNHL^National Health Laboratory^L|
OBX|2|ST|S-Cov-2 RVW^SARS-CoV-2 PCR REVIEW^L||.|||N||A^S|F|||202106101549|GNHL^National Health Laboratory^L|
NTE|1|
NTE|2|
NTE|3||SARS-CoV-2 PCR Tests Authorised by: MEDITECH|
NTE|4||Authorised Date: 10/06/21 1549|
23 changes: 23 additions & 0 deletions test/mllp/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

hostname="shr"
port=3001

for hl7File in messages/*
do
echo "Testing $hl7File"
lines=""

while IFS='' read -r LINE || [ -n "${LINE}" ]; do
LINE=`echo $LINE | sed -e 's/^[[:space:]]*//'`
echo "processing line: ${LINE}"
lines="${lines}${LINE}\x0d"
done < $hl7File

msg="\x0b${lines}\x1c\x0d"

echo $hostname
echo $msg

echo -ne $msg | socat - TCP:$hostname:$port
done
Loading

0 comments on commit 0208ca3

Please sign in to comment.