
001package org.hl7.fhir.convertors.conv14_30.resources14_30; 002 003import org.hl7.fhir.convertors.context.ConversionContext14_30; 004import org.hl7.fhir.convertors.conv14_30.VersionConvertor_14_30; 005import org.hl7.fhir.convertors.conv14_30.datatypes14_30.ElementDefinition14_30; 006import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.CodeableConcept14_30; 007import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.ContactPoint14_30; 008import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.Identifier14_30; 009import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Boolean14_30; 010import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.DateTime14_30; 011import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Id14_30; 012import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.String14_30; 013import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Uri14_30; 014import org.hl7.fhir.exceptions.FHIRException; 015 016public class DataElement14_30 { 017 018 public static org.hl7.fhir.dstu3.model.DataElement convertDataElement(org.hl7.fhir.dstu2016may.model.DataElement src) throws FHIRException { 019 if (src == null || src.isEmpty()) 020 return null; 021 org.hl7.fhir.dstu3.model.DataElement tgt = new org.hl7.fhir.dstu3.model.DataElement(); 022 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt); 023 if (src.hasUrl()) 024 tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement())); 025 for (org.hl7.fhir.dstu2016may.model.Identifier t : src.getIdentifier()) 026 tgt.addIdentifier(Identifier14_30.convertIdentifier(t)); 027 if (src.hasVersion()) 028 tgt.setVersionElement(String14_30.convertString(src.getVersionElement())); 029 if (src.hasStatus()) 030 tgt.setStatusElement(Enumerations14_30.convertConformanceResourceStatus(src.getStatusElement())); 031 if (src.hasExperimental()) 032 tgt.setExperimentalElement(Boolean14_30.convertBoolean(src.getExperimentalElement())); 033 if (src.hasPublisher()) 034 tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement())); 035 if (src.hasDate()) 036 tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement())); 037 if (src.hasName()) 038 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 039 for (org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent t : src.getContact()) 040 tgt.addContact(convertDataElementContactComponent(t)); 041 for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) 042 if (VersionConvertor_14_30.isJurisdiction(t)) 043 tgt.addJurisdiction(CodeableConcept14_30.convertCodeableConcept(t)); 044 else 045 tgt.addUseContext(CodeableConcept14_30.convertCodeableConceptToUsageContext(t)); 046 if (src.hasCopyright()) 047 tgt.setCopyright(src.getCopyright()); 048 if (src.hasStringency()) 049 tgt.setStringencyElement(convertDataElementStringency(src.getStringencyElement())); 050 for (org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent t : src.getMapping()) 051 tgt.addMapping(convertDataElementMappingComponent(t)); 052 for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement()) 053 tgt.addElement(ElementDefinition14_30.convertElementDefinition(t)); 054 return tgt; 055 } 056 057 public static org.hl7.fhir.dstu2016may.model.DataElement convertDataElement(org.hl7.fhir.dstu3.model.DataElement src) throws FHIRException { 058 if (src == null || src.isEmpty()) 059 return null; 060 org.hl7.fhir.dstu2016may.model.DataElement tgt = new org.hl7.fhir.dstu2016may.model.DataElement(); 061 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt); 062 if (src.hasUrl()) 063 tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement())); 064 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 065 tgt.addIdentifier(Identifier14_30.convertIdentifier(t)); 066 if (src.hasVersion()) 067 tgt.setVersionElement(String14_30.convertString(src.getVersionElement())); 068 if (src.hasStatus()) 069 tgt.setStatusElement(Enumerations14_30.convertConformanceResourceStatus(src.getStatusElement())); 070 if (src.hasExperimental()) 071 tgt.setExperimentalElement(Boolean14_30.convertBoolean(src.getExperimentalElement())); 072 if (src.hasPublisher()) 073 tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement())); 074 if (src.hasDate()) 075 tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement())); 076 if (src.hasName()) 077 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 078 for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) 079 tgt.addContact(convertDataElementContactComponent(t)); 080 for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) 081 if (t.hasValueCodeableConcept()) 082 tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t.getValueCodeableConcept())); 083 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) 084 tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t)); 085 if (src.hasCopyright()) 086 tgt.setCopyright(src.getCopyright()); 087 if (src.hasStringency()) 088 tgt.setStringencyElement(convertDataElementStringency(src.getStringencyElement())); 089 for (org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent t : src.getMapping()) 090 tgt.addMapping(convertDataElementMappingComponent(t)); 091 for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement()) 092 tgt.addElement(ElementDefinition14_30.convertElementDefinition(t)); 093 return tgt; 094 } 095 096 public static org.hl7.fhir.dstu3.model.ContactDetail convertDataElementContactComponent(org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent src) throws FHIRException { 097 if (src == null || src.isEmpty()) 098 return null; 099 org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); 100 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 101 if (src.hasName()) 102 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 103 for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) 104 tgt.addTelecom(ContactPoint14_30.convertContactPoint(t)); 105 return tgt; 106 } 107 108 public static org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent convertDataElementContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { 109 if (src == null || src.isEmpty()) 110 return null; 111 org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent tgt = new org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent(); 112 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 113 if (src.hasName()) 114 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 115 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 116 tgt.addTelecom(ContactPoint14_30.convertContactPoint(t)); 117 return tgt; 118 } 119 120 public static org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent src) throws FHIRException { 121 if (src == null || src.isEmpty()) 122 return null; 123 org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent(); 124 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyBackboneElement(src,tgt); 125 if (src.hasIdentityElement()) 126 tgt.setIdentityElement(Id14_30.convertId(src.getIdentityElement())); 127 if (src.hasUri()) 128 tgt.setUriElement(Uri14_30.convertUri(src.getUriElement())); 129 if (src.hasName()) 130 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 131 if (src.hasComment()) 132 tgt.setCommentElement(String14_30.convertString(src.getCommentElement())); 133 return tgt; 134 } 135 136 public static org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent src) throws FHIRException { 137 if (src == null || src.isEmpty()) 138 return null; 139 org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent(); 140 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyBackboneElement(src,tgt); 141 if (src.hasIdentityElement()) 142 tgt.setIdentityElement(Id14_30.convertId(src.getIdentityElement())); 143 if (src.hasUri()) 144 tgt.setUriElement(Uri14_30.convertUri(src.getUriElement())); 145 if (src.hasName()) 146 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 147 if (src.hasComment()) 148 tgt.setCommentElement(String14_30.convertString(src.getCommentElement())); 149 return tgt; 150 } 151 152 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> convertDataElementStringency(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> src) throws FHIRException { 153 if (src == null || src.isEmpty()) 154 return null; 155 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DataElement.DataElementStringencyEnumFactory()); 156 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 157 switch (src.getValue()) { 158 case COMPARABLE: 159 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.COMPARABLE); 160 break; 161 case FULLYSPECIFIED: 162 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FULLYSPECIFIED); 163 break; 164 case EQUIVALENT: 165 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.EQUIVALENT); 166 break; 167 case CONVERTABLE: 168 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.CONVERTABLE); 169 break; 170 case SCALEABLE: 171 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.SCALEABLE); 172 break; 173 case FLEXIBLE: 174 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FLEXIBLE); 175 break; 176 default: 177 tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.NULL); 178 break; 179 } 180 return tgt; 181 } 182 183 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> convertDataElementStringency(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> src) throws FHIRException { 184 if (src == null || src.isEmpty()) 185 return null; 186 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringencyEnumFactory()); 187 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 188 switch (src.getValue()) { 189 case COMPARABLE: 190 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.COMPARABLE); 191 break; 192 case FULLYSPECIFIED: 193 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.FULLYSPECIFIED); 194 break; 195 case EQUIVALENT: 196 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.EQUIVALENT); 197 break; 198 case CONVERTABLE: 199 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.CONVERTABLE); 200 break; 201 case SCALEABLE: 202 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.SCALEABLE); 203 break; 204 case FLEXIBLE: 205 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.FLEXIBLE); 206 break; 207 default: 208 tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.NULL); 209 break; 210 } 211 return tgt; 212 } 213}