001
002package ca.uhn.fhir.rest.method;
003
004/*
005 * #%L
006 * HAPI FHIR - Core Library
007 * %%
008 * Copyright (C) 2014 - 2016 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        
089        /**
090         * Identifier for this Value Set:
091         * http://hl7.org/fhir/vs/search-param-type
092         */
093        public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/search-param-type";
094
095        /**
096         * Name for this Value Set:
097         * SearchParamType
098         */
099        public static final String VALUESET_NAME = "SearchParamType";
100
101        private static Map<String, RestSearchParameterTypeEnum> CODE_TO_ENUM = new HashMap<String, RestSearchParameterTypeEnum>();
102        private static Map<String, Map<String, RestSearchParameterTypeEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, RestSearchParameterTypeEnum>>();
103        
104        private final String myCode;
105        private final String mySystem;
106        
107        static {
108                for (RestSearchParameterTypeEnum next : RestSearchParameterTypeEnum.values()) {
109                        CODE_TO_ENUM.put(next.getCode(), next);
110                        
111                        if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
112                                SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, RestSearchParameterTypeEnum>());
113                        }
114                        SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);                 
115                }
116        }
117        
118        /**
119         * Returns the code associated with this enumerated value
120         */
121        public String getCode() {
122                return myCode;
123        }
124        
125        /**
126         * Returns the code system associated with this enumerated value
127         */
128        public String getSystem() {
129                return mySystem;
130        }
131        
132        /**
133         * Returns the enumerated value associated with this code
134         */
135        public RestSearchParameterTypeEnum forCode(String theCode) {
136                RestSearchParameterTypeEnum retVal = CODE_TO_ENUM.get(theCode);
137                return retVal;
138        }
139
140        /**
141         * Converts codes to their respective enumerated values
142         */
143        public static final IValueSetEnumBinder<RestSearchParameterTypeEnum> VALUESET_BINDER = new IValueSetEnumBinder<RestSearchParameterTypeEnum>() {
144                @Override
145                public String toCodeString(RestSearchParameterTypeEnum theEnum) {
146                        return theEnum.getCode();
147                }
148
149                @Override
150                public String toSystemString(RestSearchParameterTypeEnum theEnum) {
151                        return theEnum.getSystem();
152                }
153                
154                @Override
155                public RestSearchParameterTypeEnum fromCodeString(String theCodeString) {
156                        return CODE_TO_ENUM.get(theCodeString);
157                }
158                
159                @Override
160                public RestSearchParameterTypeEnum fromCodeString(String theCodeString, String theSystemString) {
161                        Map<String, RestSearchParameterTypeEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
162                        if (map == null) {
163                                return null;
164                        }
165                        return map.get(theCodeString);
166                }
167                
168        };
169        
170        /** 
171         * Constructor
172         */
173        RestSearchParameterTypeEnum(String theCode, String theSystem) {
174                myCode = theCode;
175                mySystem = theSystem;
176        }
177
178        
179}