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