Reporting module: Can we really use ObsForPersonDataDefinition in a VisitDataSet?

Hi @mseaton,

As I want to retrieve observations for a visit I am interested in using the existing ObsForPersonDataDefinition. You have mentioned that PersonDataDefs can be used within a visit context. But I think the ObsForPersonDataDefinition may not allow to exactly retrieve observations for a visit. Though it allows to retrieve observation for the patient of a visit, possibly within the same date range as the visit, I don’t think it ensures to exactly retrieve observations for a visit.

Some observations may have been recorded outside of a visit, or 2 visits could overlap in their dates but they would be returned by the ObsForPersonDataDef.

So I see 2 options: Modify the current ObsForPersonDataDefinition to accept a “visit” property and implement this change. This would require to join the encounter and visit tables to the query builder, since observations are really linked to a visit only through their encounter. Or create a new ObsForVisitDataDefinition.

I am willing to implement those changes as soon as possible and PR them but I am not sure which one is best for everyone. What do you think?

(As I have already started to use my own ObsForVisitDataDef, that the simplest for me, but I still can change)

Thanks

Romain

Hi @mksrom,

Definitely the ObsForVisitDataDefinition is the way to go.

You are correct that using an ObsForPersonDataDefinition within a VisitDataSetDefinition will not necessarily return an Obs that is part of that Visit. This is by design. By definition, a PersonDataDefinition will join on the “personId”, a PatientDataDefinition will join on the “patientId”, an EncounterDataDefinition will join on the “encounterId”, an ObsDataDefinition will join on the “obsId”, etc.

Mike

OK thanks.

Here is the PR for an ObsForVisitDataDefintion. It does not quite go as far as the other ObsFor…DataDefs, but that already a starting point.

Let me know if you want me to use a specific JIRA issue number in the commit message.