Stream: hapi
Topic: BUG: Java, FHIR R4, Converting Bundle to Json
Zak Guler (Jul 07 2020 at 20:56):
The issue is when I convert Bundle object to a json fhir document, the reference id ads the resource type to the id.
EX: FHIRConfig.getCtx().newJsonParser().setPrettyPrint(prettyPrint).encodeResourceToString(msgBundle);
will produce the following:
..
"reference": "Patient/04f2325e-b068-4a6e-9990-87147e918922"
},
{
"reference": "Practitioner/5ece02c6-551f-46ca-a35f-8b502e849fdd"
},
{
"reference": "Observation/0e179660-6c5e-4e87-af53-9935c57d3a59"
..
What can I do to make sure the resource type is NOT tagged with the id in the output chir document:
"reference": "04f2325e-b068-4a6e-9990-87147e918922"
your help is appreciated.
thanx
Grahame Grieve (Jul 07 2020 at 22:06):
please start by providing code so we know how you are converting
Zak Guler (Jul 08 2020 at 18:26):
-first we call the @Search get method in the [FHIR-CLIENT] SearchController.
-the search method calls the [FHIR-SERVER] to get the DeathRecord [Bundle].
-control goes to the @Search method in the [FHIR-CLIENT] PatientResourceProvider class.
-[FHIR-CLIENT] passes the parameters to the search method in PatientDao class.
-[FHIR-CLIENT] goes to EdenmasterService class [findEdenmasterBundles()] to get the data from the database.
-[FHIR-CLIENT] back to PatientDao to convert the Patient data to a bundle: bundle = edenmasterEntityToFHIRPatient.convertToBundles(edenmasters)
-[FHIR-CLIENT] in EdenmasterEntityToFHIRPatient...convertToBundles(edenmasters) is where the magic starts:
builds the Bundle, Patient, Composition, Observations...etc
-control comes back to the @Search method in PatientResourceProvider to return as a Bundle object.
-[FHIR-CLIENT] back in the SearchController, the DeathRecordSubmission class merges the DeathRecord[bundle] with other resource types and creates a new expanded bundle.
-[FHIR-CLIENT] DeathRecordSubmission.toJson(-the new bundle-):
return FHIRConfig.getCtx().newJsonParser().setPrettyPrint(prettyPrint).encodeResourceToString(msgBundle);
the full FHIR Document output is attached with this message.
Note:
The interesting thing is, when I generate the fhie document by calling the FHIR-Server from a tool like POSTMAN, it gereates the reference ids properly without the resourceTypes tagged to it.
the conversion in the FHIR-Server does not call the FHIRConfig.getCtx().newJsonParser().setPrettyPrint(prettyPrint).encodeResourceToString(msgBundle).
I am also attaching the clean file with this message.
please let me know if you need additional info.
thank you very much for your help in advance.
Zak
Fhir_Server_SRC_Chat_Fhir_Org.zip
To_NCHS_udoh_fhir_client_R4_Chat_Fhir_Org.zip FHIR_Doc_ReferenceIds_tagged_with_resourceTypes_Chat_Fhir_org.txt FHIR_Doc_ReferenceIds_withOUT_resourceTypes_Chat_Fhir_org.txt
Zak Guler (Jul 13 2020 at 15:59):
Hi any luck with this issue? did I provide you with more code than you requested?
Last updated: Apr 12 2022 at 19:14 UTC