FHIR Chat · Transform Raw JSON into FHIR JSON Using FHIR Plain Server · implementers

Stream: implementers

Topic: Transform Raw JSON into FHIR JSON Using FHIR Plain Server


view this post on Zulip Mohsen Jafari (Jul 26 2021 at 12:54):

I am going to use FHIR Plain Server to just transform my raw JSON (which is actually a questionnaire) into a FHIR based JSON. I decided to do that, as FHIR Plain Server already has lots of models/classes and functinos to do data transformation. However, when I read the different operations (annotations) of FHIR Plain Server, none of annotaions and functions accept a JSON data. If you understand my goal, then please help me. And if you think that I am in a wrong way please help me; and also if you think that there are a better way to perform this data transformation please guide me.

view this post on Zulip Jose Costa Teixeira (Jul 26 2021 at 13:12):

did you look at this?
https://build.fhir.org/ig/HL7/sdc/extraction.html

view this post on Zulip Mohsen Jafari (Jul 26 2021 at 13:21):

Jose Costa Teixeira said:

did you look at this?
https://build.fhir.org/ig/HL7/sdc/extraction.html

But this link is not related to my question. I mean I want to transform my own JSON (which somehow includes the information that are related to a questionnaire) into a FHIR based JSON Questionnaire, and is it a correct way to use the HAPI Plain Server to do so?

view this post on Zulip Daniel Venton (Jul 26 2021 at 13:38):

How would happy know how to translate a random json file into any standardized resource? You convert your format into the standard format, after that what you do with it is up to you.

view this post on Zulip Mohsen Jafari (Jul 26 2021 at 13:49):

Daniel Venton said:

How would happy know how to translate a random json file into any standardized resource? You convert your format into the standard format, after that what you do with it is up to you.

Let's show you an example of my goal for clarification. Suppose I declare the following resource provider.

import org.hl7.fhir.r4.model.Questionnaire;

@Controller
public class QuestionnaireResourceProvider implements IResourceProvider {

@Override
public Class<? extends IBaseResource> getResourceType() {
    return Questionnaire.class;
}

public Questionnaire transform(String some_json) {
   // As I know the internal structure of some_json string value, then I can extract the required data for questionnaire in this line

    // Then I can create a FHIR Questionnaire object and populate its properties with the above extracted information
    Questionnaire q = new Questionnaire();

    // And finally I can return the questionnaire as a FHIR based JSON Questionnaire
    return q;
}

}

But, my questions:

  • Is it a correct way to do so, or is there another specific solution for data transformation?
  • If the above solution is a correct way, then what should I put as an annotaion for the above transform() endpoint?
  • And any other idea/suggestion?

view this post on Zulip Daniel Venton (Jul 26 2021 at 14:10):

I'd say that you are trying to use HAPI in a manner that HAPI isn't intended for. However, I am not the HAPI expert, you might find something in #hapi . It's possible that you could use the https://hapifhir.io/hapi-fhir/docs/server_plain/rest_operations.html#type_create operation, but then you have to check is it an actual FHIR Questionnaire or my custom format or other custom format #42..... If you can even convince hapi to pass in a non-fhir resource to begin with. For that matter you could put a custom string attribute on your now custom fhir server's @Search operation that translates a custom json into a standard resource. (@Search supports POST method).


Last updated: Apr 12 2022 at 19:14 UTC