Aidbox / aidbox-dotnet

0 stars 0 forks source link

Add polymorphic fields support #6

Closed krvital closed 1 month ago

krvital commented 6 months ago

Instead of using one of the fields like here

var patient = new Patient();
patient.DeceasedBoolean = true;
// or
patient.DeceasedDateTime = new DateOnly("2024-01-01") 

Use polymorphic field


var patient = new Patient();
patient.Deceased = true;
// or
patient.Deceased = new DateTime(2000, 1, 1, 12, 39, 0); 
krvital commented 6 months ago

There are no union types in C#. One possible solution I am thinking about is using Element type in property declaration

public class Patient : DomainResource, IResource 
{
    ...
    public Base.Element? Deceased { get; set; }
}

var patient = new Patient {
    ...
    Deceased = new Base.Boolean(true)
}
krvital commented 1 month ago

done