Skip to content

Commit

Permalink
Merge pull request #294 from jembi/CU-86bynyk8j_Register-Platform-Def…
Browse files Browse the repository at this point in the history
…ault-Portal-applications-During-init

CU-86bynyk8j - Register Platform Default Portal applications During init
  • Loading branch information
drizzentic authored May 15, 2024
2 parents 2b2aab1 + 57cee7d commit 44a566b
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 32 deletions.
10 changes: 9 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
projectName: platform
image: jembi/platform:latest
image: jembi/platform:3.0.0-beta
logPath: /tmp/logs

packages:
Expand Down Expand Up @@ -74,3 +74,11 @@ profiles:
- openhim-mapping-mediator
envFiles:
- mpi.env

- name: test-recipe
packages:
- fhir-ig-importer
- kafka-mapper-consumer
envFiles:
- cdr-dw.env
dev: true
7 changes: 7 additions & 0 deletions fhir-ig-importer/importer/docker-compose.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
target: /openhimConfig.js
- source: fhir-ig-importer-config-importer-openhim-import.json
target: /openhim-import.json
- source: fhir-ig-importer-config-importer-ig-importer-app.json
target: /ig-importer-app.json
deploy:
replicas: 1
restart_policy:
Expand All @@ -34,6 +36,11 @@ configs:
name: fhir-ig-importer-config-importer-openhim-import.json-${fhir_ig_importer_config_importer_openhim_import_js_DIGEST:?err}
labels:
name: fhir-ig-importer
fhir-ig-importer-config-importer-ig-importer-app.json:
file: ./volume/ig-importer-app.json
name: fhir-ig-importer-config-importer-ig-importer-app.json-${fhir_ig_importer_config_importer_ig_importer_app_DIGEST:?err}
labels:
name: fhir-ig-importer

networks:
openhim:
Expand Down
11 changes: 11 additions & 0 deletions fhir-ig-importer/importer/volume/ig-importer-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "FHIR IG Importer",
"description": "FHIR IG microfrontend app",
"category": "HIE Configuration",
"type": "esmodule",
"url": "http://localhost:3000/jembi-fhir-ig-importer.js",
"showInPortal": true,
"showInSideBar": true,
"access_roles": ["admin"],
"icon": "https://fonts.gstatic.com/s/i/materialicons/medical_information/v1/24px.svg"
}
79 changes: 58 additions & 21 deletions fhir-ig-importer/importer/volume/openhimConfig.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,90 @@
"use strict";

const fs = require("fs");
const https = require("https");
const path = require("path");

("use strict");

const OPENHIM_CORE_SERVICE_NAME = "openhim-core";
const OPENHIM_MEDIATOR_API_PORT = 8080;
const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD || "instant101";
const OPENHIM_API_USERNAME =
process.env.OPENHIM_API_USERNAME || "[email protected]";

const authHeader = new Buffer.from(
const authHeader = Buffer.from(
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}`
).toString("base64");

function makeRequest(options, data) {
const req = https.request(options, (res) => {
if (res.statusCode == 401) {
throw new Error(`Incorrect OpenHIM API credentials`);
}

if (![201, 200].includes(res.statusCode)) {
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`);
}

console.log("Successfully Imported OpenHIM Config");
});

req.on("error", (error) => {
throw new Error(`Failed to import OpenHIM config: ${error}`);
});

req.write(data);
req.end();
}

const jsonData = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "openhim-import.json"))
);

const appJsonData = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "ig-importer-app.json"))
);

const data = JSON.stringify(jsonData);
const appData = JSON.stringify(appJsonData);

const options = {
protocol: "https:",
hostname: OPENHIM_CORE_SERVICE_NAME,
port: OPENHIM_MEDIATOR_API_PORT,
path: "/metadata",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": data.length,
Authorization: `Basic ${authHeader}`,
},
};

