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.Boolean40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.UnsignedInt40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 011import org.hl7.fhir.exceptions.FHIRException; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 040*/ 041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 042public class Group40_50 { 043 044 public static org.hl7.fhir.r5.model.Group convertGroup(org.hl7.fhir.r4.model.Group src) throws FHIRException { 045 if (src == null) 046 return null; 047 org.hl7.fhir.r5.model.Group tgt = new org.hl7.fhir.r5.model.Group(); 048 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 049 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 050 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 051 if (src.hasActive()) 052 tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement())); 053 if (src.hasType()) 054 tgt.setTypeElement(convertGroupType(src.getTypeElement())); 055 if (src.hasActual()) 056 tgt.setActualElement(Boolean40_50.convertBoolean(src.getActualElement())); 057 if (src.hasCode()) 058 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 059 if (src.hasName()) 060 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 061 if (src.hasQuantity()) 062 tgt.setQuantityElement(UnsignedInt40_50.convertUnsignedInt(src.getQuantityElement())); 063 if (src.hasManagingEntity()) 064 tgt.setManagingEntity(Reference40_50.convertReference(src.getManagingEntity())); 065 for (org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent t : src.getCharacteristic()) 066 tgt.addCharacteristic(convertGroupCharacteristicComponent(t)); 067 for (org.hl7.fhir.r4.model.Group.GroupMemberComponent t : src.getMember()) 068 tgt.addMember(convertGroupMemberComponent(t)); 069 return tgt; 070 } 071 072 public static org.hl7.fhir.r4.model.Group convertGroup(org.hl7.fhir.r5.model.Group src) throws FHIRException { 073 if (src == null) 074 return null; 075 org.hl7.fhir.r4.model.Group tgt = new org.hl7.fhir.r4.model.Group(); 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.hasActive()) 080 tgt.setActiveElement(Boolean40_50.convertBoolean(src.getActiveElement())); 081 if (src.hasType()) 082 tgt.setTypeElement(convertGroupType(src.getTypeElement())); 083 if (src.hasActual()) 084 tgt.setActualElement(Boolean40_50.convertBoolean(src.getActualElement())); 085 if (src.hasCode()) 086 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 087 if (src.hasName()) 088 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 089 if (src.hasQuantity()) 090 tgt.setQuantityElement(UnsignedInt40_50.convertUnsignedInt(src.getQuantityElement())); 091 if (src.hasManagingEntity()) 092 tgt.setManagingEntity(Reference40_50.convertReference(src.getManagingEntity())); 093 for (org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent t : src.getCharacteristic()) 094 tgt.addCharacteristic(convertGroupCharacteristicComponent(t)); 095 for (org.hl7.fhir.r5.model.Group.GroupMemberComponent t : src.getMember()) 096 tgt.addMember(convertGroupMemberComponent(t)); 097 return tgt; 098 } 099 100 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> convertGroupType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> src) throws FHIRException { 101 if (src == null || src.isEmpty()) 102 return null; 103 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Group.GroupTypeEnumFactory()); 104 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 105 switch (src.getValue()) { 106 case PERSON: 107 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PERSON); 108 break; 109 case ANIMAL: 110 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.ANIMAL); 111 break; 112 case PRACTITIONER: 113 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.PRACTITIONER); 114 break; 115 case DEVICE: 116 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.DEVICE); 117 break; 118 case MEDICATION: 119 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.MEDICATION); 120 break; 121 case SUBSTANCE: 122 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.SUBSTANCE); 123 break; 124 default: 125 tgt.setValue(org.hl7.fhir.r5.model.Group.GroupType.NULL); 126 break; 127 } 128 return tgt; 129 } 130 131 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> convertGroupType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Group.GroupType> src) throws FHIRException { 132 if (src == null || src.isEmpty()) 133 return null; 134 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Group.GroupType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Group.GroupTypeEnumFactory()); 135 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 136 switch (src.getValue()) { 137 case PERSON: 138 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.PERSON); 139 break; 140 case ANIMAL: 141 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.ANIMAL); 142 break; 143 case PRACTITIONER: 144 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.PRACTITIONER); 145 break; 146 case DEVICE: 147 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.DEVICE); 148 break; 149 case MEDICATION: 150 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.MEDICATION); 151 break; 152 case SUBSTANCE: 153 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.SUBSTANCE); 154 break; 155 default: 156 tgt.setValue(org.hl7.fhir.r4.model.Group.GroupType.NULL); 157 break; 158 } 159 return tgt; 160 } 161 162 public static org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent src) throws FHIRException { 163 if (src == null) 164 return null; 165 org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent(); 166 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 167 if (src.hasCode()) 168 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 169 if (src.hasValue()) 170 tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue())); 171 if (src.hasExclude()) 172 tgt.setExcludeElement(Boolean40_50.convertBoolean(src.getExcludeElement())); 173 if (src.hasPeriod()) 174 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 175 return tgt; 176 } 177 178 public static org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent convertGroupCharacteristicComponent(org.hl7.fhir.r5.model.Group.GroupCharacteristicComponent src) throws FHIRException { 179 if (src == null) 180 return null; 181 org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent tgt = new org.hl7.fhir.r4.model.Group.GroupCharacteristicComponent(); 182 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 183 if (src.hasCode()) 184 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 185 if (src.hasValue()) 186 tgt.setValue(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getValue())); 187 if (src.hasExclude()) 188 tgt.setExcludeElement(Boolean40_50.convertBoolean(src.getExcludeElement())); 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.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r4.model.Group.GroupMemberComponent src) throws FHIRException { 195 if (src == null) 196 return null; 197 org.hl7.fhir.r5.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r5.model.Group.GroupMemberComponent(); 198 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 199 if (src.hasEntity()) 200 tgt.setEntity(Reference40_50.convertReference(src.getEntity())); 201 if (src.hasPeriod()) 202 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 203 if (src.hasInactive()) 204 tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement())); 205 return tgt; 206 } 207 208 public static org.hl7.fhir.r4.model.Group.GroupMemberComponent convertGroupMemberComponent(org.hl7.fhir.r5.model.Group.GroupMemberComponent src) throws FHIRException { 209 if (src == null) 210 return null; 211 org.hl7.fhir.r4.model.Group.GroupMemberComponent tgt = new org.hl7.fhir.r4.model.Group.GroupMemberComponent(); 212 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 213 if (src.hasEntity()) 214 tgt.setEntity(Reference40_50.convertReference(src.getEntity())); 215 if (src.hasPeriod()) 216 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 217 if (src.hasInactive()) 218 tgt.setInactiveElement(Boolean40_50.convertBoolean(src.getInactiveElement())); 219 return tgt; 220 } 221}