From d87372b439af3f2b0a826f4bccacfa79da193fd8 Mon Sep 17 00:00:00 2001 From: "openfn[bot]" Date: Thu, 13 Jun 2024 14:21:03 +0000 Subject: [PATCH] user aisha@openfn.org initiated a sync from Lightning --- ...d48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml | 41 ++++++++----------- ...48e-451b-4a92-9aad-e7c62a7f0923-state.json | 12 +++--- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml b/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml index 574a048..599b785 100644 --- a/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml +++ b/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml @@ -127,17 +127,12 @@ workflows: # credential: # globals: body: | - fn(state=> { - //Removig PII here before sending it to NDR - delete state.data.name; - delete state.data.telecom; - delete state.data.contact; - delete state.data.extension; //contains religion, occupation, education level, target pop group - delete state.data.maritalStatus; - - //only keeping birthdate and gender - - return state; + fn(state => { + const parsedData = JSON.parse(state.data.body); + console.log(parsedData); + state.resource = parsedData.entry[0].resource; + console.log('show only the resource:: ', state.resource); + return state; }) Create-Organization: name: Create Organization @@ -156,9 +151,9 @@ workflows: # credential: # globals: body: | - post($.data.resourceType, + post($.resource.resourceType, { - body: $.patient, + body: $.mapped_resource, errors: { 400: false }, headers: {'content-type': 'application/json'}, parseAs: 'json' @@ -232,11 +227,11 @@ workflows: body: | fn(state=> { //Map CDR data to NDR FHIR IG - const cdrData = state.data; - const patient = { + const cdrData = state.resource; + const mapped_resource = { resourceType: cdrData.resourceType, id: cdrData.id, - identifier: cdrData.identifier.map(id => ({ + identifier: cdrData.identifier?.map(id => ({ type: id.system == "http://cdr.aacahb.gov.et/MRN"? { "coding": [ { @@ -258,8 +253,8 @@ workflows: deceasedBoolean: cdrData.deceasedBoolean, text: cdrData.text }; - // returned the mapped patient object - return {...state, patient} + // returned the mapped fhir resource + return {...state, mapped_resource} }) Remove-PIIs: name: Remove PIIs @@ -269,11 +264,11 @@ workflows: body: | fn(state=> { //Removig PII here before sending it to NDR - delete state.data.name; - delete state.data.telecom; - delete state.data.contact; - delete state.data.extension; //contains religion, occupation, education level, target pop group - delete state.data.maritalStatus; + delete state.resource.name; + delete state.resource.telecom; + delete state.resource.contact; + delete state.resource.extension; //contains religion, occupation, education level, target pop group + delete state.resource.maritalStatus; //only keeping birthdate and gender diff --git a/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json b/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json index 6d31092..6ce51b7 100644 --- a/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json +++ b/openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json @@ -88,10 +88,10 @@ "id": "ad8f643a-6bda-453e-af48-aeb213069538", "name": "cdr-to-ndr", "inserted_at": "2024-06-13T08:12:03Z", - "updated_at": "2024-06-13T13:54:51Z", + "updated_at": "2024-06-13T14:06:15Z", "project_id": "d52bd48e-451b-4a92-9aad-e7c62a7f0923", "deleted_at": null, - "lock_version": 41, + "lock_version": 48, "triggers": { "webhook": { "enabled": true, @@ -103,7 +103,7 @@ "Analyze-Data": { "id": "205bd35c-32e0-4cd0-964f-98d4c6729a8b", "name": "Analyze Data", - "body": "fn(state=> {\n //Removig PII here before sending it to NDR\n delete state.data.name;\n delete state.data.telecom;\n delete state.data.contact;\n delete state.data.extension; //contains religion, occupation, education level, target pop group\n delete state.data.maritalStatus; \n\n //only keeping birthdate and gender\n\n return state;\n})", + "body": "fn(state => {\n const parsedData = JSON.parse(state.data.body); \n console.log(parsedData); \n state.resource = parsedData.entry[0].resource; \n console.log('show only the resource:: ', state.resource);\n return state; \n})", "adaptor": "@openfn/language-common@latest" }, "Create-Organization": { @@ -115,7 +115,7 @@ "Create-FHIR-Resource": { "id": "75e04925-019d-4787-853a-54275fedd86f", "name": "Create FHIR Resource", - "body": "post($.data.resourceType, \n {\n body: $.patient, \n errors: { 400: false }, \t\n headers: {'content-type': 'application/json'},\n parseAs: 'json'\n },\n state => {\n state.data.response = state.response; \n return state; \n})", + "body": "post($.resource.resourceType, \n {\n body: $.mapped_resource, \n errors: { 400: false }, \t\n headers: {'content-type': 'application/json'},\n parseAs: 'json'\n },\n state => {\n state.data.response = state.response; \n return state; \n})", "adaptor": "@openfn/language-http@latest" }, "Create-Encounter": { @@ -139,13 +139,13 @@ "Map-Data": { "id": "e4bad1bf-a006-405f-ae2e-681968c9ebf6", "name": "Map Data", - "body": "fn(state=> {\n //Map CDR data to NDR FHIR IG\n const cdrData = state.data;\n const patient = {\n resourceType: cdrData.resourceType,\n id: cdrData.id,\n identifier: cdrData.identifier.map(id => ({\n type: id.system == \"http://cdr.aacahb.gov.et/MRN\"? {\n \"coding\": [\n {\n \"code\": \"MR\",\n \"display\": \"Medical record number\",\n \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\"\n }\n ],\n \"text\": \"Medical record number\"\n } : undefined,\n system: id.system,\n value: id.value,\n })),\n active: cdrData.active,\n gender: cdrData.gender,\n birthDate: cdrData.birthDate,\n address: cdrData.address,\n managingOrganization: cdrData.managingOrganization,\n deceasedBoolean: cdrData.deceasedBoolean,\n text: cdrData.text\n };\n// returned the mapped patient object\n return {...state, patient}\n})", + "body": "fn(state=> {\n //Map CDR data to NDR FHIR IG\n const cdrData = state.resource;\n const mapped_resource = {\n resourceType: cdrData.resourceType,\n id: cdrData.id,\n identifier: cdrData.identifier?.map(id => ({\n type: id.system == \"http://cdr.aacahb.gov.et/MRN\"? {\n \"coding\": [\n {\n \"code\": \"MR\",\n \"display\": \"Medical record number\",\n \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0203\"\n }\n ],\n \"text\": \"Medical record number\"\n } : undefined,\n system: id.system,\n value: id.value,\n })),\n active: cdrData.active,\n gender: cdrData.gender,\n birthDate: cdrData.birthDate,\n address: cdrData.address,\n managingOrganization: cdrData.managingOrganization,\n deceasedBoolean: cdrData.deceasedBoolean,\n text: cdrData.text\n };\n// returned the mapped fhir resource\n return {...state, mapped_resource}\n})", "adaptor": "@openfn/language-common@latest" }, "Remove-PIIs": { "id": "a190cc21-e997-439d-a5ea-64895921eadb", "name": "Remove PIIs", - "body": "fn(state=> {\n //Removig PII here before sending it to NDR\n delete state.data.name;\n delete state.data.telecom;\n delete state.data.contact;\n delete state.data.extension; //contains religion, occupation, education level, target pop group\n delete state.data.maritalStatus; \n\n //only keeping birthdate and gender\n\n return state;\n})", + "body": "fn(state=> {\n //Removig PII here before sending it to NDR\n delete state.resource.name;\n delete state.resource.telecom;\n delete state.resource.contact;\n delete state.resource.extension; //contains religion, occupation, education level, target pop group\n delete state.resource.maritalStatus; \n\n //only keeping birthdate and gender\n\n return state;\n})", "adaptor": "@openfn/language-common@latest" } },