rahul1
05/14/2024, 1:29 PMrahul1
05/14/2024, 1:29 PM{
resourceType: 'Bundle',
type: 'transaction',
entry: [
// Create the patient if it doesn't exist
{
request: {
method: 'POST',
url: 'Patient',
ifNoneExist: 'identifier=http://example-hospital.org/mrns|234543',
},
fullUrl: 'urn:uuid:ffcda8f9-e517-412f-afde-5488cd176f68',
resource: {
resourceType: 'Patient',
identifier: [
{
system: 'http://example-hospital.org/mrns',
value: '234543',
},
],
name: [
{
family: 'Simpson',
given: ['Homer', 'Jay'],
},
],
gender: 'male',
birthDate: '1956-05-12',
},
},
// Update the patient in-place
{
request: {
method: 'PUT',
url: 'urn:uuid:ffcda8f9-e517-412f-afde-5488cd176f68',
},
resource: {
resourceType: 'Patient',
id: 'urn:uuid:ffcda8f9-e517-412f-afde-5488cd176f68',
identifier: [
{
system: 'http://example-hospital.org/mrns',
value: '234543',
},
],
name: [
{
family: 'Simpson',
given: ['Homer', 'Jay'],
},
],
gender: 'male',
birthDate: '1956-05-12',
},
},
],
};rahul1
05/14/2024, 1:29 PM{
resourceType: 'Bundle',
type: 'batch',
entry: [
// Create the patient if it doesn't exist
{
request: {
method: 'PUT',
// *NOTE THIS URL*
url: 'Patient?identifier=http://example-hospital.org/mrns|234543',
},
fullUrl: 'urn:uuid:ffcda8f9-e517-412f-afde-5488cd176f68',
resource: {
resourceType: 'Patient',
identifier: [
{
system: 'http://example-hospital.org/mrns',
value: '234543',
},
],
name: [
{
family: 'Simpson',
given: ['Homer', 'Jay'],
},
],
gender: 'male',
birthDate: '1956-05-12',
},
},
],
};
OR:
// An "upsert" (i.e. update/insert) will either update the resource in place if it
// already exists, otherwise is will be created. This is performed in a single,
// transactional request to guarantee data consistency.
const updatedPatient = medplum.upsertResource(patient, 'identifier=http://example-hospital.org/mrns|234543');