Skip to content

Commit

Permalink
user [email protected] initiated a sync from Lightning
Browse files Browse the repository at this point in the history
  • Loading branch information
openfn[bot] authored and github-actions[bot] committed Jun 13, 2024
1 parent 08e6bcb commit d87372b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
41 changes: 18 additions & 23 deletions openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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": [
{
Expand All @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions openfn-d52bd48e-451b-4a92-9aad-e7c62a7f0923-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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"
}
},
Expand Down

0 comments on commit d87372b

Please sign in to comment.