Skip to content

Commit 68e7d27

Browse files
authored
Merge branch 'main' into docs-updates
2 parents 2123c34 + a8894bb commit 68e7d27

3 files changed

Lines changed: 189 additions & 215 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Find both data flow diagrams [here](https://docs.google.com/presentation/d/1S_Bu
110110
### Workflow 1.1 – Send Referrals to Primero
111111

112112
[OpenFn Workflow Link](https://app.openfn.org/projects/1813e824-91aa-4a3b-a49c-afa8b33af333/w/5d2383d8-5f58-451e-aec9-5709e403eea7)
113+
<img width="1314" height="849" alt="image" src="https://github.com/user-attachments/assets/3add88f5-299d-4df2-b187-29e899b34d11" />
113114

114115
<img width="1314" height="849" alt="Workflow 1.1 canvas" src="https://github.com/user-attachments/assets/3add88f5-299d-4df2-b187-29e899b34d11" />
115116

@@ -151,6 +152,7 @@ Scheduled workflow execution.
151152
### Workflow 1.2 – Send Decision to PING
152153

153154
[OpenFn Workflow Link](https://app.openfn.org/projects/1813e824-91aa-4a3b-a49c-afa8b33af333/w/32d49f20-82a0-464f-b05e-fbabd22ce202)
155+
<img width="1314" height="849" alt="image" src="https://github.com/user-attachments/assets/63f8a716-7ba2-4f55-b903-733b34f9ccb7" />
154156

155157
<img width="1314" height="849" alt="Workflow 1.2 canvas" src="https://github.com/user-attachments/assets/63f8a716-7ba2-4f55-b903-733b34f9ccb7" />
156158

@@ -190,6 +192,7 @@ Scheduled workflow execution.
190192
### Workflow 2.1 – Get Referrals from Primero
191193

192194
[OpenFn Workflow Link](https://app.openfn.org/projects/1813e824-91aa-4a3b-a49c-afa8b33af333/w/360b3fea-569a-401b-b7d4-3a68ad6f575a)
195+
<img width="1314" height="849" alt="image" src="https://github.com/user-attachments/assets/5f3b5fde-5550-4527-9b92-173bd7dd7480" />
193196

194197
<img width="1314" height="849" alt="Workflow 2.1 canvas" src="https://github.com/user-attachments/assets/5f3b5fde-5550-4527-9b92-173bd7dd7480" />
195198

@@ -230,6 +233,7 @@ Scheduled workflow execution.
230233
### Workflow 2.2 – Update Referral Decision in Primero
231234

232235
[OpenFn Workflow Link](https://app.openfn.org/projects/1813e824-91aa-4a3b-a49c-afa8b33af333/w/6a3a0cce-79bb-4a25-8fb2-40a9ff505818)
236+
<img width="1314" height="849" alt="image" src="https://github.com/user-attachments/assets/73b8e34f-32ec-47ea-92e9-9c8eb19001d9" />
233237

234238
<img width="1314" height="849" alt="Workflow 2.2 canvas" src="https://github.com/user-attachments/assets/73b8e34f-32ec-47ea-92e9-9c8eb19001d9" />
235239

openfn-1813e824-91aa-4a3b-a49c-afa8b33af333-spec.yaml

Lines changed: 38 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ credentials:
1313
hunter@openfn.org-Primero-PING:
1414
name: Primero PING
1515
owner: hunter@openfn.org
16+
rediet@openfn.org-Invalid-Credential-PING:
17+
name: Invalid Credential PING
18+
owner: rediet@openfn.org
1619
rediet@openfn.org-Ping-Credential-Rediet:
1720
name: Ping Credential Rediet
1821
owner: rediet@openfn.org
@@ -39,10 +42,6 @@ workflows:
3942
"InteropID": "INT-1436",
4043
"APIVersion": "V3",
4144
"QueryParameters": [
42-
// {
43-
// "ParameterName": "{progres_interoperabilityreferralstatus}",
44-
// "Value": "[125080001, 125080002]"
45-
// }
4645
]
4746
});
4847
@@ -73,10 +72,10 @@ workflows:
7372
adaptor: '@openfn/language-ping@1.0.1'
7473
credential: hunter@openfn.org-Official-Ping-credentials
7574
body: |
76-
fn(state =>{
75+
fn(state => {
7776
7877
state.decisionRecords = [];
79-
return state
78+
return state
8079
})
8180
8281
each('$.referralIds[*]', http.post('/primes/fetch/paging/v3/retrievedatawithpaging', {
@@ -86,19 +85,19 @@ workflows:
8685
"APIVersion": "V3",
8786
"QueryParameters": [
8887
{
89-
"ParameterName": "{record_ids}",
90-
"Value": `${[$.data]}`
88+
"ParameterName": "{record_ids}",
89+
"Value": `${[$.data]}`
9190
}
9291
]
93-
}).then(state =>{
92+
}).then(state => {
9493
9594
state.decisionRecords.push(state.data.Data[0])
9695
return state
9796
}))
9897
99-
fn(state =>{
98+
fn(state => {
10099
101-
return {decisionRecords:state.decisionRecords, data:{}, references:[]}
100+
return { decisionRecords: state.decisionRecords, data: {}, references: [] }
102101
})
103102
104103
Map-decision-to-Primero-payload:
@@ -120,17 +119,14 @@ workflows:
120119
return "rejected"
121120
default:
122121
return "accepted"
123-
124122
}
125123
}
126124
127125
each('$.decisionRecords[*]', fn(state => {
128126
const r = state.data;
129-
// values differ if status is ...002, decision is ...001, and if status is ...001, decision is ...000
130127
const status = r.progres_interoperabilityreferralstatus || r.progres_reviewdecision;
131128
const case_id = r.progres_offlineid;
132129
const service_id = r.progres_orgreferralid;
133-
const service_type = r.progres_requestedservice; // proGres service GUID — used to match referral in Primero
134130
const interoperability_referral_id = r.progres_interoperabilityreferralid; // proGres UUID — used to update status in PING after Primero sync
135131
136132
const payload = {
@@ -141,7 +137,7 @@ workflows:
141137
"record_type": "case",
142138
"status": statusText(status),
143139
"rejected_reason": statusText(status) === "rejected"
144-
? (r.progres_interoperabiltyreferralrejectionreasonname || "Rejected in proGres (no reason provided)")
140+
? `${r.progres_interoperabiltyreferralrejectionreasonname || "Rejected in proGres (no reason provided)"} — ${r.progres_interoperabilityreferralrejectionomment || "No comment provided"}`
145141
: null
146142
}
147143
@@ -213,9 +209,9 @@ workflows:
213209
214210
return updateReferral(
215211
{
216-
caseExternalId: 'case_id', // was: externalId
217-
caseId: case_id, // was: id (and was being set to the case_id)
218-
id: referral.id, // was: referral_id
212+
caseExternalId: 'case_id',
213+
caseId: case_id,
214+
id: referral.id,
219215
data: decision,
220216
},
221217
state => {
@@ -230,7 +226,6 @@ workflows:
230226
return state;
231227
});
232228
}));
233-
234229
Save-Status-in-Progres:
235230
name: Save Status in Progres
236231
adaptor: '@openfn/language-ping@1.0.2'
@@ -265,22 +260,32 @@ workflows:
265260
return state;
266261
});
267262
268-
http.post('/api/ingestion/v2/PNR-1363/data', state => ({
269-
"ShippingProcessId": "SHP-2284",
270-
"InteropId": "INT-1436",
271-
"Data": state.pingStatusPayloads
272-
})).then(state => {
273-
console.log(`Status updated to Synced with PRIMERO for ${state.pingStatusPayloads.length} referral(s)`);
274-
return state;
275-
}).catch(error => {
276-
console.log(`Failed to update PING status. Error: ${error.message}`);
277-
throw error;
263+
fn(state => {
264+
if (state.pingStatusPayloads.length === 0) {
265+
console.log('No referrals to mark as synced in PING. Skipping.');
266+
return state;
267+
}
268+
269+
return http.post('/api/ingestion/v2/PNR-1363/data', state => ({
270+
"ShippingProcessId": "SHP-2284",
271+
"InteropId": "INT-1436",
272+
"Data": state.pingStatusPayloads
273+
}))(state)
274+
.then(state => {
275+
console.log(`Status updated to Synced with PRIMERO for ${state.pingStatusPayloads.length} referral(s)`);
276+
return state;
277+
})
278+
.catch(error => {
279+
console.log(`Failed to update PING status. Error: ${error.message}`);
280+
throw error;
281+
});
278282
});
279283
280284
triggers:
281285
cron:
282286
type: cron
283287
cron_expression: '0 0 * * *'
288+
cron_cursor_job: Fetch-decision-records-from-proGres-via-PING
284289
enabled: false
285290
edges:
286291
cron->Fetch-decision-records-from-proGres-via-PING:
@@ -344,8 +349,6 @@ workflows:
344349
credential: hunter@openfn.org-Official-Ping-credentials
345350
body: |
346351
fn(state => {
347-
348-
349352
state.data = state.interventions.map(item => {
350353
351354
return {
@@ -378,12 +381,6 @@ workflows:
378381
}
379382
})
380383
381-
// console.log({ data: state.data })
382-
383-
// console.log(
384-
// `Sending success message to Ping for case_id ${data.case_id} and progres_interventionnumber ${data.progres_interventionnumber}`
385-
// );
386-
387384
return state;
388385
});
389386
@@ -650,35 +647,12 @@ workflows:
650647
)(state);
651648
})
652649
);
650+
653651
Retrieve-full-intervention-details:
654652
name: Retrieve full intervention details
655653
adaptor: '@openfn/language-ping@latest'
656654
credential: hunter@openfn.org-Official-Ping-credentials
657655
body: |
658-
// fn(state => {
659-
// const { Data } = state.data;
660-
// state.referrals = Data;
661-
// state.interventions = [];
662-
// return state
663-
// })
664-
// each('$.referrals[*]', http.post('/primes/fetch/paging/v3/retrievedatawithpaging', {
665-
// "ShippingProcessId": "SHP-2358", // Retrieve referral records from proGres deliveries table, interventions, individuals
666-
// "PartnerId": "PNR-1363",
667-
// "InteropID": "INT-1436",
668-
// "APIVersion": "V3",
669-
// "QueryParameters": [
670-
// {
671-
// "ParameterName": "{record_ids}",
672-
// "Value": state => state.data.progres_lpinterventionid //interventionNumber
673-
// }
674-
// ]
675-
// }).then(state => {
676-
677-
// const data = state.data.Data.map(item => ({ ...item, progres_lpinterventionid: state.referrals[state.index].progres_lpinterventionid }));
678-
679-
// state.interventions.push(...data)
680-
// return state
681-
// }));
682656
fn(state => {
683657
const { Data } = state.data;
684658
state.referrals = Data;
@@ -760,6 +734,7 @@ workflows:
760734
cron:
761735
type: cron
762736
cron_expression: '00 00 * * *'
737+
cron_cursor_job: Retrieve-pending-referrals
763738
enabled: false
764739
edges:
765740
Send-Referrals-to-Primero->Send-Upload-Status-to-Ping:
@@ -884,20 +859,6 @@ workflows:
884859
return state;
885860
});
886861
887-
// fn(state => {
888-
// let lastRunDateTime = state.referralsToSend
889-
// .map(c => c.last_updated_at)
890-
// .sort((a, b) => new Date(b.date) - new Date(a.date))[0];
891-
892-
// lastRunDateTime =
893-
// new Date(lastRunDateTime) > new Date()
894-
// ? lastRunDateTime
895-
// : new Date().toISOString();
896-
897-
// console.log('New cursor value:', lastRunDateTime);
898-
// return { ...state, data: {}, references: [], lastRunDateTime };
899-
// });
900-
901862
Get-Decisions-from-Primero:
902863
name: Get Decisions from Primero
903864
adaptor: '@openfn/language-primero@3.0.9'
@@ -989,6 +950,7 @@ workflows:
989950
cron:
990951
type: cron
991952
cron_expression: '0 * * * *'
953+
cron_cursor_job: Get-Decisions-from-Primero
992954
enabled: false
993955
edges:
994956
cron->Get-Decisions-from-Primero:
@@ -1041,8 +1003,6 @@ workflows:
10411003
}
10421004
})
10431005
1044-
1045-
10461006
// Get referral details for each UNCHR case which have been created since the last run
10471007
each(
10481008
'$.cases[*]',
@@ -1569,6 +1529,7 @@ workflows:
15691529
cron:
15701530
type: cron
15711531
cron_expression: '0 * * * *'
1532+
cron_cursor_job: Get-Referrals-from-Primero
15721533
enabled: false
15731534
edges:
15741535
cron->Get-Referrals-from-Primero:

0 commit comments

Comments
 (0)