-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-clinics.js
42 lines (36 loc) · 962 Bytes
/
add-clinics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
alterState(state => {
function clean(obj) {
for (var propName in obj) {
if (obj[propName] === '-' || obj[propName] === null) {
delete obj[propName];
}
}
return obj;
}
state.data = {
clinics: state.data.clinics.map(c => {
//delete; we cannot update these in SF unless setting enabled
delete c.CreatedById; // map to Open Date CommCare fields
delete c.LastModifiedById;
c.Clinic_External_ID__c = c.Name;
c.India_Clinic_Code__c = c.CAST_Location_ID__c;
delete c.CAST_Location_ID__c
c.Last_Updated_by_India_CAST_App__c = new Date().toISOString();
c.Country__c = 'India';
return clean(c);
}),
};
return state;
});
//upsert Clinics
bulk(
'Account',
'upsert',
{
extIdField: 'Clinic_External_ID__c',
//extIdField: 'CAST_Location_ID__c', //Clinic External Id
failOnError: true,
allowNoOp: true,
},
dataValue('clinics')
);