001package ca.cdr.api.model.enm;
002
003/*
004 * #%L
005 * Smile CDR - CDR
006 * %%
007 * Copyright (C) 2016 - 2024 Smile CDR, Inc.
008 * %%
009 * All rights reserved.
010 * #L%
011 */
012
013import java.util.Collections;
014import java.util.HashMap;
015import java.util.Map;
016
017/**
018 * Simple enum for the NUMBER fields relevant to mapping from Source to Smile CDR and Target,
019 * and from Smile CDR to Source and Target.
020 */
021public enum DemographicFieldEnum {
022        /**
023         * Sorting agnostic.
024         */
025
026        /**
027         * Source Code System
028         */
029        SOURCE_CODE_SYSTEM("source_code_system"),
030
031        /**
032         * CDR Code System
033         */
034        CDR_CODE_SYSTEM("cdr_code_system"),
035
036        /**
037         * Target Code System
038         */
039        TARGET_CODE_SYSTEM("target_code_system");
040
041        private static Map<String, DemographicFieldEnum> ourValues;
042        private String myCode;
043
044        private DemographicFieldEnum(String theCode) {
045                myCode = theCode;
046        }
047
048        public String getCode() {
049                return myCode;
050        }
051
052        public static DemographicFieldEnum fromCode(String theCode) {
053                if (ourValues == null) {
054                        HashMap<String, DemographicFieldEnum> values = new HashMap<String, DemographicFieldEnum>();
055                        for (DemographicFieldEnum next : values()) {
056                                values.put(next.getCode(), next);
057                        }
058                        ourValues = Collections.unmodifiableMap(values);
059                }
060                return ourValues.get(theCode);
061        }
062}