...
In this snippet, we have a readPatient function which retrieves the Patient FHIR Resource and stores the result in a var named patient. The updatePatient function updates the patient's family name. (A Patient FHIR Resource can have multiple names and multiple family names within each name. We are simply updating the first family name for the first name ex. patient.name[0].family[0]) The updatePatient function then uses the fhirClient to update the FHIR Resource, passing the resource type, stringified Patient Resource and the Patient Resource IdID.
Code Block | ||||
---|---|---|---|---|
| ||||
<script type="text/javascript"> ... var patient; // Read patient function readPatient() { fhirClient.patient.read().then(function(pt) { patient = pt; }); } function updatePatient() { patient.name[0].family[0] = "NewName"; fhirClient.api.update({type: patient.resourceType, data: JSON.stringify(patient), id: patient.id}).then(function(){ readPatient() }); ... </script> |