Merge pull request #53 from tobiasgirardet/conv_fix_dosage

Fix dosage converter
This commit is contained in:
Grahame Grieve 2019-06-25 22:27:33 +10:00 committed by GitHub
commit 4ca4a595b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 4 deletions

View File

@ -1418,16 +1418,32 @@ public class VersionConvertor_30_40 {
tgt.setRoute(convertCodeableConcept(src.getRoute()));
if (src.hasMethod())
tgt.setMethod(convertCodeableConcept(src.getMethod()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose())
tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) {
// We need to manually make sure that the convertSimpleQuantity method is
// called. Otherwise (if we would simply forward to the convertType method), this would lead
// to a conversion to another Quantity object, that would be invalid for the DSTU3 Dosage resource.
if (src.getDoseAndRate().get(0).getDose() instanceof org.hl7.fhir.r4.model.Quantity) {
tgt.setDose(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getDose()));
} else {
tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose()));
}
}
if (src.hasMaxDosePerPeriod())
tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod()));
if (src.hasMaxDosePerAdministration())
tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration()));
if (src.hasMaxDosePerLifetime())
tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate())
tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) {
// We need to manually make sure that the convertSimpleQuantity method is
// called. Otherwise (if we would simply forward to the convertType method), this would lead
// to a conversion to another Quantity object, that would be invalid for the DSTU3 Dosage resource.
if (src.getDoseAndRate().get(0).getRate() instanceof org.hl7.fhir.r4.model.Quantity) {
tgt.setRate(convertSimpleQuantity((org.hl7.fhir.r4.model.Quantity) src.getDoseAndRate().get(0).getRate()));
} else {
tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate()));
}
}
return tgt;
}