feature: Clinical Data Model Expansion & Observation Vocabulary

This commit is contained in:
voltsrage
2026-06-18 15:00:42 +08:00
parent 3b4c5c524b
commit 7d630fbbd9
33 changed files with 2636 additions and 36 deletions
@@ -0,0 +1,44 @@
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class BloodTypeJsonConverter : JsonConverterFactory
{
public override bool CanConvert(Type typeToConvert) =>
typeToConvert == typeof(BloodType) || typeToConvert == typeof(BloodType?);
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
if (typeToConvert == typeof(BloodType))
return new BloodTypeConverter();
return new NullableBloodTypeConverter();
}
private sealed class BloodTypeConverter : JsonConverter<BloodType>
{
public override BloodType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> BloodTypeExtensions.FromDbString(reader.GetString()!);
public override void Write(Utf8JsonWriter writer, BloodType value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToDbString());
}
private sealed class NullableBloodTypeConverter : JsonConverter<BloodType?>
{
public override BloodType? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
return null;
return BloodTypeExtensions.FromDbString(reader.GetString()!);
}
public override void Write(Utf8JsonWriter writer, BloodType? value, JsonSerializerOptions options)
{
if (value is null)
writer.WriteNullValue();
else
writer.WriteStringValue(value.Value.ToDbString());
}
}
}