Skip to content

Commit

Permalink
Merge pull request #257 from jembi/TB-181-add-mapping-for-cr-candidates
Browse files Browse the repository at this point in the history
Tb 181 add mapping for probabilistic patient matching
  • Loading branch information
bradsawadye committed Oct 31, 2023
2 parents 7e241fb + 6abcd3e commit d92ff9a
Show file tree
Hide file tree
Showing 13 changed files with 285 additions and 218 deletions.
83 changes: 74 additions & 9 deletions client-registry-jempi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (i

POST http://localhost:3003/fhir/Patient

The `candidateThreshold` can optionally be set in the request query. The default value is 0.9

{
"resourceType": "Patient",
"gender": "male",
Expand Down Expand Up @@ -122,7 +124,7 @@ PATCH - http://localhost:50000/JeMPI/cr-update-fields
via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format)

```sh
PUT - http://localhost:3003/fhir/update/Patient/<PATIENT_GOLDEN_RECORD>
PUT - http://localhost:3003/fhir/Patient/<PATIENT_GOLDEN_RECORD>

{
"resourceType": "Patient",
Expand Down Expand Up @@ -189,20 +191,83 @@ POST http://localhost:50000/JeMPI/cr-find
via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format)

```sh
POST http://localhost:3003/fhir/Patients
GET http://localhost:3003/fhir/Patient

Query parameters - family, given, telecom, identifier, gender, birthDate, address (city)
```

## Query patients probabilistic

via the api (in JeMPI format)

```sh
POST - http://localhost:50000/JeMPI/cr-find

{
"operand": {
"fn": "match",
"name": "givenName",
"value": "drake",
"distance": 2
},
"operands": [
{
"operator": "and",
"operand": {
"fn": "match",
"name": "familyName",
"value": "brake",
"distance": 2
}
}
]
}
```

via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format)

```sh

POST http://localhost:3003/fhir/Patient/$match

{
"resourceType": "Parameters",
"parameters": [
"parameter": [
{
"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": "givenName",
"valueString": "drake",
"part": [
{
"name": "operator",
"valueString": "and"
},
{
"name": "fn",
"valueString": "match"
},
{
"name": "distance",
"valueInteger": 2
}
]
},
{
"name": "and",
"valueCode": "city",
"valueString": "Indianapeeolis"
"name": "familyName",
"valueString": "brake",
"part": [
{
"name": "operator",
"valueString": "and"
},
{
"name": "fn",
"valueString": "match"
},
{
"name": "distance",
"valueInteger": 2
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ services:
target: /searchAll.json
- source: mediator-config-searchAllResponse.json
target: /searchAllResponse.json
- source: mediator-config-searchAllProbabilistic.json
target: /searchAllProbabilistic.json
- source: mediator-config-searchAllProbabilisticResponse.json
target: /searchAllProbabilisticResponse.json
networks:
mapping-mediator:
# This command will only attempt to import the config when the uptime responds with a 2xx
Expand Down Expand Up @@ -69,6 +73,16 @@ configs:
name: mediator-config-searchAllResponse.json-${mediator_config_searchAllResponse_json_DIGEST:?err}
labels:
name: jempi
mediator-config-searchAllProbabilistic.json:
file: ./searchAllProbabilistic.json
name: mediator-config-searchAllProbabilistic.json-${mediator_config_searchAllProbabilistic_json_DIGEST:?err}
labels:
name: jempi
mediator-config-searchAllProbabilisticResponse.json:
file: ./searchAllProbabilisticResponse.json
name: mediator-config-searchAllProbabilisticResponse.json-${mediator_config_searchAllProbabilisticResponse_json_DIGEST:?err}
labels:
name: jempi

networks:
mapping-mediator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"inputTransforms": {
"currentDate": "$now()",
"candidateThreshold": "$exists(query.candidateThreshold) ? query.candidateThreshold : constants.candidateThreshold",
"sourcePatient": "$exists(requestBody.identifier) and $exists(requestBody.identifier[0]) and $exists(requestBody.identifier[0].value) ? {'patient': requestBody.identifier[0].value, 'facility': requestBody.identifier[0].system} : null",
"nationalId": "$exists(requestBody.identifier) and $exists(requestBody.identifier[0]) and $count($filter(requestBody.identifier, function($v) {$contains($v.system, 'NationalID')})) > 0 ? $filter(requestBody.identifier, function($v) {$contains($v.system, 'NationalID')})[0].value : null",
"name": "$exists(requestBody.name) and $exists(requestBody.name[0]) and $exists(requestBody.name[0].given[0]) ? requestBody.name[0].given[0] : null",
Expand All @@ -18,7 +19,7 @@
"phoneNumber": "$exists(requestBody.telecom) and $exists(requestBody.telecom[0]) ? requestBody.telecom[0].value : null"
},
"inputMapping": {
"constants.candidateThreshold": "candidateThreshold",
"transforms.candidateThreshold": "candidateThreshold",
"transforms.sourcePatient": "sourceId",
"transforms.nationalId": "demographicData.nationalId",
"transforms.familyName": "demographicData.familyName",
Expand All @@ -42,9 +43,6 @@
"contentType": "application/fhir+json"
},
"url": "http://jempi-api:50000/JeMPI/cr-register"
},
"extract": {
"JeMPIResponse": "$.body"
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions client-registry-jempi/importer/mapping-mediator/register.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@
"headers": {
"contentType": "application/fhir+json"
},
"url": "http://openhim-mapping-mediator:3003/register-response"
"url": "http://openhim-mapping-mediator:3003/register-response",
"params": {
"query": {
"candidateThreshold": {
"path": "query.candidateThreshold"
}
}
}
},
"extract": {
"JeMPIResponse": "$.body"
}
"fhirResponse": true
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Search Patient by id",
"endpoint": {
"pattern": "/fhir/Patient/:patientId",
"method": "POST"
"method": "GET"
},
"transformation": {
"input": "JSON",
Expand Down
46 changes: 33 additions & 13 deletions client-registry-jempi/importer/mapping-mediator/searchAll.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"name": "Search Endpoint",
"name": "Search Endpoint deterministic",
"endpoint": {
"pattern": "/fhir/Patients",
"method": "POST"
"pattern": "/fhir/Patient",
"method": "GET"
},
"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}}})"
Expand All @@ -22,20 +17,45 @@
"transforms.total": "total",
"transforms.entry": "entry"
},
"constants": {
"resourceType": "Bundle",
"type": "searchset"
},
"requests": {
"lookup": [
{
"id": "jempiSearchAll",
"forwardExistingRequestBody": true,
"config": {
"method": "post",
"method": "get",
"headers": {
"contentType": "application/json"
},
"params": {
"query": {
"family": {
"path": "query.family"
},
"given": {
"path": "query.given"
},
"telecom": {
"path": "query.telecom"
},
"identifier": {
"path": "query.identifier"
},
"gender": {
"path": "query.gender"
},
"birthDate": {
"path": "query.birthDate"
},
"address": {
"path": "query.address"
}
}
},
"url": "http://openhim-mapping-mediator:3003/search-response"
},
"extract": {
"JeMPIResponse": "$.body"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "Search Endpoint probabilistic",
"endpoint": {
"pattern": "/fhir/Patient/$match",
"method": "POST"
},
"transformation": {
"input": "JSON",
"output": "JSON"
},
"constants": {
"resourceType": "Bundle",
"type": "searchset"
},
"inputTransforms": {
"total": "$count(lookupRequests.jempiSearchAllProbabilistic.data.goldenRecords)",
"entry": "$map(lookupRequests.jempiSearchAllProbabilistic.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": "jempiSearchAllProbabilistic",
"forwardExistingRequestBody": true,
"config": {
"method": "post",
"headers": {
"contentType": "application/json"
},
"url": "http://openhim-mapping-mediator:3003/search-response-probabilistic"
},
"fhirResponse": true
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "Search Response Endpoint deterministic",
"endpoint": {
"pattern": "/search-response-probabilistic",
"method": "POST"
},
"transformation": {
"input": "JSON",
"output": "JSON"
},
"inputValidation": {
"type": "object",
"properties": {
"requestBody": {
"type": "object",
"properties": {
"parameter": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"valueString": {
"type": "string"
},
"part": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"valueString": {
"type": "string"
},
"valueInteger": {
"type": "number"
}
},
"required": ["name"]
}
}
},
"required": ["name", "valueString", "part"]
},
"minItems": 1
}
},
"required": ["parameter"]
}
}
},
"inputTransforms": {
"operands": "$append([], $map(requestBody.parameter, function($v) {{'operator': $single($v.part, function($v) {$v.name = 'operator'}).valueString, 'operand': {'fn': $single($v.part, function($v) {$v.name = 'fn'}).valueString, 'distance': $single($v.part, function($v) {$v.name = 'distance'}).valueInteger, 'name': $v.name, 'value': $v.valueString}}}))"
},
"inputMapping": {
"transforms.operands": "operands",
"transforms.operands[0].operand": "operand"
},
"requests": {
"response": [
{
"id": "jempiSearchAllProbabilisticResponse",
"config": {
"method": "post",
"url": "http://jempi-api:50000/JeMPI/cr-find"
}
}
]
}
}
Loading

0 comments on commit d92ff9a

Please sign in to comment.