001package org.hl7.fhir.r5.utils.validation.constants;
002
003import org.hl7.fhir.exceptions.FHIRException;
004import org.hl7.fhir.utilities.Utilities;
005
006public enum IdStatus {
007  OPTIONAL,
008  REQUIRED,
009  PROHIBITED;
010
011  public static IdStatus fromCode(String v) {
012    if (v == null || Utilities.noString(v)) {
013      return null;
014    } else {
015      v = v.toLowerCase();
016      if (v.equals("optional")) {
017        return OPTIONAL;
018      } else if (v.equals("required")) {
019        return REQUIRED;
020      } else if (v.equals("prohibited")) {
021        return PROHIBITED;
022      } else {
023        throw new FHIRException("Unkonwn Id Status code '"+v+"'");
024      }
025    }
026  }
027}