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