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.complextypes14_30.CodeableConcept14_30; 006import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.ContactPoint14_30; 007import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Boolean14_30; 008import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Code14_30; 009import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.DateTime14_30; 010import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.String14_30; 011import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.Uri14_30; 012import org.hl7.fhir.exceptions.FHIRException; 013 014public class SearchParameter14_30 { 015 016 public static org.hl7.fhir.dstu2016may.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu3.model.SearchParameter src) throws FHIRException { 017 if (src == null || src.isEmpty()) 018 return null; 019 org.hl7.fhir.dstu2016may.model.SearchParameter tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter(); 020 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt); 021 if (src.hasUrlElement()) 022 tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement())); 023 if (src.hasNameElement()) 024 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 025 if (src.hasStatus()) 026 tgt.setStatusElement(Enumerations14_30.convertConformanceResourceStatus(src.getStatusElement())); 027 if (src.hasExperimental()) 028 tgt.setExperimentalElement(Boolean14_30.convertBoolean(src.getExperimentalElement())); 029 if (src.hasDate()) 030 tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement())); 031 if (src.hasPublisher()) 032 tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement())); 033 for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact()) 034 tgt.addContact(convertSearchParameterContactComponent(t)); 035 for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext()) 036 if (t.hasValueCodeableConcept()) 037 tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t.getValueCodeableConcept())); 038 for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction()) 039 tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t)); 040 if (src.hasPurpose()) 041 tgt.setRequirements(src.getPurpose()); 042 if (src.hasCodeElement()) 043 tgt.setCodeElement(Code14_30.convertCode(src.getCodeElement())); 044 for (org.hl7.fhir.dstu3.model.CodeType t : src.getBase()) tgt.setBase(t.asStringValue()); 045 if (src.hasType()) 046 tgt.setTypeElement(Enumerations14_30.convertSearchParamType(src.getTypeElement())); 047 if (src.hasDescription()) 048 tgt.setDescription(src.getDescription()); 049 if (src.hasExpression()) 050 tgt.setExpressionElement(String14_30.convertString(src.getExpressionElement())); 051 if (src.hasXpath()) 052 tgt.setXpathElement(String14_30.convertString(src.getXpathElement())); 053 if (src.hasXpathUsage()) 054 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 055 for (org.hl7.fhir.dstu3.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 056 return tgt; 057 } 058 059 public static org.hl7.fhir.dstu3.model.SearchParameter convertSearchParameter(org.hl7.fhir.dstu2016may.model.SearchParameter src) throws FHIRException { 060 if (src == null || src.isEmpty()) 061 return null; 062 org.hl7.fhir.dstu3.model.SearchParameter tgt = new org.hl7.fhir.dstu3.model.SearchParameter(); 063 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt); 064 if (src.hasUrlElement()) 065 tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement())); 066 if (src.hasNameElement()) 067 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 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.hasDate()) 073 tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement())); 074 if (src.hasPublisher()) 075 tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement())); 076 for (org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent t : src.getContact()) 077 tgt.addContact(convertSearchParameterContactComponent(t)); 078 for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext()) 079 if (VersionConvertor_14_30.isJurisdiction(t)) 080 tgt.addJurisdiction(CodeableConcept14_30.convertCodeableConcept(t)); 081 else 082 tgt.addUseContext(CodeableConcept14_30.convertCodeableConceptToUsageContext(t)); 083 if (src.hasRequirements()) 084 tgt.setPurpose(src.getRequirements()); 085 if (src.hasCodeElement()) 086 tgt.setCodeElement(Code14_30.convertCode(src.getCodeElement())); 087 tgt.addBase(src.getBase()); 088 if (src.hasType()) 089 tgt.setTypeElement(Enumerations14_30.convertSearchParamType(src.getTypeElement())); 090 if (src.hasDescription()) 091 tgt.setDescription(src.getDescription()); 092 if (src.hasExpression()) 093 tgt.setExpressionElement(String14_30.convertString(src.getExpressionElement())); 094 if (src.hasXpath()) 095 tgt.setXpathElement(String14_30.convertString(src.getXpathElement())); 096 if (src.hasXpathUsage()) 097 tgt.setXpathUsageElement(convertXPathUsageType(src.getXpathUsageElement())); 098 for (org.hl7.fhir.dstu2016may.model.CodeType t : src.getTarget()) tgt.addTarget(t.getValue()); 099 return tgt; 100 } 101 102 public static org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent convertSearchParameterContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException { 103 if (src == null || src.isEmpty()) 104 return null; 105 org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent tgt = new org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent(); 106 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 107 if (src.hasName()) 108 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 109 for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom()) 110 tgt.addTelecom(ContactPoint14_30.convertContactPoint(t)); 111 return tgt; 112 } 113 114 public static org.hl7.fhir.dstu3.model.ContactDetail convertSearchParameterContactComponent(org.hl7.fhir.dstu2016may.model.SearchParameter.SearchParameterContactComponent src) throws FHIRException { 115 if (src == null || src.isEmpty()) 116 return null; 117 org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail(); 118 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 119 if (src.hasName()) 120 tgt.setNameElement(String14_30.convertString(src.getNameElement())); 121 for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom()) 122 tgt.addTelecom(ContactPoint14_30.convertContactPoint(t)); 123 return tgt; 124 } 125 126 static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> src) throws FHIRException { 127 if (src == null || src.isEmpty()) 128 return null; 129 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()); 130 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 131 switch (src.getValue()) { 132 case NORMAL: 133 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NORMAL); 134 break; 135 case PHONETIC: 136 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.PHONETIC); 137 break; 138 case NEARBY: 139 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NEARBY); 140 break; 141 case DISTANCE: 142 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.DISTANCE); 143 break; 144 case OTHER: 145 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.OTHER); 146 break; 147 default: 148 tgt.setValue(org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType.NULL); 149 break; 150 } 151 return tgt; 152 } 153 154 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> convertXPathUsageType(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.SearchParameter.XPathUsageType> src) throws FHIRException { 155 if (src == null || src.isEmpty()) 156 return null; 157 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageTypeEnumFactory()); 158 ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt); 159 switch (src.getValue()) { 160 case NORMAL: 161 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NORMAL); 162 break; 163 case PHONETIC: 164 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.PHONETIC); 165 break; 166 case NEARBY: 167 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NEARBY); 168 break; 169 case DISTANCE: 170 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.DISTANCE); 171 break; 172 case OTHER: 173 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.OTHER); 174 break; 175 default: 176 tgt.setValue(org.hl7.fhir.dstu3.model.SearchParameter.XPathUsageType.NULL); 177 break; 178 } 179 return tgt; 180 } 181}