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.Period40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50; 011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 012import org.hl7.fhir.exceptions.FHIRException; 013 014/* 015 Copyright (c) 2011+, HL7, Inc. 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without modification, 019 are permitted provided that the following conditions are met: 020 021 * Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 * Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 * Neither the name of HL7 nor the names of its contributors may be used to 027 endorse or promote products derived from this software without specific 028 prior written permission. 029 030 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 031 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 032 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 033 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 034 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 035 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 036 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 037 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 039 POSSIBILITY OF SUCH DAMAGE. 040 041*/ 042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 043public class NamingSystem40_50 { 044 045 public static org.hl7.fhir.r5.model.NamingSystem convertNamingSystem(org.hl7.fhir.r4.model.NamingSystem src) throws FHIRException { 046 if (src == null) 047 return null; 048 org.hl7.fhir.r5.model.NamingSystem tgt = new org.hl7.fhir.r5.model.NamingSystem(); 049 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 050 if (src.hasName()) 051 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 052 if (src.hasStatus()) 053 tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement())); 054 if (src.hasKind()) 055 tgt.setKindElement(convertNamingSystemType(src.getKindElement())); 056 if (src.hasDate()) 057 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 058 if (src.hasPublisher()) 059 tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement())); 060 for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) 061 tgt.addContact(ContactDetail40_50.convertContactDetail(t)); 062 if (src.hasResponsible()) 063 tgt.setResponsibleElement(String40_50.convertString(src.getResponsibleElement())); 064 if (src.hasType()) 065 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 066 if (src.hasDescription()) 067 tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement())); 068 for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) 069 tgt.addUseContext(UsageContext40_50.convertUsageContext(t)); 070 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) 071 tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t)); 072 if (src.hasUsage()) 073 tgt.setUsageElement(String40_50.convertString(src.getUsageElement())); 074 for (org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) 075 tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); 076 return tgt; 077 } 078 079 public static org.hl7.fhir.r4.model.NamingSystem convertNamingSystem(org.hl7.fhir.r5.model.NamingSystem src) throws FHIRException { 080 if (src == null) 081 return null; 082 org.hl7.fhir.r4.model.NamingSystem tgt = new org.hl7.fhir.r4.model.NamingSystem(); 083 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 084 if (src.hasName()) 085 tgt.setNameElement(String40_50.convertString(src.getNameElement())); 086 if (src.hasStatus()) 087 tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement())); 088 if (src.hasKind()) 089 tgt.setKindElement(convertNamingSystemType(src.getKindElement())); 090 if (src.hasDate()) 091 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 092 if (src.hasPublisher()) 093 tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement())); 094 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 095 tgt.addContact(ContactDetail40_50.convertContactDetail(t)); 096 if (src.hasResponsible()) 097 tgt.setResponsibleElement(String40_50.convertString(src.getResponsibleElement())); 098 if (src.hasType()) 099 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 100 if (src.hasDescription()) 101 tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement())); 102 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 103 tgt.addUseContext(UsageContext40_50.convertUsageContext(t)); 104 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) 105 tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t)); 106 if (src.hasUsage()) 107 tgt.setUsageElement(String40_50.convertString(src.getUsageElement())); 108 for (org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) 109 tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); 110 return tgt; 111 } 112 113 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemType> src) throws FHIRException { 114 if (src == null || src.isEmpty()) 115 return null; 116 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.NamingSystem.NamingSystemTypeEnumFactory()); 117 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 118 switch (src.getValue()) { 119 case CODESYSTEM: 120 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.CODESYSTEM); 121 break; 122 case IDENTIFIER: 123 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.IDENTIFIER); 124 break; 125 case ROOT: 126 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.ROOT); 127 break; 128 default: 129 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.NULL); 130 break; 131 } 132 return tgt; 133 } 134 135 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> src) throws FHIRException { 136 if (src == null || src.isEmpty()) 137 return null; 138 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.NamingSystem.NamingSystemTypeEnumFactory()); 139 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 140 switch (src.getValue()) { 141 case CODESYSTEM: 142 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.CODESYSTEM); 143 break; 144 case IDENTIFIER: 145 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.IDENTIFIER); 146 break; 147 case ROOT: 148 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.ROOT); 149 break; 150 default: 151 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemType.NULL); 152 break; 153 } 154 return tgt; 155 } 156 157 public static org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { 158 if (src == null) 159 return null; 160 org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent(); 161 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 162 if (src.hasType()) 163 tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement())); 164 if (src.hasValue()) 165 tgt.setValueElement(String40_50.convertString(src.getValueElement())); 166 if (src.hasPreferred()) 167 tgt.setPreferredElement(Boolean40_50.convertBoolean(src.getPreferredElement())); 168 if (src.hasComment()) 169 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 170 if (src.hasPeriod()) 171 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 172 return tgt; 173 } 174 175 public static org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { 176 if (src == null) 177 return null; 178 org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r4.model.NamingSystem.NamingSystemUniqueIdComponent(); 179 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 180 if (src.hasType()) 181 tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement())); 182 if (src.hasValue()) 183 tgt.setValueElement(String40_50.convertString(src.getValueElement())); 184 if (src.hasPreferred()) 185 tgt.setPreferredElement(Boolean40_50.convertBoolean(src.getPreferredElement())); 186 if (src.hasComment()) 187 tgt.setCommentElement(String40_50.convertString(src.getCommentElement())); 188 if (src.hasPeriod()) 189 tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod())); 190 return tgt; 191 } 192 193 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException { 194 if (src == null || src.isEmpty()) 195 return null; 196 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory()); 197 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 198 switch (src.getValue()) { 199 case OID: 200 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OID); 201 break; 202 case UUID: 203 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.UUID); 204 break; 205 case URI: 206 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.URI); 207 break; 208 case OTHER: 209 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OTHER); 210 break; 211 default: 212 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.NULL); 213 break; 214 } 215 return tgt; 216 } 217 218 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException { 219 if (src == null || src.isEmpty()) 220 return null; 221 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory()); 222 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 223 switch (src.getValue()) { 224 case OID: 225 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OID); 226 break; 227 case UUID: 228 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.UUID); 229 break; 230 case URI: 231 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.URI); 232 break; 233 case OTHER: 234 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.OTHER); 235 break; 236 default: 237 tgt.setValue(org.hl7.fhir.r4.model.NamingSystem.NamingSystemIdentifierType.NULL); 238 break; 239 } 240 return tgt; 241 } 242}