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