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