Use Composite API Requests to Import Data for Provider Relationship Cards
Usage
You can create records individually by using the Lightning Platform SOAP API or REST API. Or you can use the Composite resource in REST API to create and link multiple records with a single API call. This approach lets you create 200 records per call.
Example
Let’s say we want to add healthcare provider Dr. Scott Kaplan to your records. This example shows how to use a single API call to create Account, Contact, HealthcareProvider, PersonEducation, HealthcareProviderNpi, HealthcarePractitionerFacility, HealthcareProviderSpeciality, HealthcareFacilityNetwork, and HealthcareProviderTaxonomy records with Dr. Scott Kaplan's data. It also shows how to use a composite request to link records using Dr. Kaplan’s contactId as the practitionerId.
In this example, we assume that there are two Specialty records with SpecialtyCode Neurology and Cardiology, a PayerNetwork record with code United Healthcare, and a Taxonomy record with TaxonomyCode Critical Care. Setting allOrNone to True rolls back your request if a single record creation fails.
1curl https://yourInstance.salesforce.com/services/data/v47.0/composite/ -H "Authorization: Bearer token” -H "Content-Type: application/json" -d "@composite.json"Example request body of the composite.json file.
1{
2"allOrNone" : true,
3"compositeRequest" : [
4 {
5 "method" : "POST",
6 "url" : "/services/data/v47.0/sobjects/Account",
7 "referenceId" : "scottKaplanAccount",
8 "body" : { "Name" : "Dr. Scott Kaplan" }
9 },
10 {
11 "method" : "POST",
12 "url" : "/services/data/v47.0/sobjects/Contact",
13 "referenceId" : "scottKaplanContact",
14 "body" : {
15 "FirstName" : "Scott",
16 "LastName" : "Kaplan",
17 "AccountId" : "@{scottKaplanAccount.id}"
18 }
19 },
20 {
21 "method" : "POST",
22 "url" : "/services/data/v47.0/sobjects/HealthcareProvider",
23 "referenceId" : "scottKaplanProvider",
24 "body" : { "Name" : "Dr. Scott Kaplan",
25 "PractitionerId" : "@{scottKaplanContact.id}"
26 }
27 },
28 {
29 "method" : "POST",
30 "url" : "/services/data/v47.0/sobjects/PersonEducation",
31 "referenceId" : "scottKaplanPersonEducation",
32 "body" : {
33 "Name": "Dr. Scott Kaplan",
34 "ContactId" : "@{scottKaplanContact.id}"
35 }
36 },
37 {
38 "method" : "POST",
39 "url" : "/services/data/v47.0/sobjects/HealthcareProviderNpi",
40 "referenceId" : "scottKaplanNpi",
41 "body" : {
42 "Name": "Dr. Scott Kaplan",
43 "Npi" : "1558444601",
44 "PractitionerId" : "@{scottKaplanContact.id}",
45 "NpiType" : "Individual"
46 }
47 },
48 {
49 "method" : "POST",
50 "url" : "/services/data/v47.0/sobjects/HealthcarePractitionerFacility",
51 "referenceId" : "scottKaplanPractitionerFacility",
52 "body" : {
53 "Name": "Palo Alto Medical Foundation",
54 "PractitionerId" : "@{scottKaplanContact.id}"
55 }
56 },
57 {
58 "method" : "POST",
59 "url" : "/services/data/v47.0/sobjects/HealthcareProviderSpecialty",
60 "referenceId" : "hcProviderSpecialtyRef1",
61 "body" : {
62 "Name": "Cardiology",
63 "Specialty" : {
64 "SpecialtyCode" : "Cardiology"
65 },
66 "PractitionerId" : "@{scottKaplanContact.id}"
67 }
68 },
69 {
70 "method" : "POST",
71 "url" : "/services/data/v47.0/sobjects/HealthcareProviderSpecialty",
72 "referenceId" : "scottKaplanSpeciality2",
73 "body" : {
74 "Name": "Neurology",
75 "Specialty" : {
76 "SpecialtyCode" : "Neurology"
77 },
78 "PractitionerId" : "@{scottKaplanContact.id}"
79 }
80 },
81 {
82 "method" : "POST",
83 "url" : "/services/data/v47.0/sobjects/HealthcareFacilityNetwork",
84 "referenceId" : "scottKaplanFacilityNetwork",
85 "body" : {
86 "Name": "United Healthcare",
87 "PayerNetwork" : {
88 "Code" : "United Healthcare"
89 },
90 "PractitionerId" : "@{scottKaplanContact.id}"
91 }
92 },
93 {
94 "method" : "POST",
95 "url" : "/services/data/v47.0/sobjects/HealthcareProviderTaxonomy",
96 "referenceId" : "scottKaplanTaxonomy",
97 "body" : {
98 "Name": "Critical care",
99 "Taxonomy" : {
100 "TaxonomyCode" : "Critical Care"
101 },
102 "PractitionerId" : "@{scottKaplanContact.id}"
103 }
104 }
105
106 ]
107}Here’s a sample response:
1{
2 "compositeResponse": [{
3 "body": {
4 "id": "001RM000004MkdJYAS",
5 "success": true,
6 "errors": []
7 },
8 "httpHeaders": {
9 "Location": "/services/data/v47.0/sobjects/Account/001RM000004MkdJYAS"
10 },
11 "httpStatusCode": 201,
12 "referenceId": "scottKaplanAccount"
13 }, {
14 "body": {
15 "id": "003RM000006Ev2AYAS",
16 "success": true,
17 "errors": []
18 },
19 "httpHeaders": {
20 "Location": "/services/data/v47.0/sobjects/Contact/003RM000006Ev2AYAS"
21 },
22 "httpStatusCode": 201,
23 "referenceId": "scottKaplanContact"
24 }, {
25 "body": {
26 "id": "0bYRM0000004CAG2A2",
27 "success": true,
28 "errors": []
29 },
30 "httpHeaders": {
31 "Location": "/services/data/v47.0/sobjects/HealthcareFacilityNetwork/0bYRM0000004CAG2A2"
32 },
33 "httpStatusCode": 201,
34 "referenceId": "scottKaplanFacilityNetwork"
35 }, {
36 "body": {
37 "id": "0bPRM0000004CAB2A2",
38 "success": true,
39 "errors": []
40 },
41 "httpHeaders": {
42 "Location": "/services/data/v47.0/sobjects/HealthcareProviderTaxonomy/0bPRM0000004CAB2A2"
43 },
44 "httpStatusCode": 201,
45 "referenceId": "scottKaplanTaxonomy"
46 }]
47}In this example, Account ID 001RM000004MkdJYAS and Contact ID 0bYRM0000004CAG2A2 were created on execution. The same Contact ID is used as the PractitionerId where applicable.