001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Period30_50; 008import org.hl7.fhir.exceptions.FHIRException; 009 010public class EpisodeOfCare30_50 { 011 012 public static org.hl7.fhir.dstu3.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.r5.model.EpisodeOfCare src) throws FHIRException { 013 if (src == null) 014 return null; 015 org.hl7.fhir.dstu3.model.EpisodeOfCare tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare(); 016 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 017 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 018 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 019 if (src.hasStatus()) 020 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 021 for (org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory()) 022 tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t)); 023 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getType()) 024 tgt.addType(CodeableConcept30_50.convertCodeableConcept(t)); 025 for (org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis()) 026 tgt.addDiagnosis(convertDiagnosisComponent(t)); 027 if (src.hasPatient()) 028 tgt.setPatient(Reference30_50.convertReference(src.getPatient())); 029 if (src.hasManagingOrganization()) 030 tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization())); 031 if (src.hasPeriod()) 032 tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod())); 033 for (org.hl7.fhir.r5.model.Reference t : src.getReferralRequest()) 034 tgt.addReferralRequest(Reference30_50.convertReference(t)); 035 if (src.hasCareManager()) 036 tgt.setCareManager(Reference30_50.convertReference(src.getCareManager())); 037 for (org.hl7.fhir.r5.model.Reference t : src.getCareTeam()) tgt.addTeam(Reference30_50.convertReference(t)); 038 for (org.hl7.fhir.r5.model.Reference t : src.getAccount()) tgt.addAccount(Reference30_50.convertReference(t)); 039 return tgt; 040 } 041 042 public static org.hl7.fhir.r5.model.EpisodeOfCare convertEpisodeOfCare(org.hl7.fhir.dstu3.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 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 047 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 048 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 049 if (src.hasStatus()) 050 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 051 for (org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent t : src.getStatusHistory()) 052 tgt.addStatusHistory(convertEpisodeOfCareStatusHistoryComponent(t)); 053 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getType()) 054 tgt.addType(CodeableConcept30_50.convertCodeableConcept(t)); 055 for (org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent t : src.getDiagnosis()) 056 tgt.addDiagnosis(convertDiagnosisComponent(t)); 057 if (src.hasPatient()) 058 tgt.setPatient(Reference30_50.convertReference(src.getPatient())); 059 if (src.hasManagingOrganization()) 060 tgt.setManagingOrganization(Reference30_50.convertReference(src.getManagingOrganization())); 061 if (src.hasPeriod()) 062 tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod())); 063 for (org.hl7.fhir.dstu3.model.Reference t : src.getReferralRequest()) 064 tgt.addReferralRequest(Reference30_50.convertReference(t)); 065 if (src.hasCareManager()) 066 tgt.setCareManager(Reference30_50.convertReference(src.getCareManager())); 067 for (org.hl7.fhir.dstu3.model.Reference t : src.getTeam()) tgt.addCareTeam(Reference30_50.convertReference(t)); 068 for (org.hl7.fhir.dstu3.model.Reference t : src.getAccount()) tgt.addAccount(Reference30_50.convertReference(t)); 069 return tgt; 070 } 071 072 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException { 073 if (src == null || src.isEmpty()) 074 return null; 075 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()); 076 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 077 switch (src.getValue()) { 078 case PLANNED: 079 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED); 080 break; 081 case WAITLIST: 082 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST); 083 break; 084 case ACTIVE: 085 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE); 086 break; 087 case ONHOLD: 088 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD); 089 break; 090 case FINISHED: 091 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED); 092 break; 093 case CANCELLED: 094 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED); 095 break; 096 case ENTEREDINERROR: 097 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR); 098 break; 099 default: 100 tgt.setValue(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus.NULL); 101 break; 102 } 103 return tgt; 104 } 105 106 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> convertEpisodeOfCareStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatus> src) throws FHIRException { 107 if (src == null || src.isEmpty()) 108 return null; 109 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusEnumFactory()); 110 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 111 switch (src.getValue()) { 112 case PLANNED: 113 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.PLANNED); 114 break; 115 case WAITLIST: 116 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.WAITLIST); 117 break; 118 case ACTIVE: 119 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ACTIVE); 120 break; 121 case ONHOLD: 122 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ONHOLD); 123 break; 124 case FINISHED: 125 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.FINISHED); 126 break; 127 case CANCELLED: 128 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.CANCELLED); 129 break; 130 case ENTEREDINERROR: 131 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.ENTEREDINERROR); 132 break; 133 default: 134 tgt.setValue(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatus.NULL); 135 break; 136 } 137 return tgt; 138 } 139 140 public static org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException { 141 if (src == null) 142 return null; 143 org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent(); 144 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 145 if (src.hasStatus()) 146 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 147 if (src.hasPeriod()) 148 tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod())); 149 return tgt; 150 } 151 152 public static org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent convertEpisodeOfCareStatusHistoryComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent src) throws FHIRException { 153 if (src == null) 154 return null; 155 org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.EpisodeOfCareStatusHistoryComponent(); 156 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 157 if (src.hasStatus()) 158 tgt.setStatusElement(convertEpisodeOfCareStatus(src.getStatusElement())); 159 if (src.hasPeriod()) 160 tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod())); 161 return tgt; 162 } 163 164 public static org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { 165 if (src == null) return null; 166 org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent(); 167 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 168 if (src.hasCondition()) tgt.addCondition(Reference30_50.convertReferenceToCodableReference(src.getCondition())); 169 if (src.hasRole()) tgt.setUse(CodeableConcept30_50.convertCodeableConcept(src.getRole())); 170// if (src.hasRank()) tgt.setRankElement(PositiveInt30_50.convertPositiveInt(src.getRankElement())); 171 return tgt; 172 } 173 174 public static org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent convertDiagnosisComponent(org.hl7.fhir.r5.model.EpisodeOfCare.DiagnosisComponent src) throws FHIRException { 175 if (src == null) return null; 176 org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent tgt = new org.hl7.fhir.dstu3.model.EpisodeOfCare.DiagnosisComponent(); 177 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt); 178 if (src.hasCondition()) tgt.setCondition(Reference30_50.convertCodeableReferenceToReference(src.getConditionFirstRep())); 179 if (src.hasUse()) tgt.setRole(CodeableConcept30_50.convertCodeableConcept(src.getUse())); 180// if (src.hasRank()) tgt.setRankElement(PositiveInt30_50.convertPositiveInt(src.getRankElement())); 181 return tgt; 182 } 183}