onaio / fhir-tooling

A command line utility to support FHIR Core content authoring
Other
1 stars 1 forks source link

EUSM - Add support for importing service points #156

Closed Wambere closed 3 months ago

Wambere commented 4 months ago

Current service point structure from opensrp 1.0

Form https://example.smartregister.org/opensrp/rest/location/getAll?includeInactive=true&is_jurisdiction=false&limit=10&return_geometry=true&serverVersion=100

    {
        "type": "Feature",
        "id": "103ddb58-f359-4820-aaaa-459ba539913f",
        "geometry": {
            "type": "Point",
            "coordinates": [
                47.9,
                -14.844
            ]
        },
        "properties": {
            "type": "CSB 2",
            "status": "Active",
            "parentId": "5e8d93a2-47f2-4310-8cd3-069a34599b4e",
            "name": "CSB Ankazomena",
            "geographicLevel": 4,
            "version": 0,
            "AdminLevelTag": "Commune"
        },
        "serverVersion": 245849
    }
Wambere commented 4 months ago

FHIR version

{
  "resourceType": "Location",
  "id": "103ddb58-f359-4820-aaaa-459ba539913f",
  "identifier": [
    {"use": "official", "value": "103ddb58-f359-4820-aaaa-459ba539913f"}
  ],
  "type": {
    "coding": [
      {
        "system" : "http://terminology.hl7.org/CodeSystem/v3-RoleCode",
        "code"   : "??"                                             ,
        "display": "??"
      }
    ]
  },
  "status": "active",
  "name": "CSB Ankazomena",
  "alias": [??],
  "description": "??",
  "physicalType": {
    "coding": [
      {
        "system": "http://terminology.hl7.org/CodeSystem/location-physical-type",
        "code": "??",
        "display": "??"
      }
    ]
  },
  "partOf": {"reference": "Location/5e8d93a2-47f2-4310-8cd3-069a34599b4e"},
  "position": {"longitude": 47.9, "latitude": -14.844}
}

@dubdabasoduba please assist in filling in the above

Wambere commented 4 months ago

Mapping to current location csv json payload this maps to for context

Column Source
name properties -> name
status properties -> status
method "create"
id id
parentName ??
parentID properties -> parentId
type "Service point"
typeCode ??
physicalType ??
physicalTypeCode ??
* longitude geometry -> coordinates -> [0]
* latitude geometry -> coordinates -> [1]

To add geometry to json payload

"position": {"longitude": {{ longitude }}, "latitude": {{ latitude }}}

cc @dubdabasoduba @ageryck @AnnieMungai

Wambere commented 4 months ago

@ageryck this is ready to test, the geometry has been added

ageryck commented 3 months ago
SELECT DISTINCT json->'properties'->>'name' as name, json->'properties'->>'status' as status,'udpate' as method,json->>'id' as id,
(select name from core.location_metadata where geojson_id= json->'properties'->>'parentId') as parentName, json->'properties'->>'parentId' as parentId,
json->'properties'->>'type' as Type, 'svp' as TypeCode, null as physicalType, null as physicalTypeCode, json->'geometry'->'coordinates'->0 as longitude 
, json->'geometry'->'coordinates'->1 as latitude
from core.structure
ageryck commented 3 months ago

@dubdabasoduba below are the distinct service points in the DB how do we code them for value TypeCode;

"Village"
"CSB 2"
"Site Communautaire"
"Mairie"
"DRSP"
"CEG"
"Water Point"
"Warehouse"
"CHRD 2"
"CHRR"
"CSB 1"
"Presco"
"MEN"
"EPP"
"DRENETP"
"CHRD 1"
"Ecole privé"
ageryck commented 3 months ago

tested ok needs to agree on supported location types