Well there’s no technical problem; the query will just return whatever is in the system that conforms to it. If you have Body temps of another subject B in subject A’s EHR that you are querying, you will get subject B data as well. No developer should expect anything else
However, the semantic expectation is another question. It’s actually not that much different from the expectation that when you query for blood pressure and heart rate that you get actual measured BP and HR. However, in many systems today, you could easily pick up target BP or HR as well. This is a question of epistemic status, solved (in the great majority of cases) in openEHR by a) the distinct Entry subtypes and b) archetypes specific to the various epistemic categories.
The question of subject isn’t however an epistemic category, it’s just a contingent fact. The problem though is that we mentally think of everything in subject A’s EHR as being about subject A (including parts, systems, tissue etc). In fact, it contains everything relevant to the care of subject A, which can include foetal heart rates, candidate organ genetic match profile, etc.
No-one is generally surprised by the fact that foetal heart rates are included in the EHR of a pregnant mother, so I am not convinced that the contents of the EHR are contrary to the expectations of clinical professionals. It’s just that many of us often … forget.
We can make documentary additions to the specs to make it clearer, probably a good idea. But in terms of a technical fix, I suggest that @pablo’s type-checking approach I posted above, or something similar is probably the kind of thing to look at. Secondly, I can imagine some preset query ‘modes’ like the one @Seref posted above could be implemented in a generic way, so that if you did something like
SET SUBJECT_SELF_FILTER ON
it either modified the original query to include the type-check to force only PARTY_SELF
Entries to be returned, or maybe it re-filters the result set (clearly the latter is not a great idea if you have SUBJECT_SELF_FILTER OFF
, in terms of performance). Either way, some technical trick is performed that has the effect of adding this condition into the query, thus always creating the expected answer.
In the above, SET SUBJECT_SELF_FILTER
could just be a symbolic name of a configured query filter / modifier that is used a lot, so that it saves the query author some typing. I would consider the true query to be the result of having applied any such filters, i.e. these filters are just a tooling convenience that saves time. If this is not the case, then a bunch of saved queries have to include these filter setting statements as well, to be complete. Not out of the question, but more complicated I would suggest.