Conditional References in HAPI FHIR -
hl7 fhir release 3 (stu) introduced concept of conditional references in transaction bundles:
when constructing bundle, client may not know logical id of resource, may know identifying information - e.g. identifier. situation arises commonly when building transactions v2 messages. client resolve identifier logical id using search, mean resolution logical id not occur within same transaction commit (as complicating client). because of this, in transaction (and in transaction), references resources may replaced search uri describes how find correct reference:
<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="post" /> </request> </entry> </bundle>
the search uri relative server's [base] path, , starts resource type:
[type]:?parameters....
filtering parameters allowed; none of parameters control return of resources relevant.when processing transactions, servers shall:
- check references search uris
- for search uris, use search locate matching resources
- if there no matches, or multiple matches, transaction fails, , error returned user
- if there single match, server replaces search uri reference matching resource
... quoted 2.21.0.17.2 transaction processing rules
i found concept of conditional references useful , use in hapi fhir client/server app. seems not supported. such transaction bundle si refused server following error messages:
client:
http 400 bad request: invalid resource reference found @
path[observation.subject]
- not contain resource type -patient?identifier=12345
exception in thread "main" ca.uhn.fhir.rest.server.exceptions.invalidrequestexception: http 400 bad request: invalid resource reference found @ path[observation.subject] - not contain resource type - patient?identifier=12345 @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:423) @ ca.uhn.fhir.rest.server.exceptions.baseserverresponseexception.newinstance(baseserverresponseexception.java:307) @ ca.uhn.fhir.rest.client.baseclient.invokeclient(baseclient.java:290) @ ca.uhn.fhir.rest.client.genericclient$baseclientexecutable.invoke(genericclient.java:637) @ ca.uhn.fhir.rest.client.genericclient$transactionexecutable.execute(genericclient.java:2209)
server log:
warn c.u.f.r.s.i.exceptionhandlinginterceptor [exceptionhandlinginterceptor.java:135] failure during rest processing: ca.uhn.fhir.rest.server.exceptions.invalidrequestexception: invalid resource reference found @
path[observation.subject]
- not contain resource type -patient?identifier=12345
so question is:
is possible use conditional references hapi fhir jpa server?
or if not possible, there work around? can use same conditional operation resolve reference or fail if reference target doesn't exist?
finally discovered possible hapi fhir vesion 2.2
adding following option server daoconfig
:
ca.uhn.fhir.jpa.dao.daoconfig.setallowinlinematchurlreferences(true)
should references containing match urls resolved , replaced in create , update operations. example, if property set true , resource created containing reference
patient?identifier=12345
, reference match url resolved , replaced according usual match url rules.default
false
now, experimental feature.
see source code here: github.com/jamesagnew/hapi-fhir
Comments
Post a Comment