Skip to content

Commit d92ff9a

Browse files
authored
Merge pull request #257 from jembi/TB-181-add-mapping-for-cr-candidates
Tb 181 add mapping for probabilistic patient matching
2 parents 7e241fb + 6abcd3e commit d92ff9a

File tree

13 files changed

+285
-218
lines changed

13 files changed

+285
-218
lines changed

client-registry-jempi/README.md

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (i
4646

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

49+
The `candidateThreshold` can optionally be set in the request query. The default value is 0.9
50+
4951
{
5052
"resourceType": "Patient",
5153
"gender": "male",
@@ -122,7 +124,7 @@ PATCH - http://localhost:50000/JeMPI/cr-update-fields
122124
via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format)
123125

124126
```sh
125-
PUT - http://localhost:3003/fhir/update/Patient/<PATIENT_GOLDEN_RECORD>
127+
PUT - http://localhost:3003/fhir/Patient/<PATIENT_GOLDEN_RECORD>
126128

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

191193
```sh
192-
POST http://localhost:3003/fhir/Patients
194+
GET http://localhost:3003/fhir/Patient
195+
196+
Query parameters - family, given, telecom, identifier, gender, birthDate, address (city)
197+
```
198+
199+
## Query patients probabilistic
200+
201+
via the api (in JeMPI format)
202+
203+
```sh
204+
POST - http://localhost:50000/JeMPI/cr-find
205+
206+
{
207+
"operand": {
208+
"fn": "match",
209+
"name": "givenName",
210+
"value": "drake",
211+
"distance": 2
212+
},
213+
"operands": [
214+
{
215+
"operator": "and",
216+
"operand": {
217+
"fn": "match",
218+
"name": "familyName",
219+
"value": "brake",
220+
"distance": 2
221+
}
222+
}
223+
]
224+
}
225+
```
226+
227+
via the [mapping mediator](https://github.com/jembi/openhim-mediator-mapping) (in fhir format)
228+
229+
```sh
230+
231+
POST http://localhost:3003/fhir/Patient/$match
193232

194233
{
195234
"resourceType": "Parameters",
196-
"parameters": [
235+
"parameter": [
197236
{
198-
"name": "and", // matches to the operator (options are "and" and "or")
199-
"valueCode": "familyName", // matches to the field name (options are "givenName", "familyName", "dob", "nationalId", "gender", "city" and "phoneNumber")
200-
"valueString": "creexxxeead" // matches to value of the field
237+
"name": "givenName",
238+
"valueString": "drake",
239+
"part": [
240+
{
241+
"name": "operator",
242+
"valueString": "and"
243+
},
244+
{
245+
"name": "fn",
246+
"valueString": "match"
247+
},
248+
{
249+
"name": "distance",
250+
"valueInteger": 2
251+
}
252+
]
201253
},
202254
{
203-
"name": "and",
204-
"valueCode": "city",
205-
"valueString": "Indianapeeolis"
255+
"name": "familyName",
256+
"valueString": "brake",
257+
"part": [
258+
{
259+
"name": "operator",
260+
"valueString": "and"
261+
},
262+
{
263+
"name": "fn",
264+
"valueString": "match"
265+
},
266+
{
267+
"name": "distance",
268+
"valueInteger": 2
269+
}
270+
]
206271
}
207272
]
208273
}

client-registry-jempi/importer/mapping-mediator/docker-compose.config.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ services:
2323
target: /searchAll.json
2424
- source: mediator-config-searchAllResponse.json
2525
target: /searchAllResponse.json
26+
- source: mediator-config-searchAllProbabilistic.json
27+
target: /searchAllProbabilistic.json
28+
- source: mediator-config-searchAllProbabilisticResponse.json
29+
target: /searchAllProbabilisticResponse.json
2630
networks:
2731
mapping-mediator:
2832
# This command will only attempt to import the config when the uptime responds with a 2xx
@@ -69,6 +73,16 @@ configs:
6973
name: mediator-config-searchAllResponse.json-${mediator_config_searchAllResponse_json_DIGEST:?err}
7074
labels:
7175
name: jempi
76+
mediator-config-searchAllProbabilistic.json:
77+
file: ./searchAllProbabilistic.json
78+
name: mediator-config-searchAllProbabilistic.json-${mediator_config_searchAllProbabilistic_json_DIGEST:?err}
79+
labels:
80+
name: jempi
81+
mediator-config-searchAllProbabilisticResponse.json:
82+
file: ./searchAllProbabilisticResponse.json
83+
name: mediator-config-searchAllProbabilisticResponse.json-${mediator_config_searchAllProbabilisticResponse_json_DIGEST:?err}
84+
labels:
85+
name: jempi
7286

7387
networks:
7488
mapping-mediator:

client-registry-jempi/importer/mapping-mediator/register-response.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
},
1111
"inputTransforms": {
1212
"currentDate": "$now()",
13+
"candidateThreshold": "$exists(query.candidateThreshold) ? query.candidateThreshold : constants.candidateThreshold",
1314
"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",
1415
"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",
1516
"name": "$exists(requestBody.name) and $exists(requestBody.name[0]) and $exists(requestBody.name[0].given[0]) ? requestBody.name[0].given[0] : null",
@@ -18,7 +19,7 @@
1819
"phoneNumber": "$exists(requestBody.telecom) and $exists(requestBody.telecom[0]) ? requestBody.telecom[0].value : null"
1920
},
2021
"inputMapping": {
21-
"constants.candidateThreshold": "candidateThreshold",
22+
"transforms.candidateThreshold": "candidateThreshold",
2223
"transforms.sourcePatient": "sourceId",
2324
"transforms.nationalId": "demographicData.nationalId",
2425
"transforms.familyName": "demographicData.familyName",
@@ -42,9 +43,6 @@
4243
"contentType": "application/fhir+json"
4344
},
4445
"url": "http://jempi-api:50000/JeMPI/cr-register"
45-
},
46-
"extract": {
47-
"JeMPIResponse": "$.body"
4846
}
4947
}
5048
}

