Project: REST JSON to FHIR JSON Mapping Implementation

Thanks it now works. The problem was with my Internet provider. I changed to another provider and everything now works well.

Hi All,

I completed fhir to librehealth json representation as well.

Following are the outputs

CONVERTED LIBRE HEALTH PATIENT TO FHIR {“resourceType”:“Patient”,“id”:“f19c6540-0058-4bb2-9019-d61dd6afd0ce”,“identifier”:[{“id”:“f625a561-6cef-4e5a-a661-72377641d8d4”,“use”:“usual”,“system”:“Old Identification Number”,“value”:“1234”}],“active”:false,“name”:[{“id”:“9a4df03d-731e-4023-ae88-af7d82f86777”,“family”:“family1”,“given”:[“test1”]}],“gender”:“female”,“birthDate”:“1984-01-01”,“address”:[{“id”:“1bb9664c-da14-4db6-aea6-018046c8841c”,“use”:“home”,“line”:[“Address1”,“Address12”],“city”:“SampleVillege”,“state”:“SampleProvince”,“postalCode”:“7878”,“country”:“SampleCountry”}]}

CONVERTED FHIR PATIENT TO LIBRE HEALTH {“identifiers”:[{“display”:“Old Identification Number=1234”,“links”:[{“ref”:“self”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/identifier/f625a561-6cef-4e5a-a661-72377641d8d4"}],“uuid”:“f625a561-6cef-4e5a-a661-72377641d8d4”}],“person”:{“preferredAddress”:{“display”:"",“links”:[{“ref”:“self”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/address/1bb9664c-da14-4db6-aea6-018046c8841c”}],“uuid”:“1bb9664c-da14-4db6-aea6-018046c8841c”},“birthdate”:"Sun Jan 01 00:00:00 IST 1984”,“gender”:“F”,“display”:“family1”,“links”:[{“ref”:“self”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/person/Patient/f19c6540-0058-4bb2-9019-d61dd6afd0ce"},{“ref”:“ful”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/patient/Patient/f19c6540-0058-4bb2-9019-d61dd6afd0ce?v=full”}],“preferredName”:{“display”:“family1”,“links”:[{“ref”:“self”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/name/9a4df03d-731e-4023-ae88-af7d82f86777”}],“uuid”:“9a4df03d-731e-4023-ae88-af7d82f86777”},“uuid”:“Patient/f19c6540-0058-4bb2-9019-d61dd6afd0ce”},“display”:“1234-family1”,“links”:[{“ref”:“self”,“uri”:“https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/patient/Patient/f19c6540-0058-4bb2-9019-d61dd6afd0ce”},{}],“uuid”:"Patient/f19c6540-0058-4bb2-9019-d61dd6afd0ce”}

1 Like

Sorry to be slow on this. I finally spent some time reviewing the two attempts that have been made on this thread. I looked at this - https://github.com/kavindya89/librehealth and this - https://github.com/lehone-hp/rest-to-fhir-json-example

Both of those are sort of depending on a model. I like the spec from @lehone, but I think it is still very much hard-coded and will not work as the spec changes. On the other hand, most FHIR servers provide a /validate endpoint. You should use those, and your code should iteratively remember/learn from that validation process.

@lehone, I think you only got the one-way working, because I didnt see FHIR to REST conversion.

@sunbiz Thank you for reviewing the code.

I have used HAPI FHIR library to perform the Librehealth JSON to FHIR conversion. I think this will be good as it provides all the FHIR version support and validations. Hence populating the relevant resource in FHIR specification gives me a advantage of simply convert the model to JSON from a standard library and use particular object for validation. With the library we can convert the required librehealth resources to required FHIR version. I will look at publicly exposed FHIR validation endpoints as well.

Regarding the FHIR to REST, I convert FHIR JSON to its model representation and then used it to build the librehealth format of the resource.

One challenge I encounter was there were no mappings for some attributes.

@sunbiz what should I do next? I will add validations to the resources. I think we need to validate the librehalth format of resource as well.

@prashadi Its good that you are using the HAPI fhir-base and fhir-structures, but I was pointing to this code - https://github.com/kavindya89/librehealth/blob/master/src/main/java/org/librehealth/convert/service/PatientUtil.java This means that for every resource, you have to spend a lot of code to do the mapping. IMO, this is not optimal. I’d like you to think of generic ways in which this can be implemented, such that we can do this mapping outside code, and maybe using external configs?

Sorry about the FHIR to REST conversion, I have been a little bit busy but I will complete it shortly. It is indeed dependent on a model but we will face a problem if the spec change. We will need to look for a way in order to fix that but I posted the converted resource to an FHIR server for validation.

I have added code to perform the reverse json conversion on the Patient resource

I have given this task to modify the module by @judywawira So I want to know about the objective of this task and what technology i can use to complete this work

Thank you @sunbiz for the clarification. I got your point. So we need to find out a way to map FHIR to Librehealth JSON and vice versa. If we need to keep a mapping, we might need to use XSLT transformations?

XSLT is a good option… or you might need JAXB bindings, if you import the HAPI and REST Webservices module jar (remember to use the omod like a JAR, so thats it doesnt need you to write an OpenMRS module). You might also be able to use JOLT, like I said in my earlier post.

3 Likes

@sunbiz I looked at both XSLT and JOLT. Both a feasible options. However I have small concern on the Librehealth JSON to FHIR JSON mappings.

In librehelath if I take patient, the address location is specified through a resource URI such as https://radiology.librehealth.io/lh-toolkit/ws/rest/v1/patient/address/1bb9664c-da14-4db6-aea6-018046c8841c. This is same for the name as well. Hence we need to fetch address, name again with the requested url to fill the FHIR JSON. So we will need to parse the same template multiple time? or should we construct single JSON representation and do a transformation if we goes with template approach?

Also I think we need to have a HAPI library to do a offline validation.

1 Like

I think you’ll have to fetch it multiple times. To avoid this, get a full representation by passing the parameter ?v=full after a resource.

1 Like

Hi @sunbiz , I am Amitabh new to the community. Please help me to get started on this project. Are there any tasks that I need to accomplish or a specific aspect of this project as pre-requisite to GSoC application submission. Please point out to those. I’ve introduced myself on the main thread and a community-member directed me to this project. I am setting up the dev-environment and getting started.

Github Profile: https://www.github.com/amitabh27 Linkedin Profile : https://www.linkedin.com/in/tiwariamitabh/

Thanks and Regards, Amitabh Tiwari

@amitabh27, if you are interested in the lh-toolkit or lh-radiology projects, then I recommend that you complete the following prerequisite tasks:

The REST JSON to FHIR JSON mapping is a good starter project, but its only to give you an idea about comparing the two data models.

Sure @sunbiz I will take up the two tasks. Regards!

Yes v=full seems to be the option :slight_smile:

@prashadi do you have a proposal for us to review for the Spring data, or another toolkit/radiology project that you will be working on over the summer? We are suggesting that you do the drafts in the GSoC application portal only.

1 Like

@sunbiz I have few questions on spring data. Will ask in the project thread.

@sunbiz @judywawira thank you for accepting me to GSoC. I’m looking forward to do my best to achieve success in the project. What should be our next steps? Should I focus on the spring data project or FHIR analytics related project? So I can prepare in advance during the community bonding period and collect necessary information.

1 Like

Hi @prashadi, I will be mentoring you along with @judywawira. I am excited to work with you in the summer. I have been involved in OpenMRS and GSoC for many years and have worked as a Java developer for 9 years.

My suggestion is that you work on the FHIR analytics project. I assume there will be four parts in the project as below:

  1. Integration of Spark with spring boot application.
  2. Deployment of FHIR Bundle on a Spark-supported database.
  3. Spark configuration for FHIR Bundle.
  4. User interface for query builder.

We could discuss these in detail. You should start a new thread as suggested in the welcome to GSoC thread. @sunbiz suggested that you and @yashdsaraf work closely in a common reactive spring boot 2.x app that works with Spring 5.