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