Stream: hapi
Topic: Issue with MedicationAdminstration conversion R4 -> STU3
Juuso Oksanen (Oct 24 2019 at 12:54):
There seems to be an issue with MedicationAdministration.dosage.rate[x] when converting from R4 to STU3.
The conversion itself doesn't throw an exception but after trying to encode the resource to string the parser throws an exception:
ca.uhn.fhir.parser.DataFormatException: rate has type org.hl7.fhir.dstu3.model.Quantity but this is not a valid type for this element - Expected one of: [class org.hl7.fhir.dstu3.model.Ratio, class org.hl7.fhir.dstu3.model.SimpleQuantity]
at ca.uhn.fhir.parser.BaseParser.throwExceptionForUnknownChildType(BaseParser.java:968)
at ca.uhn.fhir.parser.BaseParser.getChildNameAndDef(BaseParser.java:429)
at ca.uhn.fhir.parser.JsonParser.encodeCompositeElementChildrenToStreamWriter(JsonParser.java:421)
at ca.uhn.fhir.parser.JsonParser.encodeCompositeElementToStreamWriter(JsonParser.java:577)
at ca.uhn.fhir.parser.JsonParser.encodeChildElementToStreamWriter(JsonParser.java:281)
at ca.uhn.fhir.parser.JsonParser.encodeCompositeElementChildrenToStreamWriter(JsonParser.java:487)
at ca.uhn.fhir.parser.JsonParser.encodeCompositeElementToStreamWriter(JsonParser.java:577)
at ca.uhn.fhir.parser.JsonParser.encodeResourceToJsonStreamWriter(JsonParser.java:731)
at ca.uhn.fhir.parser.JsonParser.encodeResourceToJsonStreamWriter(JsonParser.java:615)
at ca.uhn.fhir.parser.JsonParser.doEncodeResourceToJsonLikeWriter(JsonParser.java:163)
at ca.uhn.fhir.parser.JsonParser.doEncodeResourceToWriter(JsonParser.java:170)
at ca.uhn.fhir.parser.BaseParser.encodeResourceToWriter(BaseParser.java:367)
at ca.uhn.fhir.parser.BaseParser.encodeResourceToWriter(BaseParser.java:351)
at ca.uhn.fhir.parser.BaseParser.encodeResourceToString(BaseParser.java:340)
As far as I know, shouldn't the MedicationAdministration.dosage.rate[x] be either SimpleQuantity or Ratio? For some reason after converting the resource, the type of rate is Quantity.
Also after parsing the R4-version of the MedicationAdministration resource, both the rate and dose were Quantity but this is considered valid it would seem.
The version we are running is 4.0.3.
I managed to replicate this behavior with a unit test, since the original issue was spotted when RestfulServer sends the resource back as response to the user after the OutgoingResponse-hooks.
I also looked up the code in the VersionConvertor30_40 and I found out that MedicationAdministration.dosage.rate[x] doesn't even have an option for converting the rate to SimpleQuantity, it will always convert it Quantity. (check: VersionConvertor30_40:convertMedicationAdmistrationDosageComponent():13934 and VersionConvertor30_40:convertType():2910)
I can add more context by means of a unit test and some resource data if it is necessary.
This does look kind of weird to me.
Grahame Grieve (Oct 24 2019 at 17:26):
sure please submit the unit test as a PR or an issue, and I'll look at the underlying problem
Grahame Grieve (Oct 24 2019 at 18:50):
@James Agnew this is actually an issue in your parser framework - SimpleQuantity is not a real class, it's just a profile, so the underlying type is actually a Quantity
Juuso Oksanen (Oct 25 2019 at 14:13):
Created an issue regarding this:
https://github.com/jamesagnew/hapi-fhir/issues/1564
Last updated: Apr 12 2022 at 19:14 UTC