Tuesday, April 8, 2014

HL7 FHIR Partial Update

Below I summarized what I have tried so far for handling partial update in HL7 FHIR.

1) Syntax

URL: http://[server]/[resource]/[logical id]/_delta
method: POST

I did not use PATCH method since some of older browser does not support this method, also not sure whether PATCH method has been supported in all javascript library

2) Extension element to specify update mode

For each element to be added/replaced/deleted, added the following extension

       <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
            <valueCode value="A or R or D" />
        </extension>

As an example, below is the XML snippet for updating birthDate

 <birthDate value="1970-03-13">
      <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
            <valueCode value="R" />
        </extension
>

  </birthDate>


3) Handling collection

For collection data elements such as name, address and contact in Patient resource, server needs to know which element within the collection is to be replaced/deleted. So I decided to pull collection element's internal id as part of the query response, and then use the same id when submitting the payload to server

- Added collection element internal id in query response as part of element extension

    <telecom>
        <extension url="http://hl7.org/fhir/metadata#id">
            <valueString value="1308"/>
        </extension>

        <system value="phone"/>
        <value value="68181256"/>
        <use value="home"/>
    </telecom>

- Payload for partial update
      <telecom>
            <extension url="http://hl7.org/fhir/metadata#id">
                <valueString value="1308"/>
            </extension>

            <extension url="http://hl7.org/fhir/Profile/iso-21090#updateMode" >
                <valueCode value="R" />
             </extension>

           <system value="phone"/>
           <value value="68181256"/>
           <use value="office"/>
    </telecom>


4) Suggestion

The above approach works okay so far, however I'd like to make one suggestion here. As we can see from the above XML snippet, the content is very verbose after adding extension elements.Can we add the two attributes (id and updateMode) in FHIR resource as part of Element built-in attributes? In this way, the content will be very compact as the following snippet shows,

     <telecom  id="1308" updateMode="R">             
           <system value="phone"/>
           <value value="68181256"/>
           <use value="office"/>
    </telecom>