Closed mtuchi closed 3 weeks ago
EOD Update I have made lots of improvements based on joe's feedback, See #36 I will test the whole workflow one more time tomorrow
@aleksa-krolls i have worked on joe's feedback the PR is ready for review #36, I just want to point out that the create-events
step does not use the new tracker api yet because it requires updating the mapping. See sample payload from DHIS docs here
Assuming we have worked on the mappings, this is how we will create events 👇🏽
create(
'tracker',
{ events: $.encountersMapping },
{
params: {
async: false, //It's important for getting import summary when the import is done,
importStrategy: 'CREATE_AND_UPDATE', // For upsert like behavior
dataElementIdScheme: 'UID',
},
}
);
hey @mtuchi can we close this?
2-upsert-teis
3-get-encounters
6-create-events
I like the structure with all the little functions. It;s good, breaks down the problem
The switch statement in
processObjectAnswer
looks completely wrong to me? Also ingetRangePhq
. Just use if/else.Don't be afraid of using if/else, the Functional Programming Cops aren't gonna come and track you down.
Here's a better pattern for
getRangePhq
The ternary on line 69 should be
const value = answer ? processAnswer(answer, conceptUuid, dataElement, optsMap)) : ''
. Don't use a ternary expression like a statement.The easiest way to cast a boolean to string is probably
'' + answerValue.uuid === '278401ee-3d6f-4c65-9455-f1c16d0a7a98'
Don't parse
optsMap
here in create-events - do it when you fetch it from the gist in the earlier job. That keeps your setup in one place and your logic in another.