001 002package ca.uhn.fhir.rest.api; 003 004/* 005 * #%L 006 * HAPI FHIR - Core Library 007 * %% 008 * Copyright (C) 2014 - 2017 University Health Network 009 * %% 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * #L% 022 */ 023 024import java.util.HashMap; 025import java.util.Map; 026 027import ca.uhn.fhir.model.api.IValueSetEnumBinder; 028 029public enum RestSearchParameterTypeEnum { 030 031 /** 032 * Code Value: <b>number</b> 033 * 034 * Search parameter SHALL be a number (a whole number, or a decimal). 035 */ 036 NUMBER("number", "http://hl7.org/fhir/search-param-type"), 037 038 /** 039 * Code Value: <b>date</b> 040 * 041 * Search parameter is on a date/time. The date format is the standard XML format, though other formats may be supported. 042 */ 043 DATE("date", "http://hl7.org/fhir/search-param-type"), 044 045 /** 046 * Code Value: <b>string</b> 047 * 048 * Search parameter is a simple string, like a name part. Search is case-insensitive and accent-insensitive. May match just the start of a string. String parameters may contain spaces. 049 */ 050 STRING("string", "http://hl7.org/fhir/search-param-type"), 051 052 /** 053 * Code Value: <b>token</b> 054 * 055 * Search parameter on a coded element or identifier. May be used to search through the text, displayname, code and code/codesystem (for codes) and label, system and key (for identifier). Its value is either a string or a pair of namespace and value, separated by a "|", depending on the modifier used. 056 */ 057 TOKEN("token", "http://hl7.org/fhir/search-param-type"), 058 059 /** 060 * Code Value: <b>reference</b> 061 * 062 * A reference to another resource. 063 */ 064 REFERENCE("reference", "http://hl7.org/fhir/search-param-type"), 065 066 /** 067 * Code Value: <b>composite</b> 068 * 069 * A composite search parameter that combines a search on two values together. 070 */ 071 COMPOSITE("composite", "http://hl7.org/fhir/search-param-type"), 072 073 /** 074 * Code Value: <b>quantity</b> 075 * 076 * A search parameter that searches on a quantity. 077 */ 078 QUANTITY("quantity", "http://hl7.org/fhir/search-param-type"), 079 080 /** 081 * Code Value: <b>quantity</b> 082 * 083 * A search parameter that searches on a quantity. 084 */ 085 URI("uri", "http://hl7.org/fhir/search-param-type"), 086 087 /** 088 * _has parameter 089 */ 090 HAS("string", "http://hl7.org/fhir/search-param-type"), 091 092 ; 093 094 /** 095 * Identifier for this Value Set: 096 * http://hl7.org/fhir/vs/search-param-type 097 */ 098 public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/search-param-type"; 099 100 /** 101 * Name for this Value Set: 102 * SearchParamType 103 */ 104 public static final String VALUESET_NAME = "SearchParamType"; 105 106 private static Map<String, RestSearchParameterTypeEnum> CODE_TO_ENUM = new HashMap<String, RestSearchParameterTypeEnum>(); 107 private static Map<String, Map<String, RestSearchParameterTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterTypeEnum>>(); 108 109 private final String myCode; 110 private final String mySystem; 111 112 static { 113 for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) { 114 if (next == HAS) { 115 continue; 116 } 117 118 CODE_TO_ENUM.put(next.getCode(), next); 119 120 if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) { 121 SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterTypeEnum>()); 122 } 123 SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next); 124 } 125 } 126 127 /** 128 * Returns the code associated with this enumerated value 129 */ 130 public String getCode() { 131 return myCode; 132 } 133 134 /** 135 * Returns the code system associated with this enumerated value 136 */ 137 public String getSystem() { 138 return mySystem; 139 } 140 141 /** 142 * Returns the enumerated value associated with this code 143 */ 144 public static RestSearchParameterTypeEnum forCode(String theCode) { 145 RestSearchParameterTypeEnum retVal = CODE_TO_ENUM.get(theCode); 146 return retVal; 147 } 148 149 /** 150 * Converts codes to their respective enumerated values 151 */ 152 public static final IValueSetEnumBinder<RestSearchParameterTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterTypeEnum>() { 153 private static final long serialVersionUID = 1L; 154 155 @Override 156 public String toCodeString(RestSearchParameterTypeEnum theEnum) { 157 return theEnum.getCode(); 158 } 159 160 @Override 161 public String toSystemString(RestSearchParameterTypeEnum theEnum) { 162 return theEnum.getSystem(); 163 } 164 165 @Override 166 public RestSearchParameterTypeEnum fromCodeString(String theCodeString) { 167 return CODE_TO_ENUM.get(theCodeString); 168 } 169 170 @Override 171 public RestSearchParameterTypeEnum fromCodeString(String theCodeString, String theSystemString) { 172 Map<String, RestSearchParameterTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString); 173 if (map == null) { 174 return null; 175 } 176 return map.get(theCodeString); 177 } 178 179 }; 180 181 /** 182 * Constructor 183 */ 184 RestSearchParameterTypeEnum(String theCode, String theSystem) { 185 myCode = theCode; 186 mySystem = theSystem; 187 } 188 189 190}