client-registry-jempi/importer/mapping-mediator/register.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@
3535
"headers": {
3636
"contentType": "application/fhir+json"
3737
},
38-
"url": "http://openhim-mapping-mediator:3003/register-response"
38+
"url": "http://openhim-mapping-mediator:3003/register-response",
39+
"params": {
40+
"query": {
41+
"candidateThreshold": {
42+
"path": "query.candidateThreshold"
43+
}
44+
}
45+
}
3946
},
40-
"extract": {
41-
"JeMPIResponse": "$.body"
42-
}
47+
"fhirResponse": true
4348
}
4449
]
4550
}

client-registry-jempi/importer/mapping-mediator/search.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Search Patient by id",
33
"endpoint": {
44
"pattern": "/fhir/Patient/:patientId",
5-
"method": "POST"
5+
"method": "GET"
66
},
77
"transformation": {
88
"input": "JSON",

client-registry-jempi/importer/mapping-mediator/searchAll.json

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
{
2-
"name": "Search Endpoint",
2+
"name": "Search Endpoint deterministic",
33
"endpoint": {
4-
"pattern": "/fhir/Patients",
5-
"method": "POST"
4+
"pattern": "/fhir/Patient",
5+
"method": "GET"
66
},
77
"transformation": {
8-
"input": "JSON",
98
"output": "JSON"
109
},
11-
"constants": {
12-
"resourceType": "Bundle",
13-
"type": "searchset"
14-
},
1510
"inputTransforms": {
1611
"total": "$count(lookupRequests.jempiSearchAll.data.goldenRecords)",
1712
"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}}})"
@@ -22,20 +17,45 @@
2217
"transforms.total": "total",
2318
"transforms.entry": "entry"
2419
},
20+
"constants": {
21+
"resourceType": "Bundle",
22+
"type": "searchset"
23+
},
2524
"requests": {
2625
"lookup": [
2726
{
2827
"id": "jempiSearchAll",
29-
"forwardExistingRequestBody": true,
3028
"config": {
31-
"method": "post",
29+
"method": "get",
3230
"headers": {
3331
"contentType": "application/json"
3432
},
33+
"params": {
34+
"query": {
35+
"family": {
36+
"path": "query.family"
37+
},
38+
"given": {
39+
"path": "query.given"
40+
},
41+
"telecom": {
42+
"path": "query.telecom"
43+
},
44+
"identifier": {
45+
"path": "query.identifier"
46+
},
47+
"gender": {
48+
"path": "query.gender"
49+
},
50+
"birthDate": {
51+
"path": "query.birthDate"
52+
},
53+
"address": {
54+
"path": "query.address"
55+
}
56+
}
57+
},
3558
"url": "http://openhim-mapping-mediator:3003/search-response"
36-
},
37-
"extract": {
38-
"JeMPIResponse": "$.body"
3959
}
4060
}
4161
]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "Search Endpoint probabilistic",
3+
"endpoint": {
4+
"pattern": "/fhir/Patient/$match",
5+
"method": "POST"
6+
},
7+
"transformation": {
8+
"input": "JSON",
9+
"output": "JSON"
10+
},
11+
"constants": {
12+
"resourceType": "Bundle",
13+
"type": "searchset"
14+
},
15+
"inputTransforms": {
16+
"total": "$count(lookupRequests.jempiSearchAllProbabilistic.data.goldenRecords)",
17+
"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}}})"
18+
},
19+
"inputMapping": {
20+
"constants.resourceType": "resourceType",
21+
"constants.type": "type",
22+
"transforms.total": "total",
23+
"transforms.entry": "entry"
24+
},
25+
"requests": {
26+
"lookup": [
27+
{
28+
"id": "jempiSearchAllProbabilistic",
29+
"forwardExistingRequestBody": true,
30+
"config": {
31+
"method": "post",
32+
"headers": {
33+
"contentType": "application/json"
34+
},
35+
"url": "http://openhim-mapping-mediator:3003/search-response-probabilistic"
36+
},
37+
"fhirResponse": true
38+
}
39+
]
40+
}
41+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "Search Response Endpoint deterministic",
3+
"endpoint": {
4+
"pattern": "/search-response-probabilistic",
5+
"method": "POST"
6+
},
7+
"transformation": {
8+
"input": "JSON",
9+
"output": "JSON"
10+
},
11+
"inputValidation": {
12+
"type": "object",
13+
"properties": {
14+
"requestBody": {
15+
"type": "object",
16+
"properties": {
17+
"parameter": {
18+
"type": "array",
19+
"items": {
20+
"type": "object",
21+
"properties": {
22+
"name": {
23+
"type": "string"
24+
},
25+
"valueString": {
26+
"type": "string"
27+
},
28+
"part": {
29+
"type": "array",
30+
"items": {
31+
"type": "object",
32+
"properties": {
33+
"name": {
34+
"type": "string"
35+
},
36+
"valueString": {
37+
"type": "string"
38+
},
39+
"valueInteger": {
40+
"type": "number"
41+
}
42+
},
43+
"required": ["name"]
44+
}
45+
}
46+
},
47+
"required": ["name", "valueString", "part"]
48+
},
49+
"minItems": 1
50+
}
51+
},
52+
"required": ["parameter"]
53+
}
54+
}
55+
},
56+
"inputTransforms": {
57+
"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}}}))"
58+
},
59+
"inputMapping": {
60+
"transforms.operands": "operands",
61+
"transforms.operands[0].operand": "operand"
62+
},
63+
"requests": {
64+
"response": [
65+
{
66+
"id": "jempiSearchAllProbabilisticResponse",
67+
"config": {
68+
"method": "post",
69+
"url": "http://jempi-api:50000/JeMPI/cr-find"
70+
}
71+
}
72+
]
73+
}
74+
}

0 commit comments

Comments
 (0)