001package org.hl7.fhir.convertors.conv10_30.resources10_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext10_30; 004import org.hl7.fhir.convertors.conv10_30.datatypes10_30.Reference10_30; 005import org.hl7.fhir.convertors.conv10_30.datatypes10_30.complextypes10_30.*; 006import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.Boolean10_30; 007import org.hl7.fhir.convertors.conv10_30.datatypes10_30.primitivetypes10_30.String10_30; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class CarePlan10_30 { 011 012 public static org.hl7.fhir.dstu3.model.CarePlan convertCarePlan(org.hl7.fhir.dstu2.model.CarePlan src) throws FHIRException { 013 if (src == null || src.isEmpty()) 014 return null; 015 org.hl7.fhir.dstu3.model.CarePlan tgt = new org.hl7.fhir.dstu3.model.CarePlan(); 016 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 017 for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) 018 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 019 if (src.hasSubject()) 020 tgt.setSubject(Reference10_30.convertReference(src.getSubject())); 021 if (src.hasStatus()) 022 tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement())); 023 if (src.hasContext()) 024 tgt.setContext(Reference10_30.convertReference(src.getContext())); 025 if (src.hasPeriod()) 026 tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod())); 027 for (org.hl7.fhir.dstu2.model.Reference t : src.getAuthor()) tgt.addAuthor(Reference10_30.convertReference(t)); 028 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getCategory()) 029 tgt.addCategory(CodeableConcept10_30.convertCodeableConcept(t)); 030 if (src.hasDescriptionElement()) 031 tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 032 for (org.hl7.fhir.dstu2.model.Reference t : src.getAddresses()) 033 tgt.addAddresses(Reference10_30.convertReference(t)); 034 for (org.hl7.fhir.dstu2.model.Reference t : src.getGoal()) tgt.addGoal(Reference10_30.convertReference(t)); 035 for (org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent t : src.getActivity()) 036 tgt.addActivity(convertCarePlanActivityComponent(t)); 037 return tgt; 038 } 039 040 public static org.hl7.fhir.dstu2.model.CarePlan convertCarePlan(org.hl7.fhir.dstu3.model.CarePlan src) throws FHIRException { 041 if (src == null || src.isEmpty()) 042 return null; 043 org.hl7.fhir.dstu2.model.CarePlan tgt = new org.hl7.fhir.dstu2.model.CarePlan(); 044 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyDomainResource(src, tgt); 045 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 046 tgt.addIdentifier(Identifier10_30.convertIdentifier(t)); 047 if (src.hasSubject()) 048 tgt.setSubject(Reference10_30.convertReference(src.getSubject())); 049 if (src.hasStatus()) 050 tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement())); 051 if (src.hasContext()) 052 tgt.setContext(Reference10_30.convertReference(src.getContext())); 053 if (src.hasPeriod()) 054 tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod())); 055 for (org.hl7.fhir.dstu3.model.Reference t : src.getAuthor()) tgt.addAuthor(Reference10_30.convertReference(t)); 056 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getCategory()) 057 tgt.addCategory(CodeableConcept10_30.convertCodeableConcept(t)); 058 if (src.hasDescriptionElement()) 059 tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 060 for (org.hl7.fhir.dstu3.model.Reference t : src.getAddresses()) 061 tgt.addAddresses(Reference10_30.convertReference(t)); 062 for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal()) tgt.addGoal(Reference10_30.convertReference(t)); 063 for (org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent t : src.getActivity()) 064 tgt.addActivity(convertCarePlanActivityComponent(t)); 065 return tgt; 066 } 067 068 public static org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent src) throws FHIRException { 069 if (src == null || src.isEmpty()) 070 return null; 071 org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent(); 072 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 073 for (org.hl7.fhir.dstu3.model.Annotation t : src.getProgress()) 074 tgt.addProgress(Annotation10_30.convertAnnotation(t)); 075 if (src.hasReference()) 076 tgt.setReference(Reference10_30.convertReference(src.getReference())); 077 if (src.hasDetail()) 078 tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail())); 079 return tgt; 080 } 081 082 public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityComponent src) throws FHIRException { 083 if (src == null || src.isEmpty()) 084 return null; 085 org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityComponent(); 086 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 087 for (org.hl7.fhir.dstu2.model.Annotation t : src.getProgress()) 088 tgt.addProgress(Annotation10_30.convertAnnotation(t)); 089 if (src.hasReference()) 090 tgt.setReference(Reference10_30.convertReference(src.getReference())); 091 if (src.hasDetail()) 092 tgt.setDetail(convertCarePlanActivityDetailComponent(src.getDetail())); 093 return tgt; 094 } 095 096 public static org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException { 097 if (src == null || src.isEmpty()) 098 return null; 099 org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent(); 100 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 101 if (src.hasCategory()) 102 tgt.setCategory(CodeableConcept10_30.convertCodeableConcept(src.getCategory())); 103 if (src.hasCode()) 104 tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode())); 105 for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getReasonCode()) 106 tgt.addReasonCode(CodeableConcept10_30.convertCodeableConcept(t)); 107 for (org.hl7.fhir.dstu2.model.Reference t : src.getReasonReference()) 108 tgt.addReasonReference(Reference10_30.convertReference(t)); 109 for (org.hl7.fhir.dstu2.model.Reference t : src.getGoal()) tgt.addGoal(Reference10_30.convertReference(t)); 110 if (src.hasStatus()) 111 tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement())); 112 if (src.hasProhibitedElement()) 113 tgt.setProhibitedElement(Boolean10_30.convertBoolean(src.getProhibitedElement())); 114 if (src.hasScheduled()) 115 tgt.setScheduled(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getScheduled())); 116 if (src.hasLocation()) 117 tgt.setLocation(Reference10_30.convertReference(src.getLocation())); 118 for (org.hl7.fhir.dstu2.model.Reference t : src.getPerformer()) 119 tgt.addPerformer(Reference10_30.convertReference(t)); 120 if (src.hasProduct()) 121 tgt.setProduct(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getProduct())); 122 if (src.hasDailyAmount()) 123 tgt.setDailyAmount(SimpleQuantity10_30.convertSimpleQuantity(src.getDailyAmount())); 124 if (src.hasQuantity()) 125 tgt.setQuantity(SimpleQuantity10_30.convertSimpleQuantity(src.getQuantity())); 126 if (src.hasDescriptionElement()) 127 tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 128 return tgt; 129 } 130 131 public static org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException { 132 if (src == null || src.isEmpty()) 133 return null; 134 org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityDetailComponent(); 135 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 136 if (src.hasCategory()) 137 tgt.setCategory(CodeableConcept10_30.convertCodeableConcept(src.getCategory())); 138 if (src.hasCode()) 139 tgt.setCode(CodeableConcept10_30.convertCodeableConcept(src.getCode())); 140 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getReasonCode()) 141 tgt.addReasonCode(CodeableConcept10_30.convertCodeableConcept(t)); 142 for (org.hl7.fhir.dstu3.model.Reference t : src.getReasonReference()) 143 tgt.addReasonReference(Reference10_30.convertReference(t)); 144 for (org.hl7.fhir.dstu3.model.Reference t : src.getGoal()) tgt.addGoal(Reference10_30.convertReference(t)); 145 if (src.hasStatus()) 146 tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement())); 147 if (src.hasProhibitedElement()) 148 tgt.setProhibitedElement(Boolean10_30.convertBoolean(src.getProhibitedElement())); 149 if (src.hasScheduled()) 150 tgt.setScheduled(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getScheduled())); 151 if (src.hasLocation()) 152 tgt.setLocation(Reference10_30.convertReference(src.getLocation())); 153 for (org.hl7.fhir.dstu3.model.Reference t : src.getPerformer()) 154 tgt.addPerformer(Reference10_30.convertReference(t)); 155 if (src.hasProduct()) 156 tgt.setProduct(ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().convertType(src.getProduct())); 157 if (src.hasDailyAmount()) 158 tgt.setDailyAmount(SimpleQuantity10_30.convertSimpleQuantity(src.getDailyAmount())); 159 if (src.hasQuantity()) 160 tgt.setQuantity(SimpleQuantity10_30.convertSimpleQuantity(src.getQuantity())); 161 if (src.hasDescriptionElement()) 162 tgt.setDescriptionElement(String10_30.convertString(src.getDescriptionElement())); 163 return tgt; 164 } 165 166 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException { 167 if (src == null || src.isEmpty()) 168 return null; 169 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatusEnumFactory()); 170 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 171 switch (src.getValue()) { 172 case NOTSTARTED: 173 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.NOTSTARTED); 174 break; 175 case SCHEDULED: 176 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.SCHEDULED); 177 break; 178 case INPROGRESS: 179 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.INPROGRESS); 180 break; 181 case ONHOLD: 182 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.ONHOLD); 183 break; 184 case COMPLETED: 185 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.COMPLETED); 186 break; 187 case CANCELLED: 188 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.CANCELLED); 189 break; 190 default: 191 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus.NULL); 192 break; 193 } 194 return tgt; 195 } 196 197 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException { 198 if (src == null || src.isEmpty()) 199 return null; 200 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatusEnumFactory()); 201 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 202 switch (src.getValue()) { 203 case NOTSTARTED: 204 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NOTSTARTED); 205 break; 206 case SCHEDULED: 207 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.SCHEDULED); 208 break; 209 case INPROGRESS: 210 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.INPROGRESS); 211 break; 212 case ONHOLD: 213 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.ONHOLD); 214 break; 215 case COMPLETED: 216 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.COMPLETED); 217 break; 218 case CANCELLED: 219 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.CANCELLED); 220 break; 221 default: 222 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanActivityStatus.NULL); 223 break; 224 } 225 return tgt; 226 } 227 228 static public org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> convertCarePlanStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> src) throws FHIRException { 229 if (src == null || src.isEmpty()) 230 return null; 231 org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> tgt = new org.hl7.fhir.dstu2.model.Enumeration<>(new org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatusEnumFactory()); 232 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 233 switch (src.getValue()) { 234 case DRAFT: 235 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.DRAFT); 236 break; 237 case ACTIVE: 238 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.ACTIVE); 239 break; 240 case COMPLETED: 241 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.COMPLETED); 242 break; 243 case CANCELLED: 244 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.CANCELLED); 245 break; 246 default: 247 tgt.setValue(org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus.NULL); 248 break; 249 } 250 return tgt; 251 } 252 253 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> convertCarePlanStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.CarePlan.CarePlanStatus> src) throws FHIRException { 254 if (src == null || src.isEmpty()) 255 return null; 256 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatusEnumFactory()); 257 ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt); 258 switch (src.getValue()) { 259 case PROPOSED: 260 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.DRAFT); 261 break; 262 case DRAFT: 263 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.DRAFT); 264 break; 265 case ACTIVE: 266 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.ACTIVE); 267 break; 268 case COMPLETED: 269 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.COMPLETED); 270 break; 271 case CANCELLED: 272 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.CANCELLED); 273 break; 274 default: 275 tgt.setValue(org.hl7.fhir.dstu3.model.CarePlan.CarePlanStatus.NULL); 276 break; 277 } 278 return tgt; 279 } 280}