
001package org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext14_50; 004import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Code14_50; 005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Decimal14_50; 006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50; 007import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Uri14_50; 008import org.hl7.fhir.dstu2016may.model.Quantity; 009import org.hl7.fhir.exceptions.FHIRException; 010import org.hl7.fhir.r5.model.Enumerations; 011 012public class Quantity14_50 { 013 public static org.hl7.fhir.r5.model.Quantity convertQuantity(org.hl7.fhir.dstu2016may.model.Quantity src) throws FHIRException { 014 if (src == null || src.isEmpty()) return null; 015 org.hl7.fhir.r5.model.Quantity tgt = new org.hl7.fhir.r5.model.Quantity(); 016 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 017 if (src.hasValue()) tgt.setValueElement(Decimal14_50.convertDecimal(src.getValueElement())); 018 if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); 019 if (src.hasUnit()) tgt.setUnitElement(String14_50.convertString(src.getUnitElement())); 020 if (src.hasSystem()) tgt.setSystemElement(Uri14_50.convertUri(src.getSystemElement())); 021 if (src.hasCode()) tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); 022 return tgt; 023 } 024 025 public static org.hl7.fhir.dstu2016may.model.Quantity convertQuantity(org.hl7.fhir.r5.model.Quantity src) throws FHIRException { 026 if (src == null || src.isEmpty()) return null; 027 org.hl7.fhir.dstu2016may.model.Quantity tgt = new org.hl7.fhir.dstu2016may.model.Quantity(); 028 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 029 if (src.hasValue()) tgt.setValueElement(Decimal14_50.convertDecimal(src.getValueElement())); 030 if (src.hasComparator()) tgt.setComparatorElement(convertQuantityComparator(src.getComparatorElement())); 031 if (src.hasUnit()) tgt.setUnitElement(String14_50.convertString(src.getUnitElement())); 032 if (src.hasSystem()) tgt.setSystemElement(Uri14_50.convertUri(src.getSystemElement())); 033 if (src.hasCode()) tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); 034 return tgt; 035 } 036 037 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.QuantityComparator> convertQuantityComparator(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator> src) throws FHIRException { 038 if (src == null || src.isEmpty()) return null; 039 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.QuantityComparator> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.QuantityComparatorEnumFactory()); 040 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 041 if (src.getValue() == null) { 042 tgt.setValue(null); 043} else { 044 switch(src.getValue()) { 045 case LESS_THAN: 046 tgt.setValue(Enumerations.QuantityComparator.LESS_THAN); 047 break; 048 case LESS_OR_EQUAL: 049 tgt.setValue(Enumerations.QuantityComparator.LESS_OR_EQUAL); 050 break; 051 case GREATER_OR_EQUAL: 052 tgt.setValue(Enumerations.QuantityComparator.GREATER_OR_EQUAL); 053 break; 054 case GREATER_THAN: 055 tgt.setValue(Enumerations.QuantityComparator.GREATER_THAN); 056 break; 057 default: 058 tgt.setValue(Enumerations.QuantityComparator.NULL); 059 break; 060 } 061} 062 return tgt; 063 } 064 065 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator> convertQuantityComparator(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.QuantityComparator> src) throws FHIRException { 066 if (src == null || src.isEmpty()) return null; 067 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparator> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Quantity.QuantityComparatorEnumFactory()); 068 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 069 if (src.getValue() == null) { 070 tgt.setValue(null); 071} else { 072 switch(src.getValue()) { 073 case LESS_THAN: 074 tgt.setValue(Quantity.QuantityComparator.LESS_THAN); 075 break; 076 case LESS_OR_EQUAL: 077 tgt.setValue(Quantity.QuantityComparator.LESS_OR_EQUAL); 078 break; 079 case GREATER_OR_EQUAL: 080 tgt.setValue(Quantity.QuantityComparator.GREATER_OR_EQUAL); 081 break; 082 case GREATER_THAN: 083 tgt.setValue(Quantity.QuantityComparator.GREATER_THAN); 084 break; 085 default: 086 tgt.setValue(Quantity.QuantityComparator.NULL); 087 break; 088 } 089} 090 return tgt; 091 } 092}