001/**
002 * The contents of this file are subject to the Mozilla Public License Version 1.1
003 * (the "License"); you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
005 * Software distributed under the License is distributed on an "AS IS" basis,
006 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
007 * specific language governing rights and limitations under the License.
008 *
009 * The Original Code is "CodeStoreRegistry.java".  Description:
010 * "Registry containing CodeStore instances"
011 *
012 * The Initial Developer of the Original Code is University Health Network. Copyright (C)
013 * 2012.  All Rights Reserved.
014 *
015 * Contributor(s): ______________________________________.
016 *
017 * Alternatively, the contents of this file may be used under the terms of the
018 * GNU General Public License (the "GPL"), in which case the provisions of the GPL are
019 * applicable instead of those above.  If you wish to allow use of your version of this
020 * file only under the terms of the GPL and not to allow others to use your version
021 * of this file under the MPL, indicate your decision by deleting  the provisions above
022 * and replace  them with the notice and other provisions required by the GPL License.
023 * If you do not delete the provisions above, a recipient may use your version of
024 * this file under either the MPL or the GPL.
025 *
026 */
027package ca.uhn.hl7v2.conf.store;
028
029/**
030 * Registry containing {@link CodeStore} instances registered for Conformance Profile IDs
031 * or ID patterns.
032 * 
033 * @author Christian Ohr
034 */
035public interface CodeStoreRegistry {
036
037    /**
038     * Registers a code store for use with all profiles.
039     */
040    void addCodeStore(CodeStore store);
041    
042    /**
043     * Registers a code store for use with certain profiles. The profiles with which the code store
044     * are used are determined by profileIdPattern, which is a regular expression that will be
045     * matched against profile IDs. For example suppose there are three profiles in the profile
046     * store, with the following IDs:
047     * <ol>
048     * <li>ADT:confsig-UHN-2.4-profile-AL-NE-Immediate</li>
049     * <li>ADT:confsig-CIHI-2.4-profile-AL-NE-Immediate</li>
050     * <li>ADT:confsig-CIHI-2.3-profile-AL-NE-Immediate</li>
051     * </ol>
052     * Then to use a code store with only the first profile, the profileIdPattern would be
053     * "ADT:confsig-UHN-2.4-profile-AL-NE-Immediate". To use a code store with both of the 2.4
054     * profiles, the pattern would be ".*2\\.4.*". To use a code store with all profiles, the
055     * pattern would be '.*". Multiple stores can be registered for use with the same profile. If
056     * this happens, the first one that returned true for knowsCodes(codeSystem) will used. Stores
057     * are searched in the order they are added here.
058     */    
059    void addCodeStore(CodeStore store, String profileID);
060    
061    /**
062     * Returns the first code store that knows the codes in the given code system (as per
063     * CodeStore.knowsCodes) and is registered for the given profile. Code stores are checked in the
064     * order in which they are added (with addCodeStore()).
065     * 
066     * @return null if none are found
067     */    
068    CodeStore getCodeStore(String profileID, String codeSystem);
069    
070}