001package ca.uhn.fhir.jpa.entity;
002
003/*
004 * #%L
005 * HAPI FHIR JPA Server
006 * %%
007 * Copyright (C) 2014 - 2023 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import java.util.Collections;
024import java.util.HashMap;
025import java.util.Map;
026
027/**
028 * This enum is used to indicate the pre-expansion status of a given ValueSet in the terminology tables. In this context,
029 * an expanded ValueSet has its included concepts stored in the terminology tables as well.
030 */
031public enum TermValueSetPreExpansionStatusEnum {
032        /*
033         * Sorting agnostic.
034         */
035
036        NOT_EXPANDED("notExpanded", "The ValueSet is waiting to be picked up and pre-expanded by a scheduled task."),
037        EXPANSION_IN_PROGRESS("expansionInProgress", "The ValueSet has been picked up by a scheduled task and pre-expansion is in progress."),
038        EXPANDED("expanded", "The ValueSet has been picked up by a scheduled task and pre-expansion is complete."),
039        FAILED_TO_EXPAND("failedToExpand", "The ValueSet has been picked up by a scheduled task and pre-expansion has failed.");
040
041        private static Map<String, TermValueSetPreExpansionStatusEnum> ourValues;
042        private String myCode;
043        private String myDescription;
044
045        TermValueSetPreExpansionStatusEnum(String theCode, String theDescription) {
046                myCode = theCode;
047                myDescription = theDescription;
048        }
049
050        public String getCode() {
051                return myCode;
052        }
053
054        public String getDescription() {
055                return myDescription;
056        }
057
058        public static TermValueSetPreExpansionStatusEnum fromCode(String theCode) {
059                if (ourValues == null) {
060                        HashMap<String, TermValueSetPreExpansionStatusEnum> values = new HashMap<String, TermValueSetPreExpansionStatusEnum>();
061                        for (TermValueSetPreExpansionStatusEnum next : values()) {
062                                values.put(next.getCode(), next);
063                        }
064                        ourValues = Collections.unmodifiableMap(values);
065                }
066                return ourValues.get(theCode);
067        }
068
069        /**
070         * Convert from Enum ordinal to Enum type.
071         *
072         * Usage:
073         *
074         * <code>TermValueSetExpansionStatusEnum termValueSetExpansionStatusEnum = TermValueSetExpansionStatusEnum.values[ordinal];</code>
075         */
076        public static final TermValueSetPreExpansionStatusEnum values[] = values();
077}