
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.Address43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Attachment43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.ContactPoint43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.HumanName43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Date43_50; 011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.Enumeration; 014import org.hl7.fhir.r5.model.Person; 015 016/* 017 Copyright (c) 2011+, HL7, Inc. 018 All rights reserved. 019 020 Redistribution and use in source and binary forms, with or without modification, 021 are permitted provided that the following conditions are met: 022 023 * Redistributions of source code must retain the above copyright notice, this 024 list of conditions and the following disclaimer. 025 * Redistributions in binary form must reproduce the above copyright notice, 026 this list of conditions and the following disclaimer in the documentation 027 and/or other materials provided with the distribution. 028 * Neither the name of HL7 nor the names of its contributors may be used to 029 endorse or promote products derived from this software without specific 030 prior written permission. 031 032 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 033 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 034 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 035 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 036 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 037 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 038 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 039 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 040 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 041 POSSIBILITY OF SUCH DAMAGE. 042 043*/ 044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 045public class Person43_50 { 046 047 public static org.hl7.fhir.r5.model.Person convertPerson(org.hl7.fhir.r4b.model.Person src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.Person tgt = new org.hl7.fhir.r5.model.Person(); 051 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 052 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 053 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 054 for (org.hl7.fhir.r4b.model.HumanName t : src.getName()) tgt.addName(HumanName43_50.convertHumanName(t)); 055 for (org.hl7.fhir.r4b.model.ContactPoint t : src.getTelecom()) 056 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 057 if (src.hasGender()) 058 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 059 if (src.hasBirthDate()) 060 tgt.setBirthDateElement(Date43_50.convertDate(src.getBirthDateElement())); 061 for (org.hl7.fhir.r4b.model.Address t : src.getAddress()) tgt.addAddress(Address43_50.convertAddress(t)); 062 if (src.hasPhoto()) 063 tgt.addPhoto(Attachment43_50.convertAttachment(src.getPhoto())); 064 if (src.hasManagingOrganization()) 065 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 066 if (src.hasActive()) 067 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 068 for (org.hl7.fhir.r4b.model.Person.PersonLinkComponent t : src.getLink()) tgt.addLink(convertPersonLinkComponent(t)); 069 return tgt; 070 } 071 072 public static org.hl7.fhir.r4b.model.Person convertPerson(org.hl7.fhir.r5.model.Person src) throws FHIRException { 073 if (src == null) 074 return null; 075 org.hl7.fhir.r4b.model.Person tgt = new org.hl7.fhir.r4b.model.Person(); 076 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 077 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 078 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 079 for (org.hl7.fhir.r5.model.HumanName t : src.getName()) tgt.addName(HumanName43_50.convertHumanName(t)); 080 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 081 tgt.addTelecom(ContactPoint43_50.convertContactPoint(t)); 082 if (src.hasGender()) 083 tgt.setGenderElement(Enumerations43_50.convertAdministrativeGender(src.getGenderElement())); 084 if (src.hasBirthDate()) 085 tgt.setBirthDateElement(Date43_50.convertDate(src.getBirthDateElement())); 086 for (org.hl7.fhir.r5.model.Address t : src.getAddress()) tgt.addAddress(Address43_50.convertAddress(t)); 087 if (src.hasPhoto()) 088 tgt.setPhoto(Attachment43_50.convertAttachment(src.getPhotoFirstRep())); 089 if (src.hasManagingOrganization()) 090 tgt.setManagingOrganization(Reference43_50.convertReference(src.getManagingOrganization())); 091 if (src.hasActive()) 092 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 093 for (org.hl7.fhir.r5.model.Person.PersonLinkComponent t : src.getLink()) tgt.addLink(convertPersonLinkComponent(t)); 094 return tgt; 095 } 096 097 public static org.hl7.fhir.r5.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.r4b.model.Person.PersonLinkComponent src) throws FHIRException { 098 if (src == null) 099 return null; 100 org.hl7.fhir.r5.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.r5.model.Person.PersonLinkComponent(); 101 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 102 if (src.hasTarget()) 103 tgt.setTarget(Reference43_50.convertReference(src.getTarget())); 104 if (src.hasAssurance()) 105 tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement())); 106 return tgt; 107 } 108 109 public static org.hl7.fhir.r4b.model.Person.PersonLinkComponent convertPersonLinkComponent(org.hl7.fhir.r5.model.Person.PersonLinkComponent src) throws FHIRException { 110 if (src == null) 111 return null; 112 org.hl7.fhir.r4b.model.Person.PersonLinkComponent tgt = new org.hl7.fhir.r4b.model.Person.PersonLinkComponent(); 113 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 114 if (src.hasTarget()) 115 tgt.setTarget(Reference43_50.convertReference(src.getTarget())); 116 if (src.hasAssurance()) 117 tgt.setAssuranceElement(convertIdentityAssuranceLevel(src.getAssuranceElement())); 118 return tgt; 119 } 120 121 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel> convertIdentityAssuranceLevel(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel> src) throws FHIRException { 122 if (src == null || src.isEmpty()) 123 return null; 124 Enumeration<Person.IdentityAssuranceLevel> tgt = new Enumeration<>(new Person.IdentityAssuranceLevelEnumFactory()); 125 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 126 if (src.getValue() == null) { 127 tgt.setValue(null); 128 } else { 129 switch (src.getValue()) { 130 case LEVEL1: 131 tgt.setValue(Person.IdentityAssuranceLevel.LEVEL1); 132 break; 133 case LEVEL2: 134 tgt.setValue(Person.IdentityAssuranceLevel.LEVEL2); 135 break; 136 case LEVEL3: 137 tgt.setValue(Person.IdentityAssuranceLevel.LEVEL3); 138 break; 139 case LEVEL4: 140 tgt.setValue(Person.IdentityAssuranceLevel.LEVEL4); 141 break; 142 default: 143 tgt.setValue(Person.IdentityAssuranceLevel.NULL); 144 break; 145 } 146 } 147 return tgt; 148 } 149 150 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel> convertIdentityAssuranceLevel(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Person.IdentityAssuranceLevel> src) throws FHIRException { 151 if (src == null || src.isEmpty()) 152 return null; 153 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevelEnumFactory()); 154 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 155 if (src.getValue() == null) { 156 tgt.setValue(null); 157 } else { 158 switch (src.getValue()) { 159 case LEVEL1: 160 tgt.setValue(org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel.LEVEL1); 161 break; 162 case LEVEL2: 163 tgt.setValue(org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel.LEVEL2); 164 break; 165 case LEVEL3: 166 tgt.setValue(org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel.LEVEL3); 167 break; 168 case LEVEL4: 169 tgt.setValue(org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel.LEVEL4); 170 break; 171 default: 172 tgt.setValue(org.hl7.fhir.r4b.model.Person.IdentityAssuranceLevel.NULL); 173 break; 174 } 175 } 176 return tgt; 177 } 178}