Skip to content

Commit

Permalink
Updated CI
Browse files Browse the repository at this point in the history
  • Loading branch information
pmanko committed Nov 11, 2023
1 parent 4914455 commit 5d90aac
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 126 deletions.
144 changes: 29 additions & 115 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ on:
workflow_dispatch:

env:
REGISTRY: ghcr.io
REGISTRY: docker.io
IMAGE_NAME: ${{ github.repository }}
SHR_VERSION: ci
DOCKER_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}

jobs:
unit-test:
Expand Down Expand Up @@ -47,123 +48,36 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Extract metadata (tags, labels) for Docker
uses: actions/checkout@v4
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Change repo info to lowercase
id: string
uses: ASzc/change-string-case-action@v5
uses: docker/metadata-action@v5
with:
string: ${{ github.repository }}

- name: Get Package Version
id: package-version
uses: martinbeentjes/npm-get-version-action@main

- name: Check custom tag
run: echo ${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }}:${{steps.package-version.outputs.current-version}}

- name: Build SHR
uses: docker/build-push-action@v3
images: ${{ env.DOCKER_NAME }}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
tags: ghcr.io/i-tech-uw/shared-health-record:ci
push: false
load: true
context: .
cache-from: type=gha
cache-to: type=gha,mode=max

# - name: Pull containers
# run: docker-compose pull shr-fhir openhim-core mongo-db newman kafka zookeeper

# - name: Cache containers
# uses: satackey/[email protected]
# continue-on-error: true

# - name: Start containers
# run: docker-compose up -d shr-fhir mongo-db openhim-core kafka zookeeper

# - name: Load openhim config
# run: docker-compose up -d openhim-config

# - name: Sleep for 60 seconds
# run: sleep 90s
# shell: bash

# - name: Display docker logs for openhim config
# run: docker-compose logs openhim-config

# - name: Run SHR image
# run: docker-compose up -d shr

# - name: Sleep for 30 seconds
# run: sleep 30s
# shell: bash

# - name: Show SHR Log
# run: docker-compose logs shr

# - name: Show kafka Log
# run: docker-compose logs kafka

# - name: Check openhim-core
# run: curl -sSk https://localhost:8080/heartbeat

# - name: Show containers
# run: docker-compose ps

# - name: Show OpenHIM Log
# run: docker-compose logs openhim-core

# # Postman Testing - see https://www.postman.com/itechuw/workspace/shared-health-record/
# - name: Run General Tests Collection
# env:
# POSTMAN_COLLECTION: /.postman/collections/1_general_tests.json
# run: docker-compose up -d newman

# - name: Run Laboratory Workflows Collection (collection/1525496-f28b488f-a40c-4723-8a72-a2b4f64bb5da)
# env:
# POSTMAN_COLLECTION: /.postman/collections/2_laboratory_workflows.json
# run: docker-compose up --exit-code-from newman newman
# continue-on-error: true

# - name: Run MLLP Tests
# run: docker-compose up --exit-code-from mllp_tests mllp_tests

# - name: Show SHR Log
# if: always()
# run: docker-compose logs shr

# - name: Show kafka Log
# if: always()
# run: docker-compose logs kafka

