OpenFn/lwala

Supervisor Visit mapping logic

Closed this issue · 3 comments

Overview

We need to clean & re-format picklist values provided by CommCare before uploading to Salesforce. This logic needs to be applied in 2 jobs wherever the Salesforce field Supervisor_Visit__c is referenced.

field("Supervisor_Visit__c", function (state) {
return dataValue("$.form.supervisor_visit")(state)
.toString()
.replace(/ /g, ";");
}),

https://github.com/OpenFn/lwala/blob/master/commcare-salesforce-jobs/MOH513-Update-Household-in-SF-Production.js#L46-L63

Request

Update Update-Person-in-SF-Production.js and MOH513-Update-Household-in-SF-Production.js to include the following mappings for wherever Supervisor_Visit__c is referenced:

// commcare_input: salesforce_output
// "supervisor_visit": "Supervisor_Visit__c"
'community_health_nurse': 'Community Health Nurse'
'chw_supervisor': 'CHW Supervisor'
'chewschas': 'CHEWs/CHAs'
'other': 'Other'
'none': 'None'

Example

The below sample state from CommCare should output the value 'CHEWs/CHAs' in Salesforce.

    "supervisor_visit": "chewschas"

Resources

state.json

Test with Lwala Salesforce sandbox. See LP for creds.

  1. Update-Person-in-SF-Production.js test: Use sample_data/state_anc4.json to test scenario where Supervisor_Visit__c = 'None'. Update the value "supervisor_visit": ______ to test the different combinations.
  2. MOH513-Update-Household-in-SF-Production.js test: Use sample_data/state_HHsupervisor.json

adaptor

Use language-salesforce and make use of this LP's FakeAdaptor for offline testing.

expression.js

Update Update-Person-in-SF-Production.js
Update MOH513-Update-Household-in-SF-Production.js

Toggl

Log your time to Lwala Cleanup 2020

@lakhassane Can you please add logic to handle for instances where supervisor_visit is null or undefined? If so, it should return a null value.

@aleksa-krolls added the logic and made a test.
First screen shows an undefined supervisor_visit and second one shows the ouput where it is set to null
image

image

Closing this as it is solved.