![](/hapi-fhir/images/logos/raccoon-forwards.png)
001package org.hl7.fhir.convertors.conv14_40.resources14_40; 002 003import org.hl7.fhir.convertors.VersionConvertorConstants; 004import org.hl7.fhir.convertors.context.ConversionContext14_40; 005import org.hl7.fhir.convertors.conv14_40.VersionConvertor_14_40; 006import org.hl7.fhir.convertors.conv14_40.datatypes14_40.Reference14_40; 007import org.hl7.fhir.convertors.conv14_40.datatypes14_40.complextypes14_40.CodeableConcept14_40; 008import org.hl7.fhir.convertors.conv14_40.datatypes14_40.complextypes14_40.ContactPoint14_40; 009import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Boolean14_40; 010import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Code14_40; 011import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.DateTime14_40; 012import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Integer14_40; 013import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.String14_40; 014import org.hl7.fhir.convertors.conv14_40.datatypes14_40.primitivetypes14_40.Uri14_40; 015import org.hl7.fhir.exceptions.FHIRException; 016import org.hl7.fhir.r4.model.Type; 017 018public class OperationDefinition14_40 { 019 020 public static org.hl7.fhir.r4.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.dstu2016may.model.OperationDefinition src) throws FHIRException { 021 if (src == null || src.isEmpty()) 022 return null; 023 org.hl7.fhir.r4.model.OperationDefinition tgt = new org.hl7.fhir.r4.model.OperationDefinition(); 024 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt); 025 if (src.hasUrl()) 026 tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement())); 027 if (src.hasVersion()) 028 tgt.setVersionElement(String14_40.convertString(src.getVersionElement())); 029 if (src.hasNameElement()) 030 tgt.setNameElement(String14_40.convertString(src.getNameElement())); 031 if (src.hasStatus()) 032 tgt.setStatusElement(Enumerations14_40.convertConformanceResourceStatus(src.getStatusElement())); 033 if (src.hasKind()) 034 tgt.setKindElement(convertOperationKind(src.getKindElement())); 035 if (src.hasExperimental()) 036 tgt.setExperimentalElement(Boolean14_40.convertBoolean(src.getExperimentalElement())); 037 if (src.hasDate()) 038 tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement())); 039 if (src.hasPublisher()) 040 tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement())); 041 for (org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionContactComponent t : src.getContact()) 042 tgt.addContact(convertOperationDefinitionContactComponent(t)); 043 if (src.hasDescription()) 044 tgt.setDescription(src.getDescription()); 045 for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) 046 if (VersionConvertor_14_40.isJurisdiction(t)) 047 tgt.addJurisdiction(CodeableConcept14_40.convertCodeableConcept(t)); 048 else 049 tgt.addUseContext(CodeableConcept14_40.convertCodeableConceptToUsageContext(t)); 050 if (src.hasRequirements()) 051 tgt.setPurpose(src.getRequirements()); 052 if (src.hasIdempotent()) 053 tgt.setAffectsState(!src.getIdempotent()); 054 if (src.hasCodeElement()) 055 tgt.setCodeElement(Code14_40.convertCode(src.getCodeElement())); 056 if (src.hasComment()) 057 tgt.setComment(src.getComment()); 058 if (src.hasBase()) 059 tgt.setBaseElement(Reference14_40.convertReferenceToCanonical(src.getBase())); 060 if (src.hasSystemElement()) 061 tgt.setSystemElement(Boolean14_40.convertBoolean(src.getSystemElement())); 062 for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getType()) tgt.addResource(t.getValue()); 063 tgt.setType(tgt.hasResource()); 064 if (src.hasInstanceElement()) 065 tgt.setInstanceElement(Boolean14_40.convertBoolean(src.getInstanceElement())); 066 for (org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) 067 tgt.addParameter(convertOperationDefinitionParameterComponent(t)); 068 return tgt; 069 } 070 071 public static org.hl7.fhir.dstu2016may.model.OperationDefinition convertOperationDefinition(org.hl7.fhir.r4.model.OperationDefinition src) throws FHIRException { 072 if (src == null || src.isEmpty()) 073 return null; 074 org.hl7.fhir.dstu2016may.model.OperationDefinition tgt = new org.hl7.fhir.dstu2016may.model.OperationDefinition(); 075 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyDomainResource(src, tgt); 076 if (src.hasUrl()) 077 tgt.setUrlElement(Uri14_40.convertUri(src.getUrlElement())); 078 if (src.hasVersion()) 079 tgt.setVersionElement(String14_40.convertString(src.getVersionElement())); 080 if (src.hasNameElement()) 081 tgt.setNameElement(String14_40.convertString(src.getNameElement())); 082 if (src.hasStatus()) 083 tgt.setStatusElement(Enumerations14_40.convertConformanceResourceStatus(src.getStatusElement())); 084 if (src.hasKind()) 085 tgt.setKindElement(convertOperationKind(src.getKindElement())); 086 if (src.hasExperimental()) 087 tgt.setExperimentalElement(Boolean14_40.convertBoolean(src.getExperimentalElement())); 088 if (src.hasDate()) 089 tgt.setDateElement(DateTime14_40.convertDateTime(src.getDateElement())); 090 if (src.hasPublisher()) 091 tgt.setPublisherElement(String14_40.convertString(src.getPublisherElement())); 092 for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact()) 093 tgt.addContact(convertOperationDefinitionContactComponent(t)); 094 if (src.hasDescription()) 095 tgt.setDescription(src.getDescription()); 096 for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext()) 097 if (t.hasValueCodeableConcept()) 098 tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t.getValueCodeableConcept())); 099 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction()) 100 tgt.addUseContext(CodeableConcept14_40.convertCodeableConcept(t)); 101 if (src.hasPurpose()) 102 tgt.setRequirements(src.getPurpose()); 103 if (src.hasAffectsState()) 104 tgt.setIdempotent(!src.getAffectsState()); 105 if (src.hasCodeElement()) 106 tgt.setCodeElement(Code14_40.convertCode(src.getCodeElement())); 107 if (src.hasComment()) 108 tgt.setComment(src.getComment()); 109 if (src.hasBaseElement()) 110 tgt.setBase(Reference14_40.convertCanonicalToReference(src.getBaseElement())); 111 if (src.hasSystemElement()) 112 tgt.setSystemElement(Boolean14_40.convertBoolean(src.getSystemElement())); 113 if (src.getType()) 114 for (org.hl7.fhir.r4.model.CodeType t : src.getResource()) tgt.addType(t.getValue()); 115 if (src.hasInstanceElement()) 116 tgt.setInstanceElement(Boolean14_40.convertBoolean(src.getInstanceElement())); 117 for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getParameter()) 118 tgt.addParameter(convertOperationDefinitionParameterComponent(t)); 119 return tgt; 120 } 121 122 public static org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionContactComponent convertOperationDefinitionContactComponent(org.hl7.fhir.r4.model.ContactDetail src) throws FHIRException { 123 if (src == null || src.isEmpty()) 124 return null; 125 org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionContactComponent tgt = new org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionContactComponent(); 126 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 127 if (src.hasName()) 128 tgt.setNameElement(String14_40.convertString(src.getNameElement())); 129 for (org.hl7.fhir.r4.model.ContactPoint t : src.getTelecom()) 130 tgt.addTelecom(ContactPoint14_40.convertContactPoint(t)); 131 return tgt; 132 } 133 134 public static org.hl7.fhir.r4.model.ContactDetail convertOperationDefinitionContactComponent(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionContactComponent src) throws FHIRException { 135 if (src == null || src.isEmpty()) 136 return null; 137 org.hl7.fhir.r4.model.ContactDetail tgt = new org.hl7.fhir.r4.model.ContactDetail(); 138 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 139 if (src.hasName()) 140 tgt.setNameElement(String14_40.convertString(src.getNameElement())); 141 for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) 142 tgt.addTelecom(ContactPoint14_40.convertContactPoint(t)); 143 return tgt; 144 } 145 146 public static org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { 147 if (src == null || src.isEmpty()) 148 return null; 149 org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); 150 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyBackboneElement(src,tgt); 151 if (src.hasStrength()) 152 tgt.setStrengthElement(Enumerations14_40.convertBindingStrength(src.getStrengthElement())); 153 Type t = ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().convertType(src.getValueSet()); 154 if (t != null) { 155 if (t instanceof org.hl7.fhir.r4.model.Reference) 156 tgt.setValueSet(((org.hl7.fhir.r4.model.Reference) t).getReference()); 157 else 158 tgt.setValueSet(t.primitiveValue()); 159 tgt.setValueSet(VersionConvertorConstants.refToVS(tgt.getValueSet())); 160 } 161 return tgt; 162 } 163 164 public static org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterBindingComponent convertOperationDefinitionParameterBindingComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterBindingComponent src) throws FHIRException { 165 if (src == null || src.isEmpty()) 166 return null; 167 org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterBindingComponent tgt = new org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterBindingComponent(); 168 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyBackboneElement(src,tgt); 169 if (src.hasStrength()) 170 tgt.setStrengthElement(Enumerations14_40.convertBindingStrength(src.getStrengthElement())); 171 if (src.hasValueSet()) { 172 String vsr = VersionConvertorConstants.vsToRef(src.getValueSet()); 173 if (vsr != null) 174 tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.UriType(vsr)); 175 else 176 tgt.setValueSet(new org.hl7.fhir.dstu2016may.model.Reference(src.getValueSet())); 177 } 178 return tgt; 179 } 180 181 public static org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { 182 if (src == null || src.isEmpty()) 183 return null; 184 org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent(); 185 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyBackboneElement(src,tgt); 186 if (src.hasNameElement()) 187 tgt.setNameElement(Code14_40.convertCode(src.getNameElement())); 188 if (src.hasUse()) 189 tgt.setUseElement(convertOperationParameterUse(src.getUseElement())); 190 if (src.hasMinElement()) 191 tgt.setMinElement(Integer14_40.convertInteger(src.getMinElement())); 192 if (src.hasMaxElement()) 193 tgt.setMaxElement(String14_40.convertString(src.getMaxElement())); 194 if (src.hasDocumentation()) 195 tgt.setDocumentationElement(String14_40.convertString(src.getDocumentationElement())); 196 if (src.hasType()) 197 tgt.setTypeElement(Code14_40.convertCode(src.getTypeElement())); 198 if (src.hasSearchType()) 199 tgt.setSearchTypeElement(Enumerations14_40.convertSearchParamType(src.getSearchTypeElement())); 200 tgt.addTargetProfile(src.getProfile().getReference()); 201 if (src.hasBinding()) 202 tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); 203 for (org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) 204 tgt.addPart(convertOperationDefinitionParameterComponent(t)); 205 return tgt; 206 } 207 208 public static org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent convertOperationDefinitionParameterComponent(org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent src) throws FHIRException { 209 if (src == null || src.isEmpty()) 210 return null; 211 org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent tgt = new org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationDefinitionParameterComponent(); 212 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyBackboneElement(src,tgt); 213 if (src.hasNameElement()) 214 tgt.setNameElement(Code14_40.convertCode(src.getNameElement())); 215 if (src.hasUse()) 216 tgt.setUseElement(convertOperationParameterUse(src.getUseElement())); 217 if (src.hasMinElement()) 218 tgt.setMinElement(Integer14_40.convertInteger(src.getMinElement())); 219 if (src.hasMaxElement()) 220 tgt.setMaxElement(String14_40.convertString(src.getMaxElement())); 221 if (src.hasDocumentation()) 222 tgt.setDocumentationElement(String14_40.convertString(src.getDocumentationElement())); 223 if (src.hasType()) 224 tgt.setTypeElement(Code14_40.convertCode(src.getTypeElement())); 225 if (src.hasSearchType()) 226 tgt.setSearchTypeElement(Enumerations14_40.convertSearchParamType(src.getSearchTypeElement())); 227 for (org.hl7.fhir.r4.model.UriType t : src.getTargetProfile()) 228 tgt.setProfile(new org.hl7.fhir.dstu2016may.model.Reference(t.getValue())); 229 if (src.hasBinding()) 230 tgt.setBinding(convertOperationDefinitionParameterBindingComponent(src.getBinding())); 231 for (org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent t : src.getPart()) 232 tgt.addPart(convertOperationDefinitionParameterComponent(t)); 233 return tgt; 234 } 235 236 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind> convertOperationKind(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationKind> src) throws FHIRException { 237 if (src == null || src.isEmpty()) 238 return null; 239 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKindEnumFactory()); 240 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 241 switch (src.getValue()) { 242 case OPERATION: 243 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind.OPERATION); 244 break; 245 case QUERY: 246 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind.QUERY); 247 break; 248 default: 249 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind.NULL); 250 break; 251 } 252 return tgt; 253 } 254 255 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationKind> convertOperationKind(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationKind> src) throws FHIRException { 256 if (src == null || src.isEmpty()) 257 return null; 258 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationKind> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.OperationDefinition.OperationKindEnumFactory()); 259 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 260 switch (src.getValue()) { 261 case OPERATION: 262 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationKind.OPERATION); 263 break; 264 case QUERY: 265 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationKind.QUERY); 266 break; 267 default: 268 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationKind.NULL); 269 break; 270 } 271 return tgt; 272 } 273 274 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse> convertOperationParameterUse(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse> src) throws FHIRException { 275 if (src == null || src.isEmpty()) 276 return null; 277 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUseEnumFactory()); 278 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 279 switch (src.getValue()) { 280 case IN: 281 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse.IN); 282 break; 283 case OUT: 284 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse.OUT); 285 break; 286 default: 287 tgt.setValue(org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse.NULL); 288 break; 289 } 290 return tgt; 291 } 292 293 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse> convertOperationParameterUse(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.OperationDefinition.OperationParameterUse> src) throws FHIRException { 294 if (src == null || src.isEmpty()) 295 return null; 296 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUseEnumFactory()); 297 ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt); 298 switch (src.getValue()) { 299 case IN: 300 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.IN); 301 break; 302 case OUT: 303 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.OUT); 304 break; 305 default: 306 tgt.setValue(org.hl7.fhir.r4.model.OperationDefinition.OperationParameterUse.NULL); 307 break; 308 } 309 return tgt; 310 } 311}