Stream: mapping-framework
Topic: Custom JSON as Source Model
Kailash (Nov 02 2021 at 14:32):
Hi All,
I am trying to transform a simple JSON patient data to FHIR Patient resource,
Is there any help for JSON as source to understand the complete transformation execution, like we have help for xml as source and destination - https://github.com/ahdis/fhir-mapping-tutorial.
Thanks
Oliver Egger (Nov 02 2021 at 18:29):
you can do it the same way, define a Logical Model (StructureDefinition) for your JSON patient data and then you use for the source encoding json instead of xml
Kailash (Nov 03 2021 at 04:15):
@Oliver Egger thanks, I follow the same XML approach but I am getting below error while transforming custom JSON using HL7 validator -
Load file location*
load file: SourceModel.json - ignored due to error: Unable to find resource type - maybe not a FHIR resource?
- 2 resources (00:00.0114)
Get set... go (00:00.0059)
...Failure: Unable to find resourceType property at line -1 col -1
org.hl7.fhir.exceptions.FHIRFormatError: Unable to find resourceType property at line -1 col -1
at org.hl7.fhir.r5.elementmodel.ParserBase.logError(ParserBase.java:99)
at org.hl7.fhir.r5.elementmodel.JsonParser.parse(JsonParser.java:140)
at org.hl7.fhir.r5.elementmodel.JsonParser.parse(JsonParser.java:128)
at org.hl7.fhir.r5.elementmodel.Manager.parse(Manager.java:86)
at org.hl7.fhir.validation.ValidationEngine.transform(ValidationEngine.java:396)
at org.hl7.fhir.validation.ValidationEngine.transform(ValidationEngine.java:390)
at org.hl7.fhir.validation.cli.services.ValidationService.transform(ValidationService.java:178)
at org.hl7.fhir.validation.ValidatorCli.doValidation(ValidatorCli.java:207)
at org.hl7.fhir.validation.ValidatorCli.main(ValidatorCli.java:159)
Done. Times: Loading: 00:18.0569. Max Memory = 1Gb
Do I need to add "resourceType" element to JSON data? so that it reflect as per logical structure definition type, this issue is not with XML input as XML do have root element and we can take that as logical structure definition type.
Oliver Egger (Nov 03 2021 at 07:42):
@Kailash that sounds like the json parser cannot handle logical model json instances, would it be possible for you to provide a testcase for the validator? https://github.com/hapifhir/org.hl7.fhir.core/tree/master/org.hl7.fhir.validation/src/test/java/org/hl7/fhir/validation/tests/manifest.json
Kailash (Nov 03 2021 at 09:04):
Thanks, I am not sure about the process, I am providing all files here for the use case including source JSON data, created Logical model and Map.
Let me know if any issue in those files or as you mentioned it could be validator issue. sampleDemo.zip
Last updated: Apr 12 2022 at 19:14 UTC