![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.convertors.conv14_50.resources14_50; 002 003import org.hl7.fhir.convertors.VersionConvertorConstants; 004import org.hl7.fhir.convertors.context.ConversionContext14_50; 005import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.CodeableConcept14_50; 006import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.ContactPoint14_50; 007import org.hl7.fhir.convertors.conv14_50.datatypes14_50.complextypes14_50.Period14_50; 008import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Boolean14_50; 009import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.DateTime14_50; 010import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.String14_50; 011import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Uri14_50; 012import org.hl7.fhir.dstu2016may.model.Extension; 013import org.hl7.fhir.dstu2016may.model.StringType; 014import org.hl7.fhir.exceptions.FHIRException; 015 016public class NamingSystem14_50 { 017 018 public static org.hl7.fhir.r5.model.NamingSystem convertNamingSystem(org.hl7.fhir.dstu2016may.model.NamingSystem src) throws FHIRException { 019 if (src == null || src.isEmpty()) 020 return null; 021 022 org.hl7.fhir.r5.model.NamingSystem tgt = new org.hl7.fhir.r5.model.NamingSystem(); 023 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt, VersionConvertorConstants.EXT_NAMINGSYSTEM_URL, VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION, VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE); 024 if (src.hasNameElement()) 025 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 026 if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE)) { 027 tgt.setTitleElement(String14_50.convertString((StringType) src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).getValue())); 028 } 029 if (src.hasStatus()) 030 tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement())); 031 if (src.hasKind()) 032 tgt.setKindElement(convertNamingSystemType(src.getKindElement())); 033 if (src.hasDateElement()) 034 tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement())); 035 if (src.hasPublisher()) 036 tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement())); 037 for (org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemContactComponent t : src.getContact()) 038 tgt.addContact(convertNamingSystemContactComponent(t)); 039 if (src.hasResponsible()) 040 tgt.setResponsibleElement(String14_50.convertString(src.getResponsibleElement())); 041 if (src.hasType()) 042 tgt.setType(CodeableConcept14_50.convertCodeableConcept(src.getType())); 043 if (src.hasDescription()) 044 tgt.setDescription(src.getDescription()); 045 for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) 046 if (CodeableConcept14_50.isJurisdiction(t)) 047 tgt.addJurisdiction(CodeableConcept14_50.convertCodeableConcept(t)); 048 else 049 tgt.addUseContext(CodeableConcept14_50.convertCodeableConceptToUsageContext(t)); 050 if (src.hasUsage()) 051 tgt.setUsageElement(String14_50.convertString(src.getUsageElement())); 052 for (org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) 053 tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); 054 return tgt; 055 } 056 057 public static org.hl7.fhir.dstu2016may.model.NamingSystem convertNamingSystem(org.hl7.fhir.r5.model.NamingSystem src) throws FHIRException { 058 if (src == null || src.isEmpty()) 059 return null; 060 org.hl7.fhir.dstu2016may.model.NamingSystem tgt = new org.hl7.fhir.dstu2016may.model.NamingSystem(); 061 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt); 062 if (src.hasUrlElement()) 063 tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL).setValue(Uri14_50.convertUri(src.getUrlElement()))); 064 if (src.hasVersionElement()) 065 tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION).setValue(String14_50.convertString(src.getVersionElement()))); 066 067 if (src.hasNameElement()) 068 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 069 if (src.hasTitleElement()) 070 tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).setValue(String14_50.convertString(src.getTitleElement()))); 071 if (src.hasStatus()) 072 tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement())); 073 if (src.hasKind()) 074 tgt.setKindElement(convertNamingSystemType(src.getKindElement())); 075 if (src.hasDateElement()) 076 tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement())); 077 if (src.hasPublisher()) 078 tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement())); 079 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 080 tgt.addContact(convertNamingSystemContactComponent(t)); 081 if (src.hasResponsible()) 082 tgt.setResponsibleElement(String14_50.convertString(src.getResponsibleElement())); 083 if (src.hasType()) 084 tgt.setType(CodeableConcept14_50.convertCodeableConcept(src.getType())); 085 if (src.hasDescription()) 086 tgt.setDescription(src.getDescription()); 087 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 088 if (t.hasValueCodeableConcept()) 089 tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept())); 090 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) 091 tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t)); 092 if (src.hasUsage()) 093 tgt.setUsageElement(String14_50.convertString(src.getUsageElement())); 094 for (org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId()) 095 tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t)); 096 return tgt; 097 } 098 099 public static org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemContactComponent convertNamingSystemContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { 100 if (src == null || src.isEmpty()) 101 return null; 102 org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemContactComponent tgt = new org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemContactComponent(); 103 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 104 if (src.hasName()) 105 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 106 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 107 tgt.addTelecom(ContactPoint14_50.convertContactPoint(t)); 108 return tgt; 109 } 110 111 public static org.hl7.fhir.r5.model.ContactDetail convertNamingSystemContactComponent(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemContactComponent src) throws FHIRException { 112 if (src == null || src.isEmpty()) 113 return null; 114 org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); 115 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 116 if (src.hasName()) 117 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 118 for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) 119 tgt.addTelecom(ContactPoint14_50.convertContactPoint(t)); 120 return tgt; 121 } 122 123 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException { 124 if (src == null || src.isEmpty()) 125 return null; 126 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()); 127 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 128 switch (src.getValue()) { 129 case OID: 130 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OID); 131 break; 132 case UUID: 133 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.UUID); 134 break; 135 case URI: 136 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.URI); 137 break; 138 case OTHER: 139 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OTHER); 140 break; 141 default: 142 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.NULL); 143 break; 144 } 145 return tgt; 146 } 147 148 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException { 149 if (src == null || src.isEmpty()) 150 return null; 151 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory()); 152 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 153 switch (src.getValue()) { 154 case OID: 155 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType.OID); 156 break; 157 case UUID: 158 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType.UUID); 159 break; 160 case URI: 161 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType.URI); 162 break; 163 case OTHER: 164 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType.OTHER); 165 break; 166 default: 167 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemIdentifierType.NULL); 168 break; 169 } 170 return tgt; 171 } 172 173 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> src) throws FHIRException { 174 if (src == null || src.isEmpty()) 175 return null; 176 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemTypeEnumFactory()); 177 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 178 switch (src.getValue()) { 179 case CODESYSTEM: 180 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType.CODESYSTEM); 181 break; 182 case IDENTIFIER: 183 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType.IDENTIFIER); 184 break; 185 case ROOT: 186 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType.ROOT); 187 break; 188 default: 189 tgt.setValue(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType.NULL); 190 break; 191 } 192 return tgt; 193 } 194 195 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemType> src) throws FHIRException { 196 if (src == null || src.isEmpty()) 197 return null; 198 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()); 199 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 200 switch (src.getValue()) { 201 case CODESYSTEM: 202 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.CODESYSTEM); 203 break; 204 case IDENTIFIER: 205 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.IDENTIFIER); 206 break; 207 case ROOT: 208 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.ROOT); 209 break; 210 default: 211 tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.NULL); 212 break; 213 } 214 return tgt; 215 } 216 217 public static org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { 218 if (src == null || src.isEmpty()) 219 return null; 220 org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemUniqueIdComponent(); 221 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt); 222 if (src.hasType()) 223 tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement())); 224 if (src.hasValueElement()) 225 tgt.setValueElement(String14_50.convertString(src.getValueElement())); 226 if (src.hasPreferred()) 227 tgt.setPreferredElement(Boolean14_50.convertBoolean(src.getPreferredElement())); 228 if (src.hasPeriod()) 229 tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod())); 230 return tgt; 231 } 232 233 public static org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.dstu2016may.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException { 234 if (src == null || src.isEmpty()) 235 return null; 236 org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent(); 237 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyBackboneElement(src,tgt); 238 if (src.hasType()) 239 tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement())); 240 if (src.hasValueElement()) 241 tgt.setValueElement(String14_50.convertString(src.getValueElement())); 242 if (src.hasPreferred()) 243 tgt.setPreferredElement(Boolean14_50.convertBoolean(src.getPreferredElement())); 244 if (src.hasPeriod()) 245 tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod())); 246 return tgt; 247 } 248}