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