public enum ObservationSource { Manual, Device, Lab }

public static class ObservationSourceExtensions
{
    public static string ToDbString(this ObservationSource s) => s switch
    {
        ObservationSource.Manual => "MANUAL",
        ObservationSource.Device => "DEVICE",
        ObservationSource.Lab    => "LAB",
        _ => throw new ArgumentOutOfRangeException(nameof(s))
    };

    public static ObservationSource FromDbString(string v) => v switch
    {
        "MANUAL" => ObservationSource.Manual,
        "DEVICE" => ObservationSource.Device,
        "LAB"    => ObservationSource.Lab,
        _ => throw new ArgumentOutOfRangeException(nameof(v), $"Unknown observation source: '{v}'")
    };
}
