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