We have a query regarding referencing resources contaiend in another. Assume the scenario,
ResourceA
|- contains
|- ResourceB
|- ResourceC
And ResourceB has a reference to ResourceC.
In above case, is it mandatory for ResourceA to contain direct reference to both Resource B and C? Or is it suifficient for A to refer to B, as there is a tarnsitive reference to C already (A->B->C)?
Our intepretation of the FHIR spec is latter (i.e. transitive reference is sufficient), reading below statement from https://www.hl7.org/fhir/references.html#contained
A contained resource SHALL only be included in a resource if something in that resource (potentially another contained resource) has a reference to it.
However there is also another note under same documentation which is causing us a confusion, mainly as the example only demonstrates reference from current().
Implementation Note: Contained resources are still a reference rather than being inlined directly into the element that is the reference (e.g. "custodian" above) to ensure that a single approach to resolving resource references can be used. Though direct containment would seem simpler, it would still be necessary to support internal references where the same contained resource is referenced more than once. In the end, all that it would achieve is creating additional options in the syntax. For users using XPath to process the resource, the following XPath fragment resolves the internal reference:
ancestor::f:[not(parent::f:)]/f:contained/*[@id=substring-after(current()/f:reference/@value, '#')]
Could you please help clarify this. Thanks.