# - name: Stop containers
# if: always()
# run: docker-compose down

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish Docker image
uses: docker/build-push-action@v3
if: github.event_name == 'release'
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ steps.string.outputs.lowercase }}:${{steps.package-version.outputs.current-version}}
push: ${{ github.event_name != 'pull_request' }}
load: ${{ github.event_name == 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=registry,ref=${{github.repository}}:latest
cache-to: type=inline
2 changes: 2 additions & 0 deletions config/config_docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"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",
"immigrationSystemUrl": "http://moh.bw.org/ext/identifier/passportno",
"oclUrl": "https://api.openconceptlab.org",
"facilityCodeSystemUrl": "http://moh.bw.org/ext/identifier/facility-code",
"ipmsProviderSystemUrl": "http://moh.bw.org/ext/ipms-provider",
Expand Down
27 changes: 19 additions & 8 deletions src/workflows/botswana/IpmsWorkflows.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { R4 } from "@ahryman40k/ts-fhir-types"
import config from "../../lib/config"
import logger from "../../lib/winston"
import { getTaskStatus } from "./helpers"
import { getTaskStatus, setTaskStatus } from "./helpers"
import Hl7MllpSender from "../../lib/hl7MllpSender"
import Hl7WorkflowsBw from "../hl7WorkflowsBw"
import Hl7WorkflowsBw from "../botswana/hl7Workflows"
import got from "got"


/**
* Sends an ADT message to IPMS.
* @param labBundle The lab bundle to send.
* @returns The updated lab bundle.
*/
export async function sendAdtToIpms(labBundle: R4.IBundle): Promise<R4.IBundle> {
const status = getTaskStatus(labBundle)

Expand Down Expand Up @@ -35,12 +42,10 @@ export async function sendAdtToIpms(labBundle: R4.IBundle): Promise<R4.IBundle>
}

export async function sendOrmToIpms(bundles: any): Promise<R4.IBundle> {
const srBundle: IBundle = { resourceType: 'Bundle', entry: [] }
const srBundle: R4.IBundle = { resourceType: 'Bundle', entry: [] }
let labBundle = bundles.taskBundle
const patient = bundles.patient

// logger.info(`task bundle:\n${JSON.stringify(bundles.taskBundle)}\npatient:\n${JSON.stringify(bundles.patient)}`)

try {
// Replace PIMS/OpenMRS Patient Resource with one From IPMS Lab System
const pindex = labBundle.entry!.findIndex((entry: any) => {
Expand Down Expand Up @@ -129,20 +134,26 @@ export async function sendOrmToIpms(bundles: any): Promise<R4.IBundle> {
return labBundle
}

/**
* Handles ADT (Admission, Discharge, Transfer) messages received from IPMS (Integrated Patient Management System).
* @param registrationBundle - The registration bundle containing the patient information.
* @returns A Promise that resolves to the registration bundle.
*/
export async function handleAdtFromIpms(registrationBundle: R4.IBundle): Promise<R4.IBundle> {
try {
const options = {
timeout: config.get('bwConfig:requestTimeout'),
searchParams: {},
}

let patient: IPatient, omang: string
// Get patient from registration Bundle
let patient: R4.IPatient, omang: string
const patEntry = registrationBundle.entry!.find(entry => {
return entry.resource && entry.resource.resourceType == 'Patient'
})

if (patEntry && patEntry.resource) {
patient = <IPatient>patEntry.resource
patient = <R4.IPatient>patEntry.resource

const omangEntry = patient.identifier?.find(
i => i.system && i.system == config.get('bwConfig:omangSystemUrl'),
Expand All @@ -163,7 +174,7 @@ export async function handleAdtFromIpms(registrationBundle: R4.IBundle): Promise
_revinclude: 'Task:patient',
}

let patientTasks: IBundle
let patientTasks: R4.IBundle
try {
patientTasks = await got
.get(`${config.get('fhirServer:baseURL')}/Patient`, options)
Expand Down
7 changes: 4 additions & 3 deletions src/workflows/botswana/workflowHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,12 @@ export class WorkflowHandler {
enrichedBundle = await mapLocations(enrichedBundle)

this.sendPayload({ bundle: enrichedBundle }, topicList.SAVE_PIMS_PATIENT)

const response: R4.IBundle = await saveBundle(enrichedBundle)


await sendAdtToIpms(enrichedBundle)

// Succeed only if this bundle saves successfully
const response: R4.IBundle = await saveBundle(enrichedBundle)

break
case topicList.HANDLE_ADT_FROM_IPMS:
handleAdtFromIpms(origBundle)
Expand Down

0 comments on commit 5d90aac

Please sign in to comment.