Creating and Validating Any HL7 FHIR Resource by using FHIR schema
Tags: ensemble, fhir, vscode, tutorial
Published: 2022-03-15 17:04:21

Healthcare interoperability is instrumental in improving patient care, decreasing healthcare provider costs, and providing a more accurate picture to providers. However, with so many different systems, data is formatted in many different ways. There are many standards that have been created to try to solve this problem, including HL7v2, HL7v3, and CDA but each one has its drawbacks.

FHIR, or Fast Healthcare Interoperability Resources, is a new format for healthcare data that aims at solving these problems. It is developed by Health Level Seven International (HL7), an organization that also developed HL7v2, HL7v3 and CDA.

Today we will explore how to Create and Validate FHIR Resource by using FHIR schema with the help of IntelliSense and auto complete functionality in VS Code.

**Step 1** : Download JSON schema file for Resource validation from FHIR offical website https://www.hl7.org/fhir/


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfkqd97b7x3vtz58c565.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vs0rr444vakdfk1qj4wi.png)

**Step 2:** Create folder (in this example I am using Patient folder and Patient Resource) and copy extracted fhir.schema.json file to same folder, then open folder from VS Code   

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fzumg1dscfoj8idnhfxq.png) 
 

**Step 3:** Setup the VS code to recognize FHIR schema by modifying setting.json file.  
Press CTRL+SHIFT+P and type workspace settings JSON  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpa3xtbtkv7behohw12u.png) 
 

**Step 4:** Create a new file patient.fhir.json in the same folder.  
Press Ctrl+Space and you will get all the attributes of the FHIR resources through IntelliSense


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1hkmkwf9xir5os9rz1a.png) 

Add Resource type Patient and all the attributes related to patient resource will start appearing in the IntelliSense.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdkfswdad5eeiktceb42.png) 

**VS Code will automatically validate structure and syntax of the Resource.**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkfhxrwg1fxu8fwdicbe.png)  
 

By the help of IntelliSense and auto complete we have created and validated our patient resource.  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nus08s4o81uzwy7rslhp.png) 

<span style="font-size:14px;"><strong>Step 5:</strong> Post the create resource in InterSystems FHIR server using Rest API from postman</span>


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmd2ujnt63yim2zwffyw.png)

Retrieve the Created Patient Resource by using Get method


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cfhnbutvqr2247t1xe2i.png) 

Congratulations!, We have created, validated our Patient Resource and successfully posted and retrieved to InterSystems FHIR Server using postman.  
In this way we can easily create and validate any FHIR Resource.