
001package org.hl7.fhir.convertors.conv14_50.resources14_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext14_50; 004import org.hl7.fhir.convertors.conv14_50.datatypes14_50.ElementDefinition14_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.primitivetypes14_50.Boolean14_50; 008import org.hl7.fhir.convertors.conv14_50.datatypes14_50.primitivetypes14_50.Code14_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.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.Enumeration; 014import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAll; 015import org.hl7.fhir.r5.model.Enumerations.VersionIndependentResourceTypesAllEnumFactory; 016 017public class SearchParameter14_50 { 018 019 public static org.hl7.fhir.dstu2016may.model.SearchParameter convertSearchParameter(org.hl7.fhir.r5.model.SearchParameter src) throws FHIRException { 020 if (src == null || src.isEmpty()) 021 return null; 022 org.hl7.fhir.dstu2016may.model.SearchParameter tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter(); 023 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt); 024 if (src.hasUrlElement()) 025 tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement())); 026 if (src.hasNameElement()) 027 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 028 if (src.hasStatus()) 029 tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement())); 030 if (src.hasExperimental()) 031 tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement())); 032 if (src.hasDate()) 033 tgt.setDateElement(DateTime14_50.convertDateTime(src.getDateElement())); 034 if (src.hasPublisher()) 035 tgt.setPublisherElement(String14_50.convertString(src.getPublisherElement())); 036 for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact()) 037 tgt.addContact(convertSearchParameterContactComponent(t)); 038 for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext()) 039 if (t.hasValueCodeableConcept()) 040 tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t.getValueCodeableConcept())); 041 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction()) 042 tgt.addUseContext(CodeableConcept14_50.convertCodeableConcept(t)); 043 if (src.hasPurpose()) 044 tgt.setRequirements(src.getPurpose()); 045 if (src.hasCodeElement()) 046 tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); 047 for (Enumeration<VersionIndependentResourceTypesAll> t : src.getBase()) tgt.setBaseElement(Code14_50.convertCode(t.getCodeType())); 048 if (src.hasType()) 049 tgt.setTypeElement(Enumerations14_50.convertSearchParamType(src.getTypeElement())); 050 if (src.hasDescription()) 051 tgt.setDescription(src.getDescription()); 052 if (src.hasExpression()) 053 tgt.setExpression(ElementDefinition14_50.convertTo2016MayExpression(src.getExpression())); 054// if (src.hasXpath()) 055// tgt.setXpathElement(String14_50.convertString(src.getXpathElement())); 056 if (src.hasProcessingMode()) 057 tgt.setXpathUsageElement(convertXPathUsageType(src.getProcessingModeElement())); 058 for (Enumeration<VersionIndependentResourceTypesAll> t : src.getTarget()) tgt.getTarget().add(Code14_50.convertCode(t.getCodeType())); 059 return tgt; 060 } 061 062 public static org.hl7.fhir.r5.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu2016may.model.SearchParameter src) throws FHIRException { 063 if (src == null || src.isEmpty()) 064 return null; 065 org.hl7.fhir.r5.model.SearchParameter tgt = new org.hl7.fhir.r5.model.SearchParameter(); 066 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyDomainResource(src, tgt); 067 if (src.hasUrlElement()) 068 tgt.setUrlElement(Uri14_50.convertUri(src.getUrlElement())); 069 if (src.hasNameElement()) 070 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 071 if (src.hasStatus()) 072 tgt.setStatusElement(Enumerations14_50.convertConformanceResourceStatus(src.getStatusElement())); 073 if (src.hasExperimental()) 074 tgt.setExperimentalElement(Boolean14_50.convertBoolean(src.getExperimentalElement())); 075 if (src.hasDate()) 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.dstu2016may.model.SearchParameter.SearchParameterContactComponent t : src.getContact()) 080 tgt.addContact(convertSearchParameterContactComponent(t)); 081 for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) 082 if (CodeableConcept14_50.isJurisdiction(t)) 083 tgt.addJurisdiction(CodeableConcept14_50.convertCodeableConcept(t)); 084 else 085 tgt.addUseContext(CodeableConcept14_50.convertCodeableConceptToUsageContext(t)); 086 if (src.hasRequirements()) 087 tgt.setPurpose(src.getRequirements()); 088 if (src.hasCodeElement()) 089 tgt.setCodeElement(Code14_50.convertCode(src.getCodeElement())); 090 tgt.getBase().add(new Enumeration<VersionIndependentResourceTypesAll>(new VersionIndependentResourceTypesAllEnumFactory(), Code14_50.convertCode(src.getBaseElement()))); 091 if (src.hasType()) 092 tgt.setTypeElement(Enumerations14_50.convertSearchParamType(src.getTypeElement())); 093 if (src.hasDescription()) 094 tgt.setDescription(src.getDescription()); 095 if (src.hasExpression()) 096 tgt.setExpression(ElementDefinition14_50.convertToR4Expression(src.getExpression())); 097// if (src.hasXpath()) 098// tgt.setXpathElement(String14_50.convertString(src.getXpathElement())); 099 if (src.hasXpathUsage()) 100 tgt.setProcessingModeElement(convertXPathUsageType(src.getXpathUsageElement())); 101 for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getTarget()) tgt.getTarget().add(new Enumeration<VersionIndependentResourceTypesAll>(new VersionIndependentResourceTypesAllEnumFactory(), t.getValue())); 102 return tgt; 103 } 104 105 public static org.hl7.fhir.r5.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException { 106 if (src == null || src.isEmpty()) 107 return null; 108 org.hl7.fhir.r5.model.ContactDetail tgt = new org.hl7.fhir.r5.model.ContactDetail(); 109 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 110 if (src.hasName()) 111 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 112 for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) 113 tgt.addTelecom(ContactPoint14_50.convertContactPoint(t)); 114 return tgt; 115 } 116 117 public static org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.r5.model.ContactDetail src) throws FHIRException { 118 if (src == null || src.isEmpty()) 119 return null; 120 org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent(); 121 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 122 if (src.hasName()) 123 tgt.setNameElement(String14_50.convertString(src.getNameElement())); 124 for (org.hl7.fhir.r5.model.ContactPoint t : src.getTelecom()) 125 tgt.addTelecom(ContactPoint14_50.convertContactPoint(t)); 126 return tgt; 127 } 128 129 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> src) throws FHIRException { 130 if (src == null || src.isEmpty()) 131 return null; 132 org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageTypeEnumFactory()); 133 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 134 switch (src.getValue()) { 135 case NORMAL: 136 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NORMAL); 137 break; 138 case PHONETIC: 139 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.PHONETIC); 140 break; 141 142 case OTHER: 143 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.OTHER); 144 break; 145 default: 146 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NULL); 147 break; 148 } 149 return tgt; 150 } 151 152 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> convertXPathUsageType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> src) throws FHIRException { 153 if (src == null || src.isEmpty()) 154 return null; 155 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeTypeEnumFactory()); 156 ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt); 157 switch (src.getValue()) { 158 case NORMAL: 159 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.NORMAL); 160 break; 161 case PHONETIC: 162 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.PHONETIC); 163 break; 164 case NEARBY: 165 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER); 166 break; 167 case DISTANCE: 168 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER); 169 break; 170 case OTHER: 171 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.OTHER); 172 break; 173 default: 174 tgt.setValue(org.hl7.fhir.r5.model.SearchParameter.SearchProcessingModeType.NULL); 175 break; 176 } 177 return tgt; 178 } 179}