Skip to content

Commit

Permalink
Merge pull request #256 from jembi/TB-180-add-mapping-for-cr-find
Browse files Browse the repository at this point in the history
Tb 180 add mappings for cr find
  • Loading branch information
MatthewErispe authored Oct 17, 2023
2 parents 7e0f091 + 3297e95 commit f632480
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 1 deletion.
48 changes: 48 additions & 0 deletions client-registry-jempi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,51 @@ PUT - http://localhost:3003/fhir/update/Patient/<PATIENT_GOLDEN_RECORD>
]
}
```

## 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"
}
]
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
43 changes: 43 additions & 0 deletions client-registry-jempi/importer/mapping-mediator/searchAll.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
}

0 comments on commit f632480

Please sign in to comment.