How To Create Your First FHIR Resource Like A Pro

Ashabil Rizhana

Ashabil Rizhana

Operations Manager

Exploring healthcare technology can feel like an uphill battle. The tech terrain is vast, but I've got your back. Now, what is FHIR—Fast Healthcare Interoperability Resources—? It's a modern standard simplifying data interoperability. FHIR stands out for its rapid adoption and user-friendly approach to healthcare data, representing a shift from proprietary formats to open, accessible standards. You might be tempted to think FHIR is just another acronym to add to the soup; but it's the secret sauce making healthcare data as shareable as your favorite memes. 

Setting the Stage 

Before starting, obtain the JSON schema from https://hl7.org/fhir/ to ensure compliance with FHIR standards. This schema acts as a guide for creating valid resources. Download that schema, extract it, and save it into a new folder.

Setting up VS Code 

Install VS Code if you don’t have it already, since we’ll be working with JSON data directly.

In VS Code you can use the JSON schema to autocomplete fields for you based on the resource type. Open VS Code settings and add the following to the end of your settings.json (Ctrl + Shift + P and User settings).

{
  "json.schemas": {
    "fileMatch": ["*.fhir.json"],
    "url": "fhir.schema.json"
  }
}

Note: You can replace *.fhir.json with just *.json, but that’ll trigger the FHIR schema validation for every json you edit.

Creating a FHIR Resource

Using VS Code, follow the schema to construct a FHIR resource. Focus on essential details like name, gender, birth date, contact information, and address. Here’s a basic example:

{
  "resourceType": "Patient",
  "name": [
    {
      "use": "official",
      "family": "Ramesh",
      "given": ["Sidharth"]
    }
  ],
  "gender": "male",
  "birthDate": "1997-09-08",
  "telecom": [
    {
      "system": "phone",
      "value": "1234567890",
      "use": "mobile"
    },
    {
      "system": "email",
      "value": "[email protected]"
    }
  ],
  "address": [
    {
      "line": ["Some street"],
      "city": "Manipal",
      "state": "Karnataka",
      "postalCode": "123456"
    }
  ]
}

Adding the Details

The auto-complete feature in VS Code serves as our guide, revealing FHIR's details. It's straightforward—outline the resource type, patient details, contacts, and address. Our resource will gradually take shape, fortified by the schema validation at every step. You can also check the structure defined by the FHIR specification for Patients on the FHIR Patient resource page.

structure defined by the FHIR specification for patients on the FHIR patient resource page

Multiple Example Patients are also available under the Examples tab. Make sure to click on “JSON” link if you want to see the JSON representation of these patients.

Wrapping Up: Your FHIR Resource Is Ready to Go

Congratulations! By following these steps, you’ve created your first FHIR resource—a patient resource, to be exact. This isn’t just a bunch of data; it's a structured representation that speaks volumes in the interoperability language of health IT. 

What's Next?

In essence, FHIR represents every healthcare data point as a simple "Resource". There are 100s of FHIR resources today defined by HL7 International. Want to represent a Diagnosis, there's a resource for that (Condition), want to represent a blood pressure reading, there's a resource for that (Observation).

FHIR enables us to move from complex proprietary locked-in formats - you had to pay a license to even get ACCESS to HL7v2's specs!! FHIR on the other hand is open and accessible by default, and it embodies the spirit of Web 2.0 more than any other health IT spec has by using REST API interactions as a first-class mode of communication. It still supports Messaging, Document exchange, and more, but FHIR REST is quickly becoming a way to separate the data from the applications. 

You might wonder, "What do I do with this resource?" Well, there’s a world of possibilities, from posting it to servers to using it in real health IT applications. We'll explore these in future posts, but for now, pat yourself on the back.

Are you more of a visual learner? Then head over to my YouTube channel where you can watch me go through all the steps to create a FHIR resource. 

If this article piqued your curiosity and you're keen to delve deeper into mastering FHIR, I invite you to watch my exclusive webinar.

FAQ’s

  1. How many resources are there in FHIR?

    As of this writing, FHIR R5, which is the latest version of FHIR has a total of 158 unique resources. FHIR R4 which is still the most widely adopted version of FHIR has a total of 145 resources.

  2. What best describes FHIR resources?

    A FHIR Resource can be best described as a computer-readable expression of a healthcare-related concept. The Condition resource may represent a clinical diagnosis whereas an Observation resource may represent a Blood Pressure reading of the patient. FHIR Resources are used along with code systems like SNOMED CT and LOINC to populate the fields defined by the FHIR information model to give full meaning to the resource. FHIR Resources also cover non-clinical concepts like insurance, billing, organization, etc.

  3. What is the resource lifecycle of FHIR?

    Depending on what type of FHIR resource is being used, the lifecycle differs. For resources representing clinical status, for example, AllergyIntollerence, the lifecycle states are simple: active or inactive. For clinical workflow resources like Encounter, you have: planned, canceled, in-progress, on-hold, stopped, and completed. Whereas for Request or Order workflow resources like MedicationRequest or ServiceRequest, it’s more complicated with: proposed, draft, requested, rejected, accepted, in-progress, on-hold, stopped, completed, and cancelled. So, the resource lifecycle depends on the type of resource being used and its modeling in the FHIR specification.

  4. What is the difference between FHIR resource and profile?

    A Profile is a set of constraints on the FHIR data model usually designed for particular a use case. The FHIR information model laid down by HL7 International is very generic. It acts more like a framework to extend for building use-case-specific information models. This can be done using Profiles - where one can extend the FHIR International Versions (like R4, R5) or another Profile and define more constraints on the usage of the information models. A FHIR Resource on the other hand is an “instance” of a particular FHIR Profile or version. Think of the FHIR Profile more like a “Class” or cookie cutter in object-oriented programming, and the FHIR Resource as an “Instance” or the cut cookie dough”.

  5. How to update a FHIR resource?

    When using FHIR REST, the resource can usually be updated using a PUT or a PATCH HTTP request.

 

Become a FHIR Expert Today — Join Our Free Webinar

Unlock the secrets to mastering FHIR in our exclusive, free live webinar. Discover why now is the prime time to excel and how you can become an expert.