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

View File

@ -1418,16 +1418,32 @@ public class VersionConvertor_30_40 {
tgt.setRoute(convertCodeableConcept(src.getRoute())); tgt.setRoute(convertCodeableConcept(src.getRoute()));
if (src.hasMethod()) if (src.hasMethod())
tgt.setMethod(convertCodeableConcept(src.getMethod())); tgt.setMethod(convertCodeableConcept(src.getMethod()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasDose()) {
tgt.setDose(convertType(src.getDoseAndRate().get(0).getDose())); // 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()) if (src.hasMaxDosePerPeriod())
tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod())); tgt.setMaxDosePerPeriod(convertRatio(src.getMaxDosePerPeriod()));
if (src.hasMaxDosePerAdministration()) if (src.hasMaxDosePerAdministration())
tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration())); tgt.setMaxDosePerAdministration(convertSimpleQuantity(src.getMaxDosePerAdministration()));
if (src.hasMaxDosePerLifetime()) if (src.hasMaxDosePerLifetime())
tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime())); tgt.setMaxDosePerLifetime(convertSimpleQuantity(src.getMaxDosePerLifetime()));
if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) if (src.hasDoseAndRate() && src.getDoseAndRate().get(0).hasRate()) {
tgt.setRate(convertType(src.getDoseAndRate().get(0).getRate())); // 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; return tgt;
} }