
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.primitive43_50.Boolean43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.UnsignedInt43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 011import org.hl7.fhir.exceptions.FHIRException; 012import org.hl7.fhir.r5.model.Enumeration; 013import org.hl7.fhir.r5.model.Group; 014import org.hl7.fhir.r5.model.Group.GroupMembershipBasis; 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 Group43_50 { 046 047 public static org.hl7.fhir.r5.model.Group convertGroup(org.hl7.fhir.r4b.model.Group src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.Group tgt = new org.hl7.fhir.r5.model.Group(); 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 if (src.hasActive()) 055 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 056 if (src.hasType()) 057 tgt.setTypeElement(convertGroupType(src.getTypeElement())); 058 if (src.hasActual()) 059 tgt.setMembership(src.getActual() ? GroupMembershipBasis.ENUMERATED : GroupMembershipBasis.DEFINITIONAL); 060 if (src.hasCode()) 061 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 062 if (src.hasName()) 063 tgt.setNameElement(String43_50.convertString(src.getNameElement())); 064 if (src.hasQuantity()) 065 tgt.setQuantityElement(UnsignedInt43_50.convertUnsignedInt(src.getQuantityElement())); 066 if (src.hasManagingEntity()) 067 tgt.setManagingEntity(Reference43_50.convertReference(src.getManagingEntity())); 068 for (org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent t : src.getCharacteristic()) 069 tgt.addCharacteristic(convertGroupCharacteristicComponent(t)); 070 for (org.hl7.fhir.r4b.model.Group.GroupMemberComponent t : src.getMember()) 071 tgt.addMember(convertGroupMemberComponent(t)); 072 return tgt; 073 } 074 075 public static org.hl7.fhir.r4b.model.Group convertGroup(org.hl7.fhir.r5.model.Group src) throws FHIRException { 076 if (src == null) 077 return null; 078 org.hl7.fhir.r4b.model.Group tgt = new org.hl7.fhir.r4b.model.Group(); 079 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 080 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 081 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 082 if (src.hasActive()) 083 tgt.setActiveElement(Boolean43_50.convertBoolean(src.getActiveElement())); 084 if (src.hasType()) 085 tgt.setTypeElement(convertGroupType(src.getTypeElement())); 086 if (src.hasMembership()) 087 tgt.setActual(src.getMembership() == GroupMembershipBasis.ENUMERATED); 088 if (src.hasCode()) 089 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 090 if (src.hasName()) 091 tgt.setNameElement(String43_50.convertString(src.getNameElement())); 092 if (src.hasQuantity()) 093 tgt.setQuantityElement(UnsignedInt43_50.convertUnsignedInt(src.getQuantityElement())); 094 if (src.hasManagingEntity()) 095 tgt.setManagingEntity(Reference43_50.convertReference(src.getManagingEntity())); 096 for (org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent t : src.getCharacteristic()) 097 tgt.addCharacteristic(convertGroupCharacteristicComponent(t)); 098 for (org.hl7.fhir.r5.model.Group.GroupMemberComponent t : src.getMember()) 099 tgt.addMember(convertGroupMemberComponent(t)); 100 return tgt; 101 } 102 103 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> convertGroupType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> src) throws FHIRException { 104 if (src == null || src.isEmpty()) 105 return null; 106 Enumeration<Group.GroupType> tgt = new Enumeration<>(new Group.GroupTypeEnumFactory()); 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 PERSON: 113 tgt.setValue(Group.GroupType.PERSON); 114 break; 115 case ANIMAL: 116 tgt.setValue(Group.GroupType.ANIMAL); 117 break; 118 case PRACTITIONER: 119 tgt.setValue(Group.GroupType.PRACTITIONER); 120 break; 121 case DEVICE: 122 tgt.setValue(Group.GroupType.DEVICE); 123 break; 124 default: 125 tgt.setValue(Group.GroupType.NULL); 126 break; 127 } 128 } 129 return tgt; 130 } 131 132 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> convertGroupType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> src) throws FHIRException { 133 if (src == null || src.isEmpty()) 134 return null; 135 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Group.GroupType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Group.GroupTypeEnumFactory()); 136 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 137 if (src.getValue() == null) { 138 tgt.setValue(null); 139 } else { 140 switch (src.getValue()) { 141 case PERSON: 142 tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.PERSON); 143 break; 144 case ANIMAL: 145 tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.ANIMAL); 146 break; 147 case PRACTITIONER: 148 tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.PRACTITIONER); 149 break; 150 case DEVICE: 151 tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.DEVICE); 152 break; 153 default: 154 tgt.setValue(org.hl7.fhir.r4b.model.Group.GroupType.NULL); 155 break; 156 } 157 } 158 return tgt; 159 } 160 161 public static org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent src) throws FHIRException { 162 if (src == null) 163 return null; 164 org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent(); 165 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 166 if (src.hasCode()) 167 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 168 if (src.hasValue()) 169 tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue())); 170 if (src.hasExclude()) 171 tgt.setExcludeElement(Boolean43_50.convertBoolean(src.getExcludeElement())); 172 if (src.hasPeriod()) 173 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 174 return tgt; 175 } 176 177 public static org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent src) throws FHIRException { 178 if (src == null) 179 return null; 180 org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r4b.model.Group.GroupCharacteristicComponent(); 181 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 182 if (src.hasCode()) 183 tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode())); 184 if (src.hasValue()) 185 tgt.setValue(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getValue())); 186 if (src.hasExclude()) 187 tgt.setExcludeElement(Boolean43_50.convertBoolean(src.getExcludeElement())); 188 if (src.hasPeriod()) 189 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 190 return tgt; 191 } 192 193 public static org.hl7.fhir.r5.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r4b.model.Group.GroupMemberComponent src) throws FHIRException { 194 if (src == null) 195 return null; 196 org.hl7.fhir.r5.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r5.model.Group.GroupMemberComponent(); 197 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 198 if (src.hasEntity()) 199 tgt.setEntity(Reference43_50.convertReference(src.getEntity())); 200 if (src.hasPeriod()) 201 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 202 if (src.hasInactive()) 203 tgt.setInactiveElement(Boolean43_50.convertBoolean(src.getInactiveElement())); 204 return tgt; 205 } 206 207 public static org.hl7.fhir.r4b.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r5.model.Group.GroupMemberComponent src) throws FHIRException { 208 if (src == null) 209 return null; 210 org.hl7.fhir.r4b.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r4b.model.Group.GroupMemberComponent(); 211 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 212 if (src.hasEntity()) 213 tgt.setEntity(Reference43_50.convertReference(src.getEntity())); 214 if (src.hasPeriod()) 215 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 216 if (src.hasInactive()) 217 tgt.setInactiveElement(Boolean43_50.convertBoolean(src.getInactiveElement())); 218 return tgt; 219 } 220}