/// FHIR Extension Handler
/// This interface is used when processing resources to/from FHIR and allow
/// custom FHIR extensions to map data from extensions into the underlying
/// objects in the CDR schema.
public class FavoriteColorExtensionHandler : IFhirExtensionHandler
/// Gets the URI of the extension which appears within a resource
public Uri Uri => new Uri("http://example.com/fhir/extensions/reviewState");
/// Gets the URI of the profile that this extension is defined in
/// which is exposed on the profile definition.
public Uri ProfileUri => new Uri("http://example.com/fhir/profiles/example");
/// Gets the resource type that this applies to (or null if it applies to all types)
public ResourceType? AppliesTo => ResourceType.Patient;
/// Before returning the model object to the caller this method is called
/// so that your extension handler can construct the FHIR Extension
/// <param name="modelObject">The object that was loaded from the database which you can use to load data for your extension</param>
/// <returns>The constructed FHIR extension</returns>
public Extension Construct(IIdentifiedEntity modelObject) {
if(modelObject is IHasStatus status) {
if(status.StatusConceptKey == StatusKeys.New) {
Url = this.Uri.ToString(),
/// Parse the specified extension from FHIR and update the <paramref name="modelObject"/> accordingly
/// <param name="fhirExtension">The FHIR Extension to parsed</param>
/// <param name="modelObject">The current model object into which the extension data should be added</param>
/// <returns>True if the extension was parsed successfully</returns>
public bool Parse(Extension fhirExtension, IdentifiedData modelObject) {
if(modelObject is IHasStatus status) {
if(fhirExtension.Value == "not-reviewed") {
status.StatusConceptKey = StatusKeys.New;
status.StatusConceptKey = StatusKeys.Active;