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.Annotation40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 009import org.hl7.fhir.exceptions.FHIRException; 010import org.hl7.fhir.r5.model.CodeableReference; 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 FamilyMemberHistory40_50 { 042 043 public static org.hl7.fhir.r5.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.r4.model.FamilyMemberHistory src) throws FHIRException { 044 if (src == null) 045 return null; 046 org.hl7.fhir.r5.model.FamilyMemberHistory tgt = new org.hl7.fhir.r5.model.FamilyMemberHistory(); 047 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 048 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 049 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 050 for (org.hl7.fhir.r4.model.CanonicalType t : src.getInstantiatesCanonical()) 051 tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t)); 052 for (org.hl7.fhir.r4.model.UriType t : src.getInstantiatesUri()) 053 tgt.getInstantiatesUri().add(Uri40_50.convertUri(t)); 054 if (src.hasStatus()) 055 tgt.setStatusElement(convertFamilyHistoryStatus(src.getStatusElement())); 056 if (src.hasDataAbsentReason()) 057 tgt.setDataAbsentReason(CodeableConcept40_50.convertCodeableConcept(src.getDataAbsentReason())); 058 if (src.hasPatient()) 059 tgt.setPatient(Reference40_50.convertReference(src.getPatient())); 060 if (src.hasDate()) 061 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 062 if (src.hasName()) 063 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 064 if (src.hasRelationship()) 065 tgt.setRelationship(CodeableConcept40_50.convertCodeableConcept(src.getRelationship())); 066 if (src.hasSex()) 067 tgt.setSex(CodeableConcept40_50.convertCodeableConcept(src.getSex())); 068 if (src.hasBorn()) 069 tgt.setBorn(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getBorn())); 070 if (src.hasAge()) 071 tgt.setAge(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAge())); 072 if (src.hasEstimatedAge()) 073 tgt.setEstimatedAgeElement(Boolean40_50.convertBoolean(src.getEstimatedAgeElement())); 074 if (src.hasDeceased()) 075 tgt.setDeceased(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDeceased())); 076 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode()) 077 tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t)); 078 for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference()) 079 tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t)); 080 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 081 for (org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition()) 082 tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t)); 083 return tgt; 084 } 085 086 public static org.hl7.fhir.r4.model.FamilyMemberHistory convertFamilyMemberHistory(org.hl7.fhir.r5.model.FamilyMemberHistory src) throws FHIRException { 087 if (src == null) 088 return null; 089 org.hl7.fhir.r4.model.FamilyMemberHistory tgt = new org.hl7.fhir.r4.model.FamilyMemberHistory(); 090 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 091 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 092 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 093 for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical()) 094 tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t)); 095 for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri()) 096 tgt.getInstantiatesUri().add(Uri40_50.convertUri(t)); 097 if (src.hasStatus()) 098 tgt.setStatusElement(convertFamilyHistoryStatus(src.getStatusElement())); 099 if (src.hasDataAbsentReason()) 100 tgt.setDataAbsentReason(CodeableConcept40_50.convertCodeableConcept(src.getDataAbsentReason())); 101 if (src.hasPatient()) 102 tgt.setPatient(Reference40_50.convertReference(src.getPatient())); 103 if (src.hasDate()) 104 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 105 if (src.hasName()) 106 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 107 if (src.hasRelationship()) 108 tgt.setRelationship(CodeableConcept40_50.convertCodeableConcept(src.getRelationship())); 109 if (src.hasSex()) 110 tgt.setSex(CodeableConcept40_50.convertCodeableConcept(src.getSex())); 111 if (src.hasBorn()) 112 tgt.setBorn(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getBorn())); 113 if (src.hasAge()) 114 tgt.setAge(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAge())); 115 if (src.hasEstimatedAge()) 116 tgt.setEstimatedAgeElement(Boolean40_50.convertBoolean(src.getEstimatedAgeElement())); 117 if (src.hasDeceased()) 118 tgt.setDeceased(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDeceased())); 119 for (CodeableReference t : src.getReason()) 120 if (t.hasConcept()) 121 tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 122 for (CodeableReference t : src.getReason()) 123 if (t.hasReference()) 124 tgt.addReasonReference(Reference40_50.convertReference(t.getReference())); 125 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 126 for (org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent t : src.getCondition()) 127 tgt.addCondition(convertFamilyMemberHistoryConditionComponent(t)); 128 return tgt; 129 } 130 131 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> convertFamilyHistoryStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus> src) throws FHIRException { 132 if (src == null || src.isEmpty()) 133 return null; 134 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatusEnumFactory()); 135 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 136 switch (src.getValue()) { 137 case PARTIAL: 138 tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL); 139 break; 140 case COMPLETED: 141 tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED); 142 break; 143 case ENTEREDINERROR: 144 tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR); 145 break; 146 case HEALTHUNKNOWN: 147 tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN); 148 break; 149 default: 150 tgt.setValue(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus.NULL); 151 break; 152 } 153 return tgt; 154 } 155 156 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus> convertFamilyHistoryStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyHistoryStatus> src) throws FHIRException { 157 if (src == null || src.isEmpty()) 158 return null; 159 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatusEnumFactory()); 160 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 161 switch (src.getValue()) { 162 case PARTIAL: 163 tgt.setValue(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.PARTIAL); 164 break; 165 case COMPLETED: 166 tgt.setValue(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.COMPLETED); 167 break; 168 case ENTEREDINERROR: 169 tgt.setValue(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.ENTEREDINERROR); 170 break; 171 case HEALTHUNKNOWN: 172 tgt.setValue(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.HEALTHUNKNOWN); 173 break; 174 default: 175 tgt.setValue(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyHistoryStatus.NULL); 176 break; 177 } 178 return tgt; 179 } 180 181 public static org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException { 182 if (src == null) 183 return null; 184 org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent(); 185 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 186 if (src.hasCode()) 187 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 188 if (src.hasOutcome()) 189 tgt.setOutcome(CodeableConcept40_50.convertCodeableConcept(src.getOutcome())); 190 if (src.hasContributedToDeath()) 191 tgt.setContributedToDeathElement(Boolean40_50.convertBoolean(src.getContributedToDeathElement())); 192 if (src.hasOnset()) 193 tgt.setOnset(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOnset())); 194 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 195 return tgt; 196 } 197 198 public static org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent convertFamilyMemberHistoryConditionComponent(org.hl7.fhir.r5.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent src) throws FHIRException { 199 if (src == null) 200 return null; 201 org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent tgt = new org.hl7.fhir.r4.model.FamilyMemberHistory.FamilyMemberHistoryConditionComponent(); 202 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 203 if (src.hasCode()) 204 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 205 if (src.hasOutcome()) 206 tgt.setOutcome(CodeableConcept40_50.convertCodeableConcept(src.getOutcome())); 207 if (src.hasContributedToDeath()) 208 tgt.setContributedToDeathElement(Boolean40_50.convertBoolean(src.getContributedToDeathElement())); 209 if (src.hasOnset()) 210 tgt.setOnset(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOnset())); 211 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 212 return tgt; 213 } 214}