Skip to content

Commit

Permalink
Change the search all logic so the response in not nested in an object
Browse files Browse the repository at this point in the history
When the request comes in via the openhim, the mapping mediator responds in an openhim response format (this is needed for all the details of the transaction to be displayed on the openhim). The logic we had before was returning the response nested in an object with the orchestrations instead of only the response body. This has been changed
  • Loading branch information
bradsawadye committed Oct 30, 2023
1 parent b25ca6f commit 6abcd3e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
42 changes: 37 additions & 5 deletions client-registry-jempi/importer/mapping-mediator/searchAll.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,53 @@
"output": "JSON"
},
"inputTransforms": {
"operands": "($transform := function($v) {[query.family ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'familyName', 'value': query.family}},query.given ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'givenName', 'value': query.given}},query.gender ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'gender', 'value': query.gender}},query.birthDate ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'dob', 'value': query.birthDate}},query.address ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'city', 'value': query.address}},query.telecom ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'phoneNumber', 'value': query.telecom}},query.identifier ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'nationalId', 'value': query.identifier}}]};$transform(query))"
"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": {
"transforms.operands": "operands",
"transforms.operands[0].operand": "operand"
"constants.resourceType": "resourceType",
"constants.type": "type",
"transforms.total": "total",
"transforms.entry": "entry"
},
"constants": {
"resourceType": "Bundle",
"type": "searchset"
},
"requests": {
"response": [
"lookup": [
{
"id": "jempiSearchAll",
"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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@
"name": "Search Endpoint deterministic response",
"endpoint": {
"pattern": "/search-response",
"method": "POST"
"method": "GET"
},
"transformation": {
"input": "JSON",
"output": "JSON"
},
"constants": {
"resourceType": "Bundle",
"type": "searchset"
},
"inputTransforms": {
"total": "$count(lookupRequests.jempiSearchAllResponse.data.goldenRecords)",
"entry": "$map(lookupRequests.jempiSearchAllResponse.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}}})"
"operands": "($transform := function($v) {[query.family ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'familyName', 'value': query.family}},query.given ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'givenName', 'value': query.given}},query.gender ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'gender', 'value': query.gender}},query.birthDate ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'dob', 'value': query.birthDate}},query.address ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'city', 'value': query.address}},query.telecom ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'phoneNumber', 'value': query.telecom}},query.identifier ? {'operator': 'and', 'operand': {'fn': 'eq', 'name': 'nationalId', 'value': query.identifier}}]};$transform(query))"
},
"inputMapping": {
"constants.resourceType": "resourceType",
"constants.type": "type",
"transforms.total": "total",
"transforms.entry": "entry"
"transforms.operands": "operands",
"transforms.operands[0].operand": "operand"
},
"requests": {
"lookup": [
"response": [
{
"id": "jempiSearchAllResponse",
"forwardExistingRequestBody": true,
Expand Down

0 comments on commit 6abcd3e

Please sign in to comment.