const req = https.request(options, (res) => {
if (res.statusCode == 401) {
throw new Error(`Incorrect OpenHIM API credentials`);
}

if (res.statusCode != 201) {
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`);
}
const reqOptions = {
...options,
path: "/metadata",
method: "POST",
headers: {
...options.headers,
"Content-Length": data.length,
},
};

console.log("Successfully Imported OpenHIM Config");
});
const appReqOptions = {
...options,
path: "/apps",
method: "POST",
headers: {
...options.headers,
"Content-Length": appData.length,
},
};

req.on("error", (error) => {
throw new Error(`Failed to import OpenHIM config: ${error}`);
});
const importMapRebuildOptions = {
...options,
path: "/apps",
method: "GET",
headers: {
...options.headers,
},
};

req.write(data);
req.end();
makeRequest(reqOptions, data);
makeRequest(appReqOptions, appData);
makeRequest(importMapRebuildOptions, "");
2 changes: 1 addition & 1 deletion interoperability-layer-openhim/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "infrastructure",
"dependencies": [],
"environmentVariables": {
"OPENHIM_CORE_IMAGE": "jembi/openhim-core:microfrontends-pre-release",
"OPENHIM_CORE_IMAGE": "jembi/openhim-core:microfrontends-3.0.0-beta",
"MONGO_SET_COUNT": "1",
"OPENHIM_CORE_INSTANCES": "1",
"OPENHIM_CONSOLE_INSTANCES": "1",
Expand Down
11 changes: 11 additions & 0 deletions kafka-mapper-consumer/consumer-ui-app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Kafka Mapper Consumer",
"description": "Kafka mapper consumer microfrontends app",
"category": "HIE Configuration",
"type": "esmodule",
"url": "http://localhost:8091/jembi-kafka-mapper-consumer-ui.js",
"showInPortal": true,
"showInSideBar": false,
"access_roles": ["admin"],
"icon": "https://fonts.gstatic.com/s/i/materialicons/apps/v12/24px.svg"
}
41 changes: 41 additions & 0 deletions kafka-mapper-consumer/docker-compose.config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.9'

services:
# container for executing config import scripts for creating the OpenHIM channels used by the Mediator
kafka-mapper-consumer-config-importer:
image: node:erbium-alpine
networks:
openhim:
default:
environment:
OPENHIM_API_USERNAME: ${OPENHIM_USERNAME}
OPENHIM_API_PASSWORD: ${OPENHIM_PASSWORD}
# Reject unauthorised is only needed if the OpenHIM's SSL is not setup
NODE_TLS_REJECT_UNAUTHORIZED: 0
command: sh -c "node openhimConfig.js"
configs:
- source: kafka-mapper-consumer-openhimConfig.js
target: /openhimConfig.js
- source: kafka-mapper-consumer-consumer-ui-app.json
target: /consumer-ui-app.json
deploy:
replicas: 1
restart_policy:
condition: none

configs:
kafka-mapper-consumer-openhimConfig.js:
file: ./openhimConfig.js
name: kafka-mapper-consumer-openhimConfig.js-${fhir_ig_importer_config_importer_openhimConfig_js_DIGEST:?err}
labels:
name: kafka-mapper-consumer
kafka-mapper-consumer-consumer-ui-app.json:
file: ./consumer-ui-app.json
name: kafka-mapper-consumer-consumer-ui-app.json-${kafka_mapper_consumer_ui_json_DIGEST:?err}
labels:
name: kafka-mapper-consumer

networks:
openhim:
name: openhim_public
external: true
72 changes: 72 additions & 0 deletions kafka-mapper-consumer/openhimConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const fs = require("fs");
const https = require("https");
const path = require("path");

("use strict");

const OPENHIM_CORE_SERVICE_NAME = "openhim-core";
const OPENHIM_MEDIATOR_API_PORT = 8080;
const OPENHIM_API_PASSWORD = process.env.OPENHIM_API_PASSWORD || "instant101";
const OPENHIM_API_USERNAME =
process.env.OPENHIM_API_USERNAME || "[email protected]";

const authHeader = Buffer.from(
`${OPENHIM_API_USERNAME}:${OPENHIM_API_PASSWORD}`
).toString("base64");
function makeRequest(options, data) {
const req = https.request(options, (res) => {
if (res.statusCode == 401) {
throw new Error(`Incorrect OpenHIM API credentials`);
}

if (![201, 200].includes(res.statusCode)) {
throw new Error(`Failed to import OpenHIM config: ${res.statusCode}`);
}

console.log("Successfully Imported OpenHIM Config");
});

req.on("error", (error) => {
throw new Error(`Failed to import OpenHIM config: ${error}`);
});

req.write(data);
req.end();
}

const appJsonData = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "consumer-ui-app.json"))
);
const appData = JSON.stringify(appJsonData);

const options = {
protocol: "https:",
hostname: OPENHIM_CORE_SERVICE_NAME,
port: OPENHIM_MEDIATOR_API_PORT,
headers: {
"Content-Type": "application/json",
Authorization: `Basic ${authHeader}`,
},
};

const appReqOptions = {
...options,
path: "/apps",
method: "POST",
headers: {
...options.headers,
"Content-Length": appData.length,
},
};

const importMapRebuildOptions = {
...options,
path: "/apps",
method: "GET",
headers: {
...options.headers,
},
};

makeRequest(appReqOptions, appData);
makeRequest(importMapRebuildOptions, "");
2 changes: 1 addition & 1 deletion kafka-mapper-consumer/package-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"CLICKHOUSE_HOST": "analytics-datastore-clickhouse",
"CLICKHOUSE_PORT": "8123",
"KAFKA_CONSUMER_MAPPER_MEDIATOR_VERSION": "jembi/kafka-mapper-consumer:0.1.0",
"KAFKA_CONSUMER_MAPPER_UI_VERSION": "jembi/kafka-mapper-consumer-ui:0.1.0-alpha"
"KAFKA_CONSUMER_MAPPER_UI_VERSION": "jembi/kafka-mapper-consumer-ui:0.1.1-alpha"
}
}
1 change: 1 addition & 0 deletions kafka-mapper-consumer/swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function initialize_package() {
log error "Failed to deploy package"
exit 1
}
docker::deploy_config_importer $STACK "$COMPOSE_FILE_PATH/docker-compose.config.yml" "kafka-mapper-consumer-config-importer" "kafka-mapper-consumer"
}

function destroy_package() {
Expand Down
15 changes: 7 additions & 8 deletions test/cucumber/features/single-mode/recipe.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: CDR-DW recipe?
Does the recipe work as expected

Scenario: Init the CDR recipe
Scenario: Init the CDR recipe
Given I use parameters "package init -p cdr-dw --dev --env-file=cdr-dw.env"
When I launch the platform with params
Then The service "mongo-1" should be started with 1 replica
Expand All @@ -12,7 +12,6 @@ Scenario: Init the CDR recipe
And The service "kafka-01" should be started with 1 replica
And The service "kafdrop" should be started with 1 replica
And The service "kafka-minion" should be started with 1 replica
And The service "keycloak-postgres-1" should be started with 1 replica
And The service "identity-access-manager-keycloak" should be started with 1 replica
And The service "jempi-ratel" should be started with 1 replica
And The service "jempi-alpha-01" should be started with 1 replica
Expand All @@ -35,27 +34,27 @@ Scenario: Init the CDR recipe
And The service "dashboard-visualiser-superset" should be started with 1 replica
And The service "analytics-datastore-clickhouse" should be started with 1 replica

Scenario: Send Fhir bundle and store the clinical data in the Fhir datastore, the patient info in the CR
Scenario: Send Fhir bundle and store the clinical data in the Fhir datastore, the patient info in the CR
Given I have configured the cdr
When I send a fhir patient bundle
Then the clinical data should be stored in hapi fhir
And the patient data in the Jempi client registry
And the data should be stored in clickhouse

Scenario: Fetch International Patient summary (IPS)
Scenario: Fetch International Patient summary (IPS)
When I then send a fhir patient summary request
Then I should get a successful summary response

Scenario: Fetch everything for a patient (all the clinical data)
Scenario: Fetch everything for a patient (all the clinical data)
When I then send a request for all the patient's clinical data
Then I should get a successful everything response

Scenario: Bring down the servers
Scenario: Bring down the servers
Given I use parameters "package down -p cdr-dw --env-file=cdr-dw.env"
When I launch the platform with params
Then a request to fetch data from the cdr should fail

Scenario: Bring up the servers and test
Scenario: Bring up the servers and test
Given I use parameters "package up -p cdr-dw --dev --env-file=cdr-dw.env"
When I launch the platform with params
Then The service "mongo-1" should be started with 1 replica
Expand All @@ -67,7 +66,7 @@ Scenario: Bring up the servers and test
Then I should get a successful everything response
And the data should be stored in clickhouse

Scenario: Destroy the services
Scenario: Destroy the services
Given I use parameters "package remove -p cdr-dw --env-file=cdr-dw.env"
When I launch the platform with params
Then There should be 0 service
Expand Down

0 comments on commit 44a566b

Please sign in to comment.