OpenFn / openfn-lime-pilot

MSF LIME Project - OpenFn Workflows for Iraq Pilot
1 stars 0 forks source link

Joe's feedback #35

Closed mtuchi closed 3 weeks ago

mtuchi commented 2 months ago

2-upsert-teis

3-get-encounters

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 in getRangePhq. 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

const getRangePhq = input => {
  if (input >= 20) return '>20';
  if (input >= 15) return '15_19';
  if (input >= 10) return '10_14';
  if (input >= 5) return '5_9';
  return '0_4'

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.

mtuchi commented 2 months 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

mtuchi commented 2 months ago

@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',
    },
  }
);
aleksa-krolls commented 3 weeks ago

hey @mtuchi can we close this?