2

I am trying to construct an Order resource for the purpose of the EvaluateOrder transaction for GAO. According to the spec it is using contained resources as shown below. The problem I am having is that the .NET object model seems to require a resource reference. Is there any way to contain the data within the reference or is this use case outside of the intent of the model?

Order order = new Order 
{
    Identifier = new List<Identifier>{ new Identifier("mysystem", "8ea608db-ce55-41ea-936c-38195ae9b245") },
    DateElement = new FhirDateTime(DateTimeOffset.Now),
    Subject = new ResourceReference { /*???*/ }, 
};

GAO Order Spec

GAO Spec Fragment

Tedford
  • 2,842
  • 2
  • 35
  • 45

2 Answers2

2

We don't have the exact same requirements, but where we use "contained" resources we use code along the lines of :

Order myOrder = new Order();
Patient myPatient = new Patient();
myPatient.Id = Guid.NewGuid().ToString();

myOrder.Contained.Add(myPatient);
myOrder.Subject = new ResourceReference()
   {
    Reference = "#" + myPatient.Id
   };
BENBUN Coder
  • 4,801
  • 7
  • 52
  • 89
0

I expect it's outside the model because the same "contained" resource could potentially be referenced from multiple places. That said, a helper function that allows inline definition (and resolution) might be possible. You can make the suggestion on github.

In terms of what goes over the wire, the convenience of allowing inline substitution of references with the referenced content is outweighed by the complexity of resources now being able to appear absolutely anywhere, unlimited nesting, etc.

Lloyd McKenzie
  • 6,345
  • 1
  • 13
  • 10
  • This suggestion has been made during the last Atlanta WGM asd well and has been added to the issues list for the API (https://github.com/ewoutkramer/fhir-net-api/issues/107). We will align this solution with the HAPI Java API as they have already implemented this feature. – Ewout Kramer Oct 19 '15 at 09:19