View Javadoc
1   
2   package ca.uhn.fhir.model.dstu.valueset;
3   
4   /*
5    * #%L
6    * HAPI FHIR - Core Library
7    * %%
8    * Copyright (C) 2014 University Health Network
9    * %%
10   * Licensed under the Apache License, Version 2.0 (the "License");
11   * you may not use this file except in compliance with the License.
12   * You may obtain a copy of the License at
13   * 
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   * 
16   * Unless required by applicable law or agreed to in writing, software
17   * distributed under the License is distributed on an "AS IS" BASIS,
18   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   * See the License for the specific language governing permissions and
20   * limitations under the License.
21   * #L%
22   */
23  
24  import java.util.HashMap;
25  import java.util.Map;
26  
27  import ca.uhn.fhir.model.api.IValueSetEnumBinder;
28  
29  public enum ContactUseEnum {
30  
31  	/**
32  	 * Code Value: <b>home</b>
33  	 *
34  	 * A communication contact at a home; attempted contacts for business purposes might intrude privacy and chances are one will contact family or other household members instead of the person one wishes to call. Typically used with urgent cases, or if no other contacts are available.
35  	 */
36  	HOME("home", "http://hl7.org/fhir/contact-use"),
37  	
38  	/**
39  	 * Code Value: <b>work</b>
40  	 *
41  	 * An office contact. First choice for business related contacts during business hours.
42  	 */
43  	WORK("work", "http://hl7.org/fhir/contact-use"),
44  	
45  	/**
46  	 * Code Value: <b>temp</b>
47  	 *
48  	 * A temporary contact. The period can provide more detailed information.
49  	 */
50  	TEMP("temp", "http://hl7.org/fhir/contact-use"),
51  	
52  	/**
53  	 * Code Value: <b>old</b>
54  	 *
55  	 * This contact is no longer in use (or was never correct, but retained for records).
56  	 */
57  	OLD("old", "http://hl7.org/fhir/contact-use"),
58  	
59  	/**
60  	 * Code Value: <b>mobile</b>
61  	 *
62  	 * A telecommunication device that moves and stays with its owner. May have characteristics of all other use codes, suitable for urgent matters, not the first choice for routine business.
63  	 */
64  	MOBILE("mobile", "http://hl7.org/fhir/contact-use"),
65  	
66  	;
67  	
68  	/**
69  	 * Identifier for this Value Set:
70  	 * http://hl7.org/fhir/vs/contact-use
71  	 */
72  	public static final String VALUESET_IDENTIFIER = "http://hl7.org/fhir/vs/contact-use";
73  
74  	/**
75  	 * Name for this Value Set:
76  	 * ContactUse
77  	 */
78  	public static final String VALUESET_NAME = "ContactUse";
79  
80  	private static Map<String, ContactUseEnum> CODE_TO_ENUM = new HashMap<String, ContactUseEnum>();
81  	private static Map<String, Map<String, ContactUseEnum>> SYSTEM_TO_CODE_TO_ENUM = new HashMap<String, Map<String, ContactUseEnum>>();
82  	
83  	private final String myCode;
84  	private final String mySystem;
85  	
86  	static {
87  		for (ContactUseEnum next : ContactUseEnum.values()) {
88  			CODE_TO_ENUM.put(next.getCode(), next);
89  			
90  			if (!SYSTEM_TO_CODE_TO_ENUM.containsKey(next.getSystem())) {
91  				SYSTEM_TO_CODE_TO_ENUM.put(next.getSystem(), new HashMap<String, ContactUseEnum>());
92  			}
93  			SYSTEM_TO_CODE_TO_ENUM.get(next.getSystem()).put(next.getCode(), next);			
94  		}
95  	}
96  	
97  	/**
98  	 * Returns the code associated with this enumerated value
99  	 */
100 	public String getCode() {
101 		return myCode;
102 	}
103 	
104 	/**
105 	 * Returns the code system associated with this enumerated value
106 	 */
107 	public String getSystem() {
108 		return mySystem;
109 	}
110 	
111 	/**
112 	 * Returns the enumerated value associated with this code
113 	 */
114 	public ContactUseEnum forCode(String theCode) {
115 		ContactUseEnum retVal = CODE_TO_ENUM.get(theCode);
116 		return retVal;
117 	}
118 
119 	/**
120 	 * Converts codes to their respective enumerated values
121 	 */
122 	public static final IValueSetEnumBinder<ContactUseEnum> VALUESET_BINDER = new IValueSetEnumBinder<ContactUseEnum>() {
123 		@Override
124 		public String toCodeString(ContactUseEnum theEnum) {
125 			return theEnum.getCode();
126 		}
127 
128 		@Override
129 		public String toSystemString(ContactUseEnum theEnum) {
130 			return theEnum.getSystem();
131 		}
132 		
133 		@Override
134 		public ContactUseEnum fromCodeString(String theCodeString) {
135 			return CODE_TO_ENUM.get(theCodeString);
136 		}
137 		
138 		@Override
139 		public ContactUseEnum fromCodeString(String theCodeString, String theSystemString) {
140 			Map<String, ContactUseEnum> map = SYSTEM_TO_CODE_TO_ENUM.get(theSystemString);
141 			if (map == null) {
142 				return null;
143 			}
144 			return map.get(theCodeString);
145 		}
146 		
147 	};
148 	
149 	/** 
150 	 * Constructor
151 	 */
152 	ContactUseEnum(String theCode, String theSystem) {
153 		myCode = theCode;
154 		mySystem = theSystem;
155 	}
156 
157 	
158 }