Skip to main content

Create Person in SF

This job was provided by an OpenFn.org user via the job library API.

Metadata

Key Functions

dataValue, field, fields, humanProper, relationship, upsert

Expression

upsert("Patient__c", "CommCare_Case_ID__c", fields(
field('CommCare_Case_ID__c', dataValue("form.case.@case_id")),
relationship('Clinic__r', 'Location_ID__c', dataValue('form.case.create.owner_id')),
field('First_Name__c', humanProper(state.data.form.case.update.patient_first_name)),
field('Last_Name__c', humanProper(state.data.form.case.update.patient_last_name)),
field('Patient_ID__c', dataValue('form.case.update.patient_id')),
field('Age_Months_Started_Treatment__c', dataValue('form.case.update.age_months_start_treatment_rounded')),
field('Registration_Date__c', (state) => {
const validDate = state.data.form.case.update.registration_date
return ( validDate ? new Date(validDate).toISOString() : null )
})
))