public enum ExternalResourceType
{
    Patient,
    Encounter
}

public static class ExternalResourceTypeExtensions
{
    public static string ToDbString(this ExternalResourceType t) => t switch
    {
        ExternalResourceType.Patient   => "PATIENT",
        ExternalResourceType.Encounter => "ENCOUNTER",
        _ => throw new ArgumentOutOfRangeException(nameof(t))
    };

    public static ExternalResourceType FromDbString(string v) => v switch
    {
        "PATIENT"   => ExternalResourceType.Patient,
        "ENCOUNTER" => ExternalResourceType.Encounter,
        _ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown external resource type: '{v}'")
    };
}