Newer Version Available
Create Patient
Use this single Apex API to create a patient record rather than making separate calls
to the Account and Contact objects. The Person Account object and the Individual record type
(for Account and Contact objects) are both supported.
A single API call creates a patient record and populates all fields. If you’ve defined custom fields, it manages those as well.
If something goes wrong while inserting data, the API rolls back to prevent leaving orphan records behind.
Usage
Instantiate a patient using the relevant record type:
1HealthCloudGA.Patient patient = new HealthCloudGA.Patient();
2 patient.PatientClass = 'Individual'; // record type
3 // OR
4 // patient.PatientClass = 'PersonAccount';Set standard fields:
1patient.FirstName = 'Charles';
2 patient.LastName = 'Green';
3 //... similarly set additional standard fields for Individual record typeSet custom fields:
1patient.customFields.put('customField','value');
2 patient.customFields.put('DateTypeCustomField__c',Date.newInstance(2017,11,15));Usage of PatientService:
1public class HCBusinessAPIExample {
2 public static void genSamplePatient(){
3
4 HealthCloudGA.Patient patient = new HealthCloudGA.Patient();
5 patient.PatientClass = 'Individual';
6 patient.FirstName = 'Charles';
7 patient.LastName = 'Green';
8 //... set additional standard fields and custom fields
9
10 HealthCloudGA.Result res = HealthCloudGA.PatientService.createPatient(patient);
11
12 System.debug(res);
13
14 }
15}