![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50; 002 003import java.util.Collections; 004 005import org.hl7.fhir.convertors.context.ConversionContext14_50; 006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Decimal14_50; 007import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.UnsignedInt14_50; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class Timing14_50 { 011 public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu2016may.model.Timing src) throws FHIRException { 012 if (src == null || src.isEmpty()) return null; 013 org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); 014 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 015 for (org.hl7.fhir.dstu2016may.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); 016 if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); 017 if (src.hasCode()) tgt.setCode(CodeableConcept14_50.convertCodeableConcept(src.getCode())); 018 return tgt; 019 } 020 021 public static org.hl7.fhir.dstu2016may.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { 022 if (src == null || src.isEmpty()) return null; 023 org.hl7.fhir.dstu2016may.model.Timing tgt = new org.hl7.fhir.dstu2016may.model.Timing(); 024 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 025 for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); 026 if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); 027 if (src.hasCode()) tgt.setCode(CodeableConcept14_50.convertCodeableConcept(src.getCode())); 028 return tgt; 029 } 030 031 public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent src) throws FHIRException { 032 if (src == null || src.isEmpty()) return null; 033 org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); 034 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 035 if (src.hasBounds()) 036 tgt.setBounds(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getBounds())); 037 if (src.hasCount()) tgt.setCount(src.getCount()); 038 if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); 039 if (src.hasDuration()) tgt.setDurationElement(Decimal14_50.convertDecimal(src.getDurationElement())); 040 if (src.hasDurationMax()) tgt.setDurationMaxElement(Decimal14_50.convertDecimal(src.getDurationMaxElement())); 041 if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); 042 if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); 043 if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); 044 if (src.hasPeriod()) tgt.setPeriodElement(Decimal14_50.convertDecimal(src.getPeriodElement())); 045 if (src.hasPeriodMax()) tgt.setPeriodMaxElement(Decimal14_50.convertDecimal(src.getPeriodMaxElement())); 046 if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); 047 if (src.hasWhen()) tgt.setWhen(Collections.singletonList(convertEventTiming(src.getWhenElement()))); 048 if (src.hasOffset()) tgt.setOffsetElement(UnsignedInt14_50.convertUnsignedInt(src.getOffsetElement())); 049 return tgt; 050 } 051 052 public static org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { 053 if (src == null || src.isEmpty()) return null; 054 org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu2016may.model.Timing.TimingRepeatComponent(); 055 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 056 if (src.hasBounds()) 057 tgt.setBounds(ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().convertType(src.getBounds())); 058 if (src.hasCount()) tgt.setCount(src.getCount()); 059 if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); 060 if (src.hasDuration()) tgt.setDurationElement(Decimal14_50.convertDecimal(src.getDurationElement())); 061 if (src.hasDurationMax()) tgt.setDurationMaxElement(Decimal14_50.convertDecimal(src.getDurationMaxElement())); 062 if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); 063 if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); 064 if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); 065 if (src.hasPeriod()) tgt.setPeriodElement(Decimal14_50.convertDecimal(src.getPeriodElement())); 066 if (src.hasPeriodMax()) tgt.setPeriodMaxElement(Decimal14_50.convertDecimal(src.getPeriodMaxElement())); 067 if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); 068 if (src.hasWhen()) tgt.setWhenElement(convertEventTiming(src.getWhen().get(0))); 069 if (src.hasOffset()) tgt.setOffsetElement(UnsignedInt14_50.convertUnsignedInt(src.getOffsetElement())); 070 return tgt; 071 } 072 073 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.UnitsOfTime> convertUnitsOfTime(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime> src) throws FHIRException { 074 if (src == null || src.isEmpty()) return null; 075 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.UnitsOfTime> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.UnitsOfTimeEnumFactory()); 076 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 077 if (src.getValue() == null) { 078 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); 079 } else { 080 switch (src.getValue()) { 081 case S: 082 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.S); 083 break; 084 case MIN: 085 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MIN); 086 break; 087 case H: 088 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.H); 089 break; 090 case D: 091 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.D); 092 break; 093 case WK: 094 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.WK); 095 break; 096 case MO: 097 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.MO); 098 break; 099 case A: 100 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.A); 101 break; 102 default: 103 tgt.setValue(org.hl7.fhir.r5.model.Timing.UnitsOfTime.NULL); 104 break; 105 } 106 } 107 return tgt; 108 } 109 110 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime> convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.UnitsOfTime> src) throws FHIRException { 111 if (src == null || src.isEmpty()) return null; 112 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTimeEnumFactory()); 113 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 114 if (src.getValue() == null) { 115 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); 116 } else { 117 switch (src.getValue()) { 118 case S: 119 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.S); 120 break; 121 case MIN: 122 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MIN); 123 break; 124 case H: 125 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.H); 126 break; 127 case D: 128 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.D); 129 break; 130 case WK: 131 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.WK); 132 break; 133 case MO: 134 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.MO); 135 break; 136 case A: 137 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.A); 138 break; 139 default: 140 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.UnitsOfTime.NULL); 141 break; 142 } 143 } 144 return tgt; 145 } 146 147 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.EventTiming> convertEventTiming(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.EventTiming> src) throws FHIRException { 148 if (src == null || src.isEmpty()) return null; 149 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.EventTiming> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Timing.EventTimingEnumFactory()); 150 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 151 if (src.getValue() == null) { 152 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); 153 } else { 154 switch (src.getValue()) { 155 case HS: 156 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.HS); 157 break; 158 case WAKE: 159 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.WAKE); 160 break; 161 case C: 162 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.C); 163 break; 164 case CM: 165 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CM); 166 break; 167 case CD: 168 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CD); 169 break; 170 case CV: 171 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.CV); 172 break; 173 case AC: 174 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.AC); 175 break; 176 case ACM: 177 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACM); 178 break; 179 case ACD: 180 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACD); 181 break; 182 case ACV: 183 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.ACV); 184 break; 185 case PC: 186 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PC); 187 break; 188 case PCM: 189 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCM); 190 break; 191 case PCD: 192 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCD); 193 break; 194 case PCV: 195 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.PCV); 196 break; 197 default: 198 tgt.setValue(org.hl7.fhir.r5.model.Timing.EventTiming.NULL); 199 break; 200 } 201 } 202 return tgt; 203 } 204 205 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.EventTiming> convertEventTiming(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.EventTiming> src) throws FHIRException { 206 if (src == null || src.isEmpty()) return null; 207 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.Timing.EventTiming> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.Timing.EventTimingEnumFactory()); 208 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 209 if (src.getValue() == null) { 210 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); 211 } else { 212 switch (src.getValue()) { 213 case HS: 214 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.HS); 215 break; 216 case WAKE: 217 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.WAKE); 218 break; 219 case C: 220 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.C); 221 break; 222 case CM: 223 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CM); 224 break; 225 case CD: 226 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CD); 227 break; 228 case CV: 229 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.CV); 230 break; 231 case AC: 232 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.AC); 233 break; 234 case ACM: 235 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACM); 236 break; 237 case ACD: 238 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACD); 239 break; 240 case ACV: 241 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.ACV); 242 break; 243 case PC: 244 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PC); 245 break; 246 case PCM: 247 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCM); 248 break; 249 case PCD: 250 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCD); 251 break; 252 case PCV: 253 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.PCV); 254 break; 255 default: 256 tgt.setValue(org.hl7.fhir.dstu2016may.model.Timing.EventTiming.NULL); 257 break; 258 } 259 } 260 return tgt; 261 } 262}