
001package org.hl7.fhir.convertors.conv43_50.resources43_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext43_50; 004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 008import org.hl7.fhir.exceptions.FHIRException; 009import org.hl7.fhir.r5.model.Enumeration; 010import org.hl7.fhir.r5.model.EpisodeOfCare; 011 012/* 013 Copyright (c) 2011+, HL7, Inc. 014 All rights reserved. 015 016 Redistribution and use in source and binary forms, with or without modification, 017 are permitted provided that the following conditions are met: 018 019 * Redistributions of source code must retain the above copyright notice, this 020 list of conditions and the following disclaimer. 021 * Redistributions in binary form must reproduce the above copyright notice, 022 this list of conditions and the following disclaimer in the documentation 023 and/or other materials provided with the distribution. 024 * Neither the name of HL7 nor the names of its contributors may be used to 025 endorse or promote products derived from this software without specific 026 prior written permission. 027 028 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 029 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 030 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 031 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 032 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 033 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 034 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 035 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 036 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 037 POSSIBILITY OF SUCH DAMAGE. 038 039*/ 040// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 041public class EpisodeOfCare43_50 { 042 043 public static org.hl7.fhir.r5.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.r4b.model.EpisodeOfCare src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.EpisodeOfCare tgt = new org.hl7.fhir.r5.model.EpisodeOfCare(); 047 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 050 if (src.hasStatus()) 051 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 052 for (org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory()) 053 tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t)); 054 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getType()) 055 tgt.addType(CodeableConcept43_50.convertCodeableConcept(t)); 056 for (org.hl7.fhir.r4b.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis()) 057 tgt.addDiagnosis(convertDiagnosisComponent(t)); 058 if (src.hasPatient()) 059 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 060 if (src.hasManagingOrganization()) 061 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 062 if (src.hasPeriod()) 063 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 064 for (org.hl7.fhir.r4b.model.Reference t : src.getReferralRequest()) 065 tgt.addReferralRequest(Reference43_50.convertReference(t)); 066 if (src.hasCareManager()) 067 tgt.setCareManager(Reference43_50.convertReference(src.getCareManager())); 068 for (org.hl7.fhir.r4b.model.Reference t : src.getTeam()) tgt.addCareTeam(Reference43_50.convertReference(t)); 069 for (org.hl7.fhir.r4b.model.Reference t : src.getAccount()) tgt.addAccount(Reference43_50.convertReference(t)); 070 return tgt; 071 } 072 073 public static org.hl7.fhir.r4b.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.r5.model.EpisodeOfCare src) throws FHIRException { 074 if (src == null) 075 return null; 076 org.hl7.fhir.r4b.model.EpisodeOfCare tgt = new org.hl7.fhir.r4b.model.EpisodeOfCare(); 077 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 078 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 079 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 080 if (src.hasStatus()) 081 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 082 for (org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory()) 083 tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t)); 084 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 085 tgt.addType(CodeableConcept43_50.convertCodeableConcept(t)); 086 for (org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis()) 087 tgt.addDiagnosis(convertDiagnosisComponent(t)); 088 if (src.hasPatient()) 089 tgt.setPatient(Reference43_50.convertReference(src.getPatient())); 090 if (src.hasManagingOrganization()) 091 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 092 if (src.hasPeriod()) 093 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 094 for (org.hl7.fhir.r5.model.Reference t : src.getReferralRequest()) 095 tgt.addReferralRequest(Reference43_50.convertReference(t)); 096 if (src.hasCareManager()) 097 tgt.setCareManager(Reference43_50.convertReference(src.getCareManager())); 098 for (org.hl7.fhir.r5.model.Reference t : src.getCareTeam()) tgt.addTeam(Reference43_50.convertReference(t)); 099 for (org.hl7.fhir.r5.model.Reference t : src.getAccount()) tgt.addAccount(Reference43_50.convertReference(t)); 100 return tgt; 101 } 102 103 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException { 104 if (src == null || src.isEmpty()) 105 return null; 106 Enumeration<EpisodeOfCare.EpisodeOfCareStatus> tgt = new Enumeration<>(new EpisodeOfCare.EpisodeOfCareStatusEnumFactory()); 107 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 108 if (src.getValue() == null) { 109 tgt.setValue(null); 110 } else { 111 switch (src.getValue()) { 112 case PLANNED: 113 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.PLANNED); 114 break; 115 case WAITLIST: 116 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.WAITLIST); 117 break; 118 case ACTIVE: 119 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.ACTIVE); 120 break; 121 case ONHOLD: 122 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.ONHOLD); 123 break; 124 case FINISHED: 125 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.FINISHED); 126 break; 127 case CANCELLED: 128 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.CANCELLED); 129 break; 130 case ENTEREDINERROR: 131 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR); 132 break; 133 default: 134 tgt.setValue(EpisodeOfCare.EpisodeOfCareStatus.NULL); 135 break; 136 } 137 } 138 return tgt; 139 } 140 141 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException { 142 if (src == null || src.isEmpty()) 143 return null; 144 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusEnumFactory()); 145 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 146 if (src.getValue() == null) { 147 tgt.setValue(null); 148 } else { 149 switch (src.getValue()) { 150 case PLANNED: 151 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED); 152 break; 153 case WAITLIST: 154 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST); 155 break; 156 case ACTIVE: 157 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE); 158 break; 159 case ONHOLD: 160 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD); 161 break; 162 case FINISHED: 163 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED); 164 break; 165 case CANCELLED: 166 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED); 167 break; 168 case ENTEREDINERROR: 169 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR); 170 break; 171 default: 172 tgt.setValue(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatus.NULL); 173 break; 174 } 175 } 176 return tgt; 177 } 178 179 public static org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException { 180 if (src == null) 181 return null; 182 org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent(); 183 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 184 if (src.hasStatus()) 185 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 186 if (src.hasPeriod()) 187 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 188 return tgt; 189 } 190 191 public static org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException { 192 if (src == null) 193 return null; 194 org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.r4b.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent(); 195 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 196 if (src.hasStatus()) 197 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 198 if (src.hasPeriod()) 199 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 200 return tgt; 201 } 202 203 public static org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r4b.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { 204 if (src == null) 205 return null; 206 org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent(); 207 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 208 if (src.hasCondition()) 209 tgt.addCondition(Reference43_50.convertReferenceToCodeableReference(src.getCondition())); 210 if (src.hasRole()) 211 tgt.setUse(CodeableConcept43_50.convertCodeableConcept(src.getRole())); 212// if (src.hasRank()) 213// tgt.setRankElement(PositiveInt43_50.convertPositiveInt(src.getRankElement())); 214 return tgt; 215 } 216 217 public static org.hl7.fhir.r4b.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { 218 if (src == null) 219 return null; 220 org.hl7.fhir.r4b.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r4b.model.EpisodeOfCare.DiagnosisComponent(); 221 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 222 if (src.hasCondition()) 223 tgt.setCondition(Reference43_50.convertCodeableReferenceToReference(src.getConditionFirstRep())); 224 if (src.hasUse()) 225 tgt.setRole(CodeableConcept43_50.convertCodeableConcept(src.getUse())); 226// if (src.hasRank()) 227// tgt.setRankElement(PositiveInt43_50.convertPositiveInt(src.getRankElement())); 228 return tgt; 229 } 230}