Reporting with Encounter and Coded Obs Cohort Definitions

In our implementation we are looking at finding obs which are grouped by encounter dates. In looking over the evaluators for the two cohort definitions, the EncounterWithCodedObsCohortDefinition uses encounter_dateandtime while the CodedObsCohortDefinition uses obs_datetime.

So my question is: Under what circumstances would obs_datetime be different from encounter_datetime.

When should one encounter definition be used over another?

@mseaton

An encounter can span over several minutes to hours in a day, historically this would be a patient’s hospital visit before we introduced visits. Typically, the encounter date time would be when the patient checked in at the facility, the obs date time on the other hand is the actual time of the day during the span of the encounter when it was diagnosed therefore it would always be a couple minutes or hours later. If the patient checked in at the facility close to midnight most likely some of the obs would be diagnosed a couple of minutes or hours after midnight which would be the next day.

@wyclif So how does it work with an HTML Form - is the encounter date time always the same as the obs date time at the time of submission?

Does the obs_date time also differ when the encounter is edited and new obs data added?

@ssmusoke, in HTML Form Entry, the obs_datetime defaults to inheriting the same value as encounter_datetime unless you explicitly do something like this <obs conceptId="3232" showDate="true" />.

I’m not sure what criteria is used in HFE module but in theory you can set the obs datetime to anything as long as it’s not before that of its encounter. In core if an obs has no datetime, we set it to that of the encounter by default.

Just to be clear, in my previous post meant to say encounter datetime is normally set to when the patient checked in and not really when they arrived at the facility.

@darius so apart from setting showDate=true, is there any other scenario when the obs_datetime will be different from the encounter date time?

@wyclif I am looking at instances when the two dates would be different to influence whether I use the EncounterWithCodedObsCohortDefinition or CodedObsCohortDefinition for speed - I expect the encounter one to be faster since there are less encounters - but this will be confirmed in timing

@ssmusoke I don’t remember any other scenarios where they would differ, if you’re purely entering data via HFE.

However looking at your original post here, I don’t really understand why you’re comparing these two cohort definition against each other from a purely performance standpoint. They queries do different things (i.e. one only finds patients with obs within encounters, and the other finds patients with those obs even if they’re not in encounters) so you should pick the one that has the correct behavior you want.

If you truly want to optimize performance, write a SqlCohortDefinition (but don’t do this unless you’re sure it’s actually worthwhile).

@darius Thank you for the clarification.

The performance was just a bonus (I had hoped), essentially we are looking at coded obs with values between dates passed as parameters so I will move back to the CodedObsCohortDefinition because it does what we need.