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