001package ca.uhn.fhir.cql.common.evaluation;
002
003/*-
004 * #%L
005 * HAPI FHIR JPA Server - Clinical Quality Language
006 * %%
007 * Copyright (C) 2014 - 2022 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 ca.uhn.fhir.i18n.Msg;
024import java.util.HashMap;
025import java.util.Map;
026
027public enum MeasureScoring {
028    PROPORTION("proportion", "Proportion", "The measure score is defined using a proportion"),
029
030    RATIO("ratio", "Ratio", "The measure score is defined using a ratio"),
031
032    CONTINUOUSVARIABLE("continuous-variable", "Continuous Variable", "The score is defined by a calculation of some quantity"),
033
034    COHORT("cohort", "Cohort", "The measure is a cohort definition");
035
036    private String code;
037    private String display;
038    private String definition;
039
040    MeasureScoring(String code, String display, String definition) {
041        this.code = code;
042        this.display = display;
043        this.definition = definition;
044    }
045
046    private static final Map<String, MeasureScoring> lookup = new HashMap<>();
047
048    static {
049        for (MeasureScoring ms : MeasureScoring.values()) {
050            lookup.put(ms.toCode(), ms);
051        }
052    }
053
054    public static MeasureScoring fromCode(String code) {
055        if (code != null && !code.isEmpty()) {
056            if (lookup.containsKey(code)) {
057                return lookup.get(code);
058            }
059            // } else if (Configuration.isAcceptInvalidEnums()) {
060            //     return null;
061            // } else {
062            //     // throw new FHIRException(Msg.code(1656) + "Unknown MeasureScoring code \'" + code + "\'");
063            // }
064        }
065
066        return null;
067    }
068
069    public String toCode() {
070        return this.code;
071    }
072
073    public String getSystem() {
074        return "http://hl7.org/fhir/measure-scoring";
075    }
076
077    public String getDefinition() {
078        return this.definition;
079
080    }
081
082    public String getDisplay() {
083        return this.display;
084    }
085}