-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for extract location resource via hh-registeration-loc…
…ation-questionnaire
- Loading branch information
1 parent
7b04c19
commit c097b02
Showing
3 changed files
with
311 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
android/quest/src/test/resources/content/general/family/family-registration-gps.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
map "https://fhir.labs.smartregister.org/fhir/StructureMap/db883d33-5dd8-4b02-9838-db980cd8e87b" = "Household Registration" | ||
|
||
uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireReponse" as source | ||
uses "http://hl7.org/fhir/StructureDefinition/Bundle" as target | ||
uses "http://hl7.org/fhir/StructureDefinition/Group" as target | ||
|
||
group HouseholdRegistration(source src : QuestionnaireResponse, target bundle: Bundle) { | ||
src -> bundle.id = uuid() "rule_bundle_id"; | ||
src -> bundle.type = 'collection' "rule_bundle_type"; | ||
src -> bundle.entry as entry, entry.resource = create('Group') as group then | ||
ExtractGroup(src, group, bundle) "rule_bundle_entries"; | ||
} | ||
|
||
group ExtractGroup(source src : QuestionnaireResponse, target group : Group, target bundle: Bundle) { | ||
src -> group.id = uuid() "rule_group_id_generation"; | ||
src -> group.name = evaluate(src, $this.item.where(linkId = 'household.name').answer.value) "rule_group_name"; | ||
|
||
src -> group.identifier = create('Identifier') as groupIdentifierOpenSRPId then { | ||
src -> groupIdentifierOpenSRPId.value = evaluate(src, $this.item.where(linkId = 'household.id').answer.value) | ||
"rule_group_identifier_opensrp_id_value"; | ||
src -> groupIdentifierOpenSRPId.use = "official" "rule_group_identifier_opensrp_id_use"; | ||
src -> groupIdentifierOpenSRPId.period = create('Period') as period, period.start = evaluate(src, $this.authored) "rule_group_identifier_period"; | ||
} "rule_group_identifier_opensrp"; | ||
|
||
src -> group.identifier = create('Identifier') as groupIdentifier then { | ||
src -> groupIdentifier.value = uuid() "rule_group_identifier_value"; | ||
src -> groupIdentifier.use = "secondary" "rule_group_identifier_use"; | ||
} "rule_group_identifier"; | ||
|
||
src -> group.active = true "r_grp_status_data"; | ||
src -> group.type = 'person' "r_grp_type_data"; | ||
|
||
src -> group.code = create('CodeableConcept') as concept then ExtractHouseholdCode(src, concept) "r_grp_code_data"; | ||
|
||
src.item as groupCharLocation where(linkId='household.location') -> group.characteristic = create ('Group_Characteristic') as groupChar then { | ||
groupCharLocation -> groupChar.code = create('CodeableConcept') as villCode then{ | ||
src -> villCode.coding = c("http://ona.io/codes", "hh_location") as coding then { | ||
src -> coding.display = 'Household Location' "r_cp_cod_disp_l"; | ||
} "r_grp_lcode"; | ||
src -> villCode.text = evaluate(src, $this.item.where(linkId = 'household.location').answer.value) "r_vcc_hh_location"; | ||
} "r_cp_cc_coding_l"; | ||
groupCharLocation -> groupChar.exclude = false "r_cp_cc_exclude_l"; | ||
} "r_group_char_l"; | ||
|
||
src.item as groupGpsLocation where(linkId='location-widget') then { | ||
src then ExtractGpsLocation(groupGpsLocation, bundle, group) "r-gps-location"; | ||
} "r-gps-location-data"; | ||
} | ||
|
||
group ExtractGpsLocation(source src: QuestionnaireResponse, target bundle: Bundle, source group : Group) { | ||
src->bundle.entry as entry, | ||
entry.resource = create("Location") as gpsLocation then { | ||
src->gpsLocation.id = uuid(), | ||
gpsLocation.status = 'active', | ||
gpsLocation.mode = 'instance', | ||
//gpsLocation.address = 'Regsitering Household Village', // group.characteristic.code.text // | ||
//gpsLocation.name = group.name, //'Registering Household Name', | ||
gpsLocation.description = 'GPS Coordinates for Household Registration' "r_gps_type_data"; | ||
|
||
src -> gpsLocation.type = create('CodeableConcept') as code then { | ||
src -> code.coding = create('Coding') as coding then { | ||
src -> coding.system = 'https://fhir-ru.github.io/v3/ServiceDeliveryLocationRoleType/vs.html' "r_gps_type_coding_system"; | ||
src -> coding.code = 'PTRES' "r_gps_type_c_coding_code"; | ||
src -> coding.display = 'Patient\' Residence' "r_gps_type_c_coding_display"; | ||
} "r_gps_type_c_coding"; | ||
src -> code.text = 'Patient\'s Residence' "r_gps_type-text"; | ||
} "r_gps_location_type"; | ||
|
||
src -> gpsLocation.physicalType = create('CodeableConcept') as code then { | ||
src -> code.coding = create('Coding') as coding then { | ||
src -> coding.system = 'http://terminology.hl7.org/CodeSystem/location-physical-type' "r_gps_physicalType_coding_system"; | ||
src -> coding.code = 'ho' "r_gps_physicalType_c_coding_code"; | ||
src -> coding.display = 'House' "r_gps_physicalType_c_coding_display"; | ||
} "r_gps_physicalType_c_coding"; | ||
src -> code.text = 'House' "r_gps_physicalType-text"; | ||
} "r_gps_location_physicalType"; | ||
|
||
// src -> gpsLocation.position = create("BackboneElement") as position then { | ||
// src -> position.altitude = '0.0' "r-position-default-alt"; | ||
// src.item as itemLatitude where(linkId='latitude' and answer.value.exists()) then { | ||
// src -> position.latitude = evaluate(src, $this.item.where(linkId = 'latitude').answer.value.display) "r-position-latitude"; | ||
// } "r-latitude-item"; | ||
// src.item as itemLongitude where(linkId='longitude' and answer.value.exists()) then { | ||
// src -> position.longitude = evaluate(src, $this.item.where(linkId = 'longitude').answer.value.display) "r-position-longitude"; | ||
// } "r-longitude-item"; | ||
// } "r_position_data"; | ||
} "r_obs_date_ws"; | ||
|
||
} | ||
|
||
group ExtractHouseholdCode(source src : Group, target concept: CodeableConcept) { | ||
src -> concept.coding = c("https://www.snomed.org", "35359004") as coding then { | ||
src -> coding.display = 'Family' "r_cp_cod_disp"; | ||
} "r_cp_cc_cod"; | ||
} |
183 changes: 183 additions & 0 deletions
183
android/quest/src/test/resources/content/general/family/questionnaire-response-gps.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
{ | ||
"resourceType": "QuestionnaireResponse", | ||
"id": "47a2c01e-d968-44b8-9062-7172e77c5585", | ||
"meta": { | ||
"lastUpdated": "2024-02-20T10:57:25.069+05:00", | ||
"tag": [ | ||
{ | ||
"system": "http://fhir.ona.io", | ||
"code": "000005", | ||
"display": "Clinical Focus" | ||
}, | ||
{ | ||
"system": "http://fhir.ona.io", | ||
"code": "000005", | ||
"display": "Clinical Focus" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/care-team-tag-id", | ||
"code": "bf369c01-0fad-4e1b-8cab-aa0fe9642cfa", | ||
"display": "Practitioner CareTeam" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/location-tag-id", | ||
"code": "0a90ea06-1026-45c1-b64b-73e13b59ad1e", | ||
"display": "Practitioner Location" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/organisation-tag-id", | ||
"code": "d1ea93d6-5b98-4fdf-b868-18b963a08307", | ||
"display": "Practitioner Organization" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/practitioner-tag-id", | ||
"code": "6edaafb0-0212-4069-a0e2-c6a90a080c83", | ||
"display": "Practitioner" | ||
} | ||
] | ||
}, | ||
"contained": [ | ||
{ | ||
"resourceType": "Group", | ||
"id": "31db9c93-cb3a-4854-b9ff-61040a625381", | ||
"meta": { | ||
"tag": [ | ||
{ | ||
"system": "https://smartregister.org/app-version", | ||
"code": "1.0.3-echis", | ||
"display": "Application Version" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/care-team-tag-id", | ||
"code": "bf369c01-0fad-4e1b-8cab-aa0fe9642cfa", | ||
"display": "Practitioner CareTeam" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/location-tag-id", | ||
"code": "0a90ea06-1026-45c1-b64b-73e13b59ad1e", | ||
"display": "Practitioner Location" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/organisation-tag-id", | ||
"code": "d1ea93d6-5b98-4fdf-b868-18b963a08307", | ||
"display": "Practitioner Organization" | ||
}, | ||
{ | ||
"system": "https://smartregister.org/practitioner-tag-id", | ||
"code": "6edaafb0-0212-4069-a0e2-c6a90a080c83", | ||
"display": "Practitioner" | ||
} | ||
] | ||
}, | ||
"identifier": [ | ||
{ | ||
"use": "official", | ||
"value": "162149", | ||
"period": { | ||
"start": "2024-02-20T10:57:24+05:00" | ||
} | ||
}, | ||
{ | ||
"use": "secondary", | ||
"value": "52fd342e-e4fb-4768-ae3c-a7669fb449f9" | ||
} | ||
], | ||
"active": true, | ||
"type": "person", | ||
"code": { | ||
"coding": [ | ||
{ | ||
"system": "https://www.snomed.org", | ||
"code": "35359004", | ||
"display": "Family" | ||
} | ||
] | ||
}, | ||
"name": "HhregUnitTest", | ||
"managingEntity": { | ||
"reference": "Organization/d1ea93d6-5b98-4fdf-b868-18b963a08307" | ||
}, | ||
"characteristic": [ | ||
{ | ||
"code": { | ||
"coding": [ | ||
{ | ||
"system": "http://ona.io/codes", | ||
"code": "hh_location", | ||
"display": "Household Location" | ||
} | ||
], | ||
"text": "HhregVilla" | ||
}, | ||
"exclude": false | ||
} | ||
] | ||
} | ||
], | ||
"questionnaire": "Questionnaire/447a1f25-0c44-4638-ab3d-63a97113909b", | ||
"status": "completed", | ||
"subject": { | ||
"reference": "Group/31db9c93-cb3a-4854-b9ff-61040a625381" | ||
}, | ||
"authored": "2024-02-20T10:57:24+05:00", | ||
"author": { | ||
"reference": "Practitioner/6edaafb0-0212-4069-a0e2-c6a90a080c83" | ||
}, | ||
"item": [ | ||
{ | ||
"linkId": "7133a736-f901-4ef3-8861-2d0d00b1856e", | ||
"text": "HOUSEHOLD REGISTRATION" | ||
}, | ||
{ | ||
"linkId": "household.id", | ||
"text": "Household OpenSRP ID", | ||
"answer": [ | ||
{ | ||
"valueInteger": 162149 | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "household.name", | ||
"text": "Household Name", | ||
"answer": [ | ||
{ | ||
"valueString": "HhregUnitTest" | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "household.location", | ||
"text": "Household Village", | ||
"answer": [ | ||
{ | ||
"valueString": "HhregVilla" | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "location-widget", | ||
"text": "Location Widget", | ||
"item": [ | ||
{ | ||
"linkId": "latitude", | ||
"text": "Latitude", | ||
"answer": [ | ||
{ | ||
"valueDecimal": 24.8808488 | ||
} | ||
] | ||
}, | ||
{ | ||
"linkId": "longitude", | ||
"text": "Longitude", | ||
"answer": [ | ||
{ | ||
"valueDecimal": 67.0424254 | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |