Skip to content

correctIdElement in StructureDefinitionCorrectionsResolver always removes constraints of original type #583

@Rob5045

Description

@Rob5045

The currect logic always creates a whole new type component which will remove any constraints!

static void correctIdElement(IElementList elements)
{
    if (elements is null) return;

    var idElements = elements.Element.Where(e => Regex.IsMatch(e.Path, @"^[a-zA-Z]+\.id$"));
    if (idElements.Count() == 1 && idElements.Single().Type.Count == 1)
    {
        idElements.Single().Type = new() { new ElementDefinition.TypeRefComponent { Code = "id" } };
    }
}

Maybe something like this:

if (idElements.Count() == 1)
{
    var idElement = idElements.First();

    if (idElement.Type.Count == 1 && idElement.Type[0].Code != "id")
        idElement.Type[0].Code = "id";
}

PS. The use of Single() is unnecessary since Count() == 1 has already been checked!

Also the extension "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type" should be removed when its there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions