FHIR Chat · Add relatedAction.Relationship · dotnet

Stream: dotnet

Topic: Add relatedAction.Relationship


view this post on Zulip Jefferson (Jul 26 2019 at 14:18):

Relationship has a required binding so I can't have the element without a code, I been tiring to add the code of Concurrent but it will not add that to my output am I missing something?

 if (relatedAction.ActionIdElement == null)
            {
                relatedAction.ActionIdElement = new Id();
                relatedAction.Relationship = ActionRelationshipType.Concurrent;
            }

            relatedAction.ActionIdElement.Extension = new List<Extension>()
            {
                new Extension(GetExtensionUrl("actionPlaceholder"), new Code("radiation therapy"))
            };

            var radiationTherapyExtension = new Extension(GetExtensionUrl("radiationTherapyRelationship"),
                new Code(source.RadiationTherapy.Value));

            relatedAction.RelationshipElement = new Code<ActionRelationshipType>()
            {
                Extension = new List<Extension>() {radiationTherapyExtension}
            };

            target.RelatedAction.Add(relatedAction);

view this post on Zulip Michel Rutten (Jul 29 2019 at 09:13):

Hi @Tom MCDEVITT , the following statement:

relatedAction.RelationshipElement = new Code<ActionRelationshipType>()
{
    Extension = new List<Extension>() {radiationTherapyExtension}
};

completely replaces the RelationShip child component, thereby overwriting the binding value assigned earlier:

relatedAction.Relationship = ActionRelationshipType.Concurrent;

Instead, you can combine both statements and specify the binding value in the ctor:

relatedAction.RelationshipElement = new Code<ActionRelationshipType>(ActionRelationshipType.Concurrent)
{
    Extension = new List<Extension>() { radiationTherapyExtension }
};

Last updated: Apr 12 2022 at 19:14 UTC