201605 Conditional Reference Connectathon Proposal
Conditional Reference
Submitting WG/Project/Implementer Group
Justification
In many scenarios, FHIR resources can be uniquely (re-)identified by their common business identifier (e.G.). Since FHIR resources however can only be referenced by their server assigned resource id, referencing to resources that are known by the client only by their business identifier requires an additional step to retreive the resource matching that business identifier, extracting the resource ID and then create a reference accordingly.
In the context of Transactions, it is required to include bogus Resources with conditional create requests in order to be able to create references. This may cause undesired side effects because the client is forced to use create verb on resources it actually means to read. Transactions may fail due to lack of client write permissions even though the client does not actually want to write anything.
Example: The Client wants to create an Observation linked to the Patient with business identifier 12345. The Client does not have write permissions on Patient resources. The Transaction Bundle would need to include the Patient resource with a uuid and a create condition in order to invoke the server's responsibility to
- search for a patient that matches the condition
- replace the uuid and all references to it in the transaction bundle with the actual id
<Bundle xmlns="http://hl7.org/fhir"> <id value="20160113160203" /> <type value="transaction" /> <entry> <fullUrl value="urn:uuid:653a9d22-b6c1-44cd-55a0-3ce35d574642" /> <resource> <Patient> <identifier> <value value="12345" /> </identifier> </Patient> </resource> <request> <method value="CREATE" /> <if-none-exixts="Patient?identifier=12345" /> </request> </entry> <entry> <fullUrl value="urn:uuid:c72aa430-2ddc-456e-7a09-dea8264671d8" /> <resource> <Observation> <subject> <reference value="urn:uuid:653a9d22-b6c1-44cd-55a0-3ce35d574642"/> </subject> <--! rest of resource omitted --> </Observation> </resource> <request> <method value="CREATE" /> </request> </entry> </Bundle>
The transcaction would fail if
- no patient matches the create condition and the subsequent create action runs into an error due to insufficient client permissions
- multiple patients match the create condition
The proposal has been made to allow conditional references with the same syntax as conditional updates.
As a more intuitive approach, this Connectathon Track suggests to allow the conditional url otherwise placed in the if-none-exists attribute directly in the patient reference:
<source lang="xml">
<Bundle xmlns="http://hl7.org/fhir"> <id value="20160113160203" /> <type value="transaction" /> <entry> <fullUrl value="urn:uuid:c72aa430-2ddc-456e-7a09-dea8264671d8" /> <resource> <Observation> <subject> <reference value="Patient?identifier=12345"/> </subject> <--! rest of resource omitted --> </Observation> </resource> <request> <method value="CREATE" /> </request> </entry> <Bundle>
</source>
Other possible use cases are
- Referencing an Insurance Organization by the National Insurance Identifier
- Referencing a Location by it's name
- V2 mapping scenarios
Proposed Track Lead
Simone Heckmann
- Email: simone dot heckmann at health-comm dot de
See Connectathon_Track_Lead_Responsibilities
Expected participants
- Simone Heckmann (Health-Comm): Client implementation (V2 Mapping Scenarios)
Roles
Client
The Client sumbits Bundles to the server including conditional references as proposed above.
Server
The Server receives the Bundles and processes them as described above
The server is expected to
- replace the conditional reference by the actual id of the one resource that matches the criteria
- return an HTTP 500 if no resource matches the criteria
- return an HTTP 500 if multiple resources matches the criteria
Scenarios
The mechanisms described above can be used in any scenario that leverages FHIR Transactions, e.g. any of the FHIR-V2-Mapping Scenarios
Scenario Step 1 Conditional URL matches one resource
- Action: Client submits Transaction Bundle with at least one Resource containing a conditional reference that matches exactly one Resource on the Server
- Precondition: Client has to make sure it references an existing Resource uniquely identified by the query criteria
- Success Criteria: Server returns HTTP 200 with transaction resonse bundle. Visual inspection of the resource on the server to confirm that the reference has been updated properly
- Bonus point: Client automatically checks the correct resolution of the reference by sending a query that confirms the success (Example for the Bundle above: Observation?subject.identifier=12345 should return the subitted Observation
Scenario Step 2 Conditional URL matches multiple resources
- Action: Client submits Transaction Bundle with at least one Resource containing a conditional reference that matches multiple Resources on the Server
- Precondition: Client has to make sure it uses query criteria that returns more than one match
- Success Criteria: Server returns HTTP 500, no update is performed
- Bonus point: Server returns Operation Outcome with verbose information about the issue
Scenario Step 3 Conditional URL matches no resource
- Action: Client submits Transaction Bundle with at least one Resource containing a conditional reference that matches no Resources on the Server
- Precondition: Client has to make sure it uses query criteria that returns no match
- Success Criteria: Server returns HTTP 500, no update is performed
- Bonus point: Server returns Operation Outcome with verbose information about the issue