Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

SMART on FHIR JavaScript Client

*Note, this example is not following the SMART on FHIR launch specification.  In your code, you will not connect to an EHR this way, but will be given the serviceUrl and patient values from the launch request.  See Quick Start for details.

 

...

Query A Patient Resource and Update Last Name

Code Block
languagejs
titleUpdate a Resource
<script type="text/javascript">
...
var patient;

// Read patient
function readPatient() {
  smart.patient.read().then(function(pt) {
    patient = pt;
  });
}

function updatePatient() {
  patient.name[0].family[0] = "NewName";
  smart.api.update({type: patient.resourceType, data: JSON.stringify(patient), id: patient.id}).then(function(){
        readPatient()
  });
...
</script>