Learn how FHIRModels creates native data models for all FHIR resources, provides data validation to enforce resource integrity, and prevents the creation of structurally invalid resources — across multiple versions of the FHIR specification. Whether you're working with clinical data obtained from HealthKit or direct from a clinical system, FHIRModels makes FHIR easy to handle.
Hi my name is Pascal and I'm here to talk about handling FHIR without getting burned.
We'll add support for new releases as they emerge. It is available via GitHub co-hosted by our friends at CareKit. Now, let's handle some FHIR.
Here's how you can get a full fledged FHIR data model from clinical data that you obtain via the HealthKit API. First import HealthKit and the DSTU2 library from the FHIRModels package. Grab an HKClinicalRecord from HealthKit and its associated HKFHIRResource. You can inspect HKFHIRResource to know its type. Parse the resource's JSON data to receive, in this case, a "MedicationOrder" instance. You could then print the note.
Let's complicate things a bit by presenting dosage instructions with an associated date range from a deeply nested structure. First, write an extension on "TimingRepeat", a type provided by FHIRModels. We want to pull out the start and end dates of the bounds' period. In the real world you would want to make this far more extensive, like check for nullability and use a good old date formatter. Then, map over all the prescription's dosage instructions. Use your new extension to prefix the instruction with the data range during which these instructions were valid. Another fun part of FHIR is the fact that different releases are in use out there in the wild. In the fall of 2014, the first draft standard for trial use "DSTU-1" was released. It was followed by three more major releases up to today. Soon, release 5 will be let out of the barn. However, as I alluded to, when a new release is published, existing APIs aren't magically updated.
You likely want to support the more popular releases, especially DSTU-2 for a few more years. So let's see how you can support multiple FHIR releases with FHIRModels. First, import the appropriate libraries from FHIRModels. Then assuming you have a "FHIRRelease" enum with values for all FHIR releases you want to support, switch over the release and use the JSON decoder with the appropriate model types. Here we use MedOrder for DSTU2 and MedRequest for R4. Finally, walk the properties accordingly to arrive at the values you want to extract. This, and much more, is what you can do with FHIRModels. To wrap up, FHIRModels helps you deal with the complexity of FHIR resources and even FHIR releases.
Use the package when you're working with clinical data obtained by the HealthKit API. Also take a look at "What's new in CareKit" to see how you can use FHIR with CareKit to build care apps. Or, of course, enhance your own, independent FHIR apps with the use of this package. Here's what you can do from here. Clone the library, add it to your project and start exploring the code. File issues even if you just want to provide feedback or ask questions.
Get our sample app, which shows how you can integrate FHIRModels into an app that uses the HealthKit API. And finally, you can learn more about FHIR
Looking for something specific? Enter a topic above and jump straight to the good stuff.
An error occurred when submitting your query. Please check your Internet connection and try again.