From b619dbc15c50fbf0350c254087056a61a35e1742 Mon Sep 17 00:00:00 2001 From: bradsawadye Date: Mon, 16 Oct 2023 14:39:45 +0200 Subject: [PATCH 1/2] Add mappings for the jempi endpoint for retrieving the patients This adds mappings that will be used in the mapping mediator for mapping the jempi patient into fhir format TB-180 --- .../docker-compose.config.yml | 15 +++- .../importer/mapping-mediator/searchAll.json | 43 ++++++++++++ .../mapping-mediator/searchAllResponse.json | 69 +++++++++++++++++++ 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 client-registry-jempi/importer/mapping-mediator/searchAll.json create mode 100644 client-registry-jempi/importer/mapping-mediator/searchAllResponse.json diff --git a/client-registry-jempi/importer/mapping-mediator/docker-compose.config.yml b/client-registry-jempi/importer/mapping-mediator/docker-compose.config.yml index 4c2c7965..7c761fdf 100644 --- a/client-registry-jempi/importer/mapping-mediator/docker-compose.config.yml +++ b/client-registry-jempi/importer/mapping-mediator/docker-compose.config.yml @@ -19,6 +19,10 @@ services: target: /update.json - source: mediator-config-search.json target: /search.json + - source: mediator-config-searchAll.json + target: /searchAll.json + - source: mediator-config-searchAllResponse.json + target: /searchAllResponse.json networks: mapping-mediator: # This command will only attempt to import the config when the uptime responds with a 2xx @@ -55,7 +59,16 @@ configs: name: mediator-config-search.json-${mediator_config_search_json_DIGEST:?err} labels: name: jempi - + mediator-config-searchAll.json: + file: ./searchAll.json + name: mediator-config-searchAll.json-${mediator_config_searchAll_json_DIGEST:?err} + labels: + name: jempi + mediator-config-searchAllResponse.json: + file: ./searchAllResponse.json + name: mediator-config-searchAllResponse.json-${mediator_config_searchAllResponse_json_DIGEST:?err} + labels: + name: jempi networks: mapping-mediator: diff --git a/client-registry-jempi/importer/mapping-mediator/searchAll.json b/client-registry-jempi/importer/mapping-mediator/searchAll.json new file mode 100644 index 00000000..54c04047 --- /dev/null +++ b/client-registry-jempi/importer/mapping-mediator/searchAll.json @@ -0,0 +1,43 @@ +{ + "name": "Search Endpoint", + "endpoint": { + "pattern": "/fhir/Patients", + "method": "POST" + }, + "transformation": { + "input": "JSON", + "output": "JSON" + }, + "constants": { + "resourceType": "Bundle", + "type": "searchset" + }, + "inputTransforms": { + "total": "$count(lookupRequests.jempiSearchAll.data.goldenRecords)", + "entry": "$map(lookupRequests.jempiSearchAll.data.goldenRecords, function($v) {{'fullUrl': 'Patient/' & $v.goldenId, 'resource': {'resourceType': 'Patient','id': $v.goldenId,'name': {'given': [$v.demographicData.givenName],'family': $v.demographicData.familyName},'address': [{'city': $v.demographicData.city}],'birthDate': $v.demographicData.dob,'telecom': [{'value': $v.demographicData.phoneNumber,'system': 'phone'}],'identifier': [{'system': $v.sourceId.facility,'value': $v.sourceId.patient},{'system': 'NationalID','value': $v.demographicData.nationalId}],'gender': $v.demographicData.gender}}})" + }, + "inputMapping": { + "constants.resourceType": "resourceType", + "constants.type": "type", + "transforms.total": "total", + "transforms.entry": "entry" + }, + "requests": { + "lookup": [ + { + "id": "jempiSearchAll", + "forwardExistingRequestBody": true, + "config": { + "method": "post", + "headers": { + "contentType": "application/json" + }, + "url": "http://openhim-mapping-mediator:3003/search-response" + }, + "extract": { + "JeMPIResponse": "$.body" + } + } + ] + } +} diff --git a/client-registry-jempi/importer/mapping-mediator/searchAllResponse.json b/client-registry-jempi/importer/mapping-mediator/searchAllResponse.json new file mode 100644 index 00000000..aa9a4bb5 --- /dev/null +++ b/client-registry-jempi/importer/mapping-mediator/searchAllResponse.json @@ -0,0 +1,69 @@ +{ + "name": "Search Response Endpoint", + "endpoint": { + "pattern": "/search-response", + "method": "POST" + }, + "transformation": { + "input": "JSON", + "output": "JSON" + }, + "inputValidation": { + "type": "object", + "properties": { + "requestBody": { + "type": "object", + "properties": { + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "valueCode": { + "type": "string" + }, + "valueString": { + "type": "string" + } + }, + "required": ["name", "valueCode", "valueString"] + }, + "minItems": 1 + } + }, + "required": [ + "parameters" + ] + } + } + }, + "inputTransforms": { + "operands": "$append([], $map(requestBody.parameters, function($v) {{'operator': $v.name, 'operand': {'fn': 'eq', 'name': $v.valueCode, 'value': $v.valueString}}}))" + }, + "constants": { + "operator": "or", + "function": "match", + "operandFunction": "eq" + }, + "inputMapping": { + "transforms.operands": "operands", + "transforms.operands[0].operand": "operand" + }, + "requests": { + "response": [ + { + "id": "jempiSearchAllResponse", + "config": { + "method": "post", + "url": "http://jempi-api:50000/JeMPI/cr-find" + }, + "extract": { + "JeMPIResponse": "$.body" + } + } + ] + } +} From 3312c58714a26a24da33a2bb1dd495493fc7bdbe Mon Sep 17 00:00:00 2001 From: bradsawadye Date: Mon, 16 Oct 2023 14:41:49 +0200 Subject: [PATCH 2/2] Update the readme with instructions for retrieving patients in jempi and fhir format TB-180 --- client-registry-jempi/README.md | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/client-registry-jempi/README.md b/client-registry-jempi/README.md index f2bdca9d..39446d7e 100644 --- a/client-registry-jempi/README.md +++ b/client-registry-jempi/README.md @@ -159,3 +159,51 @@ PUT - http://localhost:3003/fhir/update/Patient/ ] } ``` + +## Query all patients deterministic + +via the api (returns in JeMPI format) + +```sh +POST http://localhost:50000/JeMPI/cr-find + +{ + "operand": { + "fn": "eq", + "name": "givenName", + "value": "xxx" + }, + "operands": [ + { + "operator": "and", + "operand": { + "fn": "eq", + "name": "familyName", + "value": "yyy" + } + } + ] +} +``` + +via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format) + +```sh +POST http://localhost:3003/fhir/Patients + +{ + "resourceType": "Parameters", + "parameters": [ + { + "name": "and", // matches to the operator (options are "and" and "or") + "valueCode": "familyName", // matches to the field name (options are "givenName", "familyName", "dob", "nationalId", "gender", "city" and "phoneNumber") + "valueString": "creexxxeead" // matches to value of the field + }, + { + "name": "and", + "valueCode": "city", + "valueString": "Indianapeeolis" + } + ] +} +```