
001package org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50; 002 003import java.util.stream.Collectors; 004 005import org.hl7.fhir.convertors.context.ConversionContext30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Decimal30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.UnsignedInt30_50; 008import org.hl7.fhir.exceptions.FHIRException; 009import org.hl7.fhir.r5.model.Enumerations; 010import org.hl7.fhir.r5.model.Timing; 011 012public class Timing30_50 { 013 public static org.hl7.fhir.r5.model.Timing convertTiming(org.hl7.fhir.dstu3.model.Timing src) throws FHIRException { 014 if (src == null) return null; 015 org.hl7.fhir.r5.model.Timing tgt = new org.hl7.fhir.r5.model.Timing(); 016 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 017 for (org.hl7.fhir.dstu3.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); 018 if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); 019 if (src.hasCode()) tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 020 return tgt; 021 } 022 023 public static org.hl7.fhir.dstu3.model.Timing convertTiming(org.hl7.fhir.r5.model.Timing src) throws FHIRException { 024 if (src == null) return null; 025 org.hl7.fhir.dstu3.model.Timing tgt = new org.hl7.fhir.dstu3.model.Timing(); 026 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 027 for (org.hl7.fhir.r5.model.DateTimeType t : src.getEvent()) tgt.addEvent(t.getValue()); 028 if (src.hasRepeat()) tgt.setRepeat(convertTimingRepeatComponent(src.getRepeat())); 029 if (src.hasCode()) tgt.setCode(CodeableConcept30_50.convertCodeableConcept(src.getCode())); 030 return tgt; 031 } 032 033 public static org.hl7.fhir.r5.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent src) throws FHIRException { 034 if (src == null) return null; 035 org.hl7.fhir.r5.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.r5.model.Timing.TimingRepeatComponent(); 036 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 037 if (src.hasBounds()) 038 tgt.setBounds(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getBounds())); 039 if (src.hasCount()) tgt.setCount(src.getCount()); 040 if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); 041 if (src.hasDuration()) tgt.setDurationElement(Decimal30_50.convertDecimal(src.getDurationElement())); 042 if (src.hasDurationMax()) tgt.setDurationMaxElement(Decimal30_50.convertDecimal(src.getDurationMaxElement())); 043 if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); 044 if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); 045 if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); 046 if (src.hasPeriod()) tgt.setPeriodElement(Decimal30_50.convertDecimal(src.getPeriodElement())); 047 if (src.hasPeriodMax()) tgt.setPeriodMaxElement(Decimal30_50.convertDecimal(src.getPeriodMaxElement())); 048 if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); 049 tgt.setDayOfWeek(src.getDayOfWeek().stream().map(Timing30_50::convertDayOfWeek).collect(Collectors.toList())); 050 if (src.hasWhen()) 051 tgt.setWhen(src.getWhen().stream().map(Timing30_50::convertEventTiming).collect(Collectors.toList())); 052 for (org.hl7.fhir.dstu3.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); 053 if (src.hasOffset()) tgt.setOffsetElement(UnsignedInt30_50.convertUnsignedInt(src.getOffsetElement())); 054 return tgt; 055 } 056 057 public static org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent convertTimingRepeatComponent(org.hl7.fhir.r5.model.Timing.TimingRepeatComponent src) throws FHIRException { 058 if (src == null) return null; 059 org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent tgt = new org.hl7.fhir.dstu3.model.Timing.TimingRepeatComponent(); 060 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 061 if (src.hasBounds()) 062 tgt.setBounds(ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().convertType(src.getBounds())); 063 if (src.hasCount()) tgt.setCount(src.getCount()); 064 if (src.hasCountMax()) tgt.setCountMax(src.getCountMax()); 065 if (src.hasDuration()) tgt.setDurationElement(Decimal30_50.convertDecimal(src.getDurationElement())); 066 if (src.hasDurationMax()) tgt.setDurationMaxElement(Decimal30_50.convertDecimal(src.getDurationMaxElement())); 067 if (src.hasDurationUnit()) tgt.setDurationUnitElement(convertUnitsOfTime(src.getDurationUnitElement())); 068 if (src.hasFrequency()) tgt.setFrequency(src.getFrequency()); 069 if (src.hasFrequencyMax()) tgt.setFrequencyMax(src.getFrequencyMax()); 070 if (src.hasPeriod()) tgt.setPeriodElement(Decimal30_50.convertDecimal(src.getPeriodElement())); 071 if (src.hasPeriodMax()) tgt.setPeriodMaxElement(Decimal30_50.convertDecimal(src.getPeriodMaxElement())); 072 if (src.hasPeriodUnit()) tgt.setPeriodUnitElement(convertUnitsOfTime(src.getPeriodUnitElement())); 073 tgt.setDayOfWeek(src.getDayOfWeek().stream().map(Timing30_50::convertDayOfWeek).collect(Collectors.toList())); 074 if (src.hasWhen()) 075 tgt.setWhen(src.getWhen().stream().map(Timing30_50::convertEventTiming).collect(Collectors.toList())); 076 for (org.hl7.fhir.r5.model.TimeType t : src.getTimeOfDay()) tgt.addTimeOfDay(t.getValue()); 077 if (src.hasOffset()) tgt.setOffsetElement(UnsignedInt30_50.convertUnsignedInt(src.getOffsetElement())); 078 return tgt; 079 } 080 081 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.UnitsOfTime> convertUnitsOfTime(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.UnitsOfTime> src) throws FHIRException { 082 if (src == null || src.isEmpty()) return null; 083 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()); 084 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 085 if (src.getValue() == null) { 086 tgt.setValue(null); 087} else { 088 switch(src.getValue()) { 089 case S: 090 tgt.setValue(Timing.UnitsOfTime.S); 091 break; 092 case MIN: 093 tgt.setValue(Timing.UnitsOfTime.MIN); 094 break; 095 case H: 096 tgt.setValue(Timing.UnitsOfTime.H); 097 break; 098 case D: 099 tgt.setValue(Timing.UnitsOfTime.D); 100 break; 101 case WK: 102 tgt.setValue(Timing.UnitsOfTime.WK); 103 break; 104 case MO: 105 tgt.setValue(Timing.UnitsOfTime.MO); 106 break; 107 case A: 108 tgt.setValue(Timing.UnitsOfTime.A); 109 break; 110 default: 111 tgt.setValue(Timing.UnitsOfTime.NULL); 112 break; 113 } 114} 115 return tgt; 116 } 117 118 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.UnitsOfTime> convertUnitsOfTime(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.UnitsOfTime> src) throws FHIRException { 119 if (src == null || src.isEmpty()) return null; 120 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.UnitsOfTime> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.UnitsOfTimeEnumFactory()); 121 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 122 if (src.getValue() == null) { 123 tgt.setValue(null); 124} else { 125 switch(src.getValue()) { 126 case S: 127 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.S); 128 break; 129 case MIN: 130 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MIN); 131 break; 132 case H: 133 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.H); 134 break; 135 case D: 136 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.D); 137 break; 138 case WK: 139 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.WK); 140 break; 141 case MO: 142 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.MO); 143 break; 144 case A: 145 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.A); 146 break; 147 default: 148 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.UnitsOfTime.NULL); 149 break; 150 } 151} 152 return tgt; 153 } 154 155 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> convertDayOfWeek(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.DayOfWeek> src) throws FHIRException { 156 if (src == null || src.isEmpty()) return null; 157 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.DaysOfWeekEnumFactory()); 158 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 159 if (src.getValue() == null) { 160 tgt.setValue(null); 161} else { 162 switch(src.getValue()) { 163 case MON: 164 tgt.setValue(Enumerations.DaysOfWeek.MON); 165 break; 166 case TUE: 167 tgt.setValue(Enumerations.DaysOfWeek.TUE); 168 break; 169 case WED: 170 tgt.setValue(Enumerations.DaysOfWeek.WED); 171 break; 172 case THU: 173 tgt.setValue(Enumerations.DaysOfWeek.THU); 174 break; 175 case FRI: 176 tgt.setValue(Enumerations.DaysOfWeek.FRI); 177 break; 178 case SAT: 179 tgt.setValue(Enumerations.DaysOfWeek.SAT); 180 break; 181 case SUN: 182 tgt.setValue(Enumerations.DaysOfWeek.SUN); 183 break; 184 default: 185 tgt.setValue(Enumerations.DaysOfWeek.NULL); 186 break; 187 } 188} 189 return tgt; 190 } 191 192 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.DayOfWeek> convertDayOfWeek(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.DaysOfWeek> src) throws FHIRException { 193 if (src == null || src.isEmpty()) return null; 194 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.DayOfWeek> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.DayOfWeekEnumFactory()); 195 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 196 if (src.getValue() == null) { 197 tgt.setValue(null); 198} else { 199 switch(src.getValue()) { 200 case MON: 201 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.MON); 202 break; 203 case TUE: 204 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.TUE); 205 break; 206 case WED: 207 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.WED); 208 break; 209 case THU: 210 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.THU); 211 break; 212 case FRI: 213 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.FRI); 214 break; 215 case SAT: 216 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SAT); 217 break; 218 case SUN: 219 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.SUN); 220 break; 221 default: 222 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.DayOfWeek.NULL); 223 break; 224 } 225} 226 return tgt; 227 } 228 229 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.EventTiming> convertEventTiming(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.EventTiming> src) throws FHIRException { 230 if (src == null || src.isEmpty()) return null; 231 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()); 232 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 233 if (src.getValue() == null) { 234 tgt.setValue(null); 235} else { 236 switch(src.getValue()) { 237 case MORN: 238 tgt.setValue(Timing.EventTiming.MORN); 239 break; 240 case AFT: 241 tgt.setValue(Timing.EventTiming.AFT); 242 break; 243 case EVE: 244 tgt.setValue(Timing.EventTiming.EVE); 245 break; 246 case NIGHT: 247 tgt.setValue(Timing.EventTiming.NIGHT); 248 break; 249 case PHS: 250 tgt.setValue(Timing.EventTiming.PHS); 251 break; 252 case HS: 253 tgt.setValue(Timing.EventTiming.HS); 254 break; 255 case WAKE: 256 tgt.setValue(Timing.EventTiming.WAKE); 257 break; 258 case C: 259 tgt.setValue(Timing.EventTiming.C); 260 break; 261 case CM: 262 tgt.setValue(Timing.EventTiming.CM); 263 break; 264 case CD: 265 tgt.setValue(Timing.EventTiming.CD); 266 break; 267 case CV: 268 tgt.setValue(Timing.EventTiming.CV); 269 break; 270 case AC: 271 tgt.setValue(Timing.EventTiming.AC); 272 break; 273 case ACM: 274 tgt.setValue(Timing.EventTiming.ACM); 275 break; 276 case ACD: 277 tgt.setValue(Timing.EventTiming.ACD); 278 break; 279 case ACV: 280 tgt.setValue(Timing.EventTiming.ACV); 281 break; 282 case PC: 283 tgt.setValue(Timing.EventTiming.PC); 284 break; 285 case PCM: 286 tgt.setValue(Timing.EventTiming.PCM); 287 break; 288 case PCD: 289 tgt.setValue(Timing.EventTiming.PCD); 290 break; 291 case PCV: 292 tgt.setValue(Timing.EventTiming.PCV); 293 break; 294 default: 295 tgt.setValue(Timing.EventTiming.NULL); 296 break; 297 } 298} 299 return tgt; 300 } 301 302 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.EventTiming> convertEventTiming(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Timing.EventTiming> src) throws FHIRException { 303 if (src == null || src.isEmpty()) return null; 304 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Timing.EventTiming> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Timing.EventTimingEnumFactory()); 305 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 306 if (src.getValue() == null) { 307 tgt.setValue(null); 308} else { 309 switch(src.getValue()) { 310 case MORN: 311 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.MORN); 312 break; 313 case AFT: 314 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AFT); 315 break; 316 case EVE: 317 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.EVE); 318 break; 319 case NIGHT: 320 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NIGHT); 321 break; 322 case PHS: 323 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PHS); 324 break; 325 case HS: 326 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.HS); 327 break; 328 case WAKE: 329 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.WAKE); 330 break; 331 case C: 332 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.C); 333 break; 334 case CM: 335 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CM); 336 break; 337 case CD: 338 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CD); 339 break; 340 case CV: 341 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.CV); 342 break; 343 case AC: 344 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.AC); 345 break; 346 case ACM: 347 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACM); 348 break; 349 case ACD: 350 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACD); 351 break; 352 case ACV: 353 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.ACV); 354 break; 355 case PC: 356 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PC); 357 break; 358 case PCM: 359 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCM); 360 break; 361 case PCD: 362 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCD); 363 break; 364 case PCV: 365 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.PCV); 366 break; 367 default: 368 tgt.setValue(org.hl7.fhir.dstu3.model.Timing.EventTiming.NULL); 369 break; 370 } 371} 372 return tgt; 373 } 374}