FHIR has a large number of resources available and, of course, not all of them are useful in an EHR context or in the contexts OpenMRS is normally used in, but a great many of them are, including many resources for which we have no OpenMRS analogue or poorly-defined ones.
In the past, we’ve occasionally created new tables to represent FHIR resources we need, e.g., the Task resource was pretty central to the lab workflow—and is probably pretty central to being able to “FHIR-ize” any order workflow1—so we added a Task class. This works well enough, but it has some serious limitations to it. In particular, to keep the Task flexible enough to be able to reference the appropriate resources (including for basedOn
which can be a reference to any FHIR resource), we end up with a model that lacks any of the normal referential integrity we might have, and consequently our ability to write performant queries against Task. For instance, our current implementation can handle a query to get any task created as part of a given encounter (/ws/fhir2/R4/Task?encounter=893c6850-ff9e-4b11-bc59-52d60c1cc0d7
), but we couldn’t add the flexibility we have with other resources to implement chaining to allow things like queries for tasks related to encounters by characteristics of that encounter (e.g., find me all tasks related to active encounters for John Smith: /ws/fhir2/R4/Task?encounter.status=in-progress&for:Patient.name=John%20Smith
), at least not in a performant way. The overall point is that this probably isn’t the best way to add FHIR resources for things not already covered by the OMRS data model.
However, there are certainly needs to represent FHIR resources that currently don’t fit comfortably in the OMRS data model or at least to use FHIR as a model for expanding the OMRS datamodel, but we need to think carefully about how we do this. Plausible ways of moving forward are:
- We store things in the Obs table either as Obs or ComplexObs (e.g.
DocumentReference
s,MedicationDispense
s etc.). We also have done this with Immunization, though the results are probably a little brittle. This probably means ensuring that we have standarised models in CIEL for these things and that implementers are happy using those CIEL models. - We create bespoke models that address narrow use-cases, e.g. create some sort of model for MedicationDispense more similar to existing OMRS data model objects. This allow us to best take advantage of the tooling in the FHIR2 module to provide a decent user experience at the expense of probably needing to limit what data we can actually accept.
- We continue to create new data models after the model of Task, where we can represent all the data a Task can store, but lose referential integrity and chainability.
- We fall-back to something like a real FHIR server, e.g., by embedding a HAPI JPA server to serve those resources we can’t represent in the OMRS model. This allows us to keep the full flexibility of FHIR resources and search, but means we need to come up with a strategy for synchronising this FHIR instance with the resources already available in OMRS.’
Something like 4 has been the sort of thing I’ve been planning on, but it has some obvious draw-backs, in particular, how do resources in the secondary FHIR server reference resources in the OMRS database?
I’d appreciate any thoughts or commentary from the community on this.
Thanks!
1: FHIR’s workflow model distinguishes between “Requests”, e.g., an order and “Events”, e.g., a medication dispense or diagnostic report. “Tasks” are the resource used to track what happens between the request and the corresponding event (if any), including things like was the order rejected?