Today was asked how you would handle a VISIT_END_DATE when the patient is still active, meaning the patient is still a patient at the time the data cut was made.
Technically VISIT_END_DATE should but NULL in this case, however this is not possible given this is a required field. After chatting with @Patrick_Ryan, I would like to recommend the VISIT_END_DATE should be set to OBSERVATION_PERIOD_END_DATE +1. This would make the end date outside the observation but not so far outside that it would destroy any standard analytics using VISIT_START_DATE and VISIT_END_DATE.
You could find these active visits like this:
SELECT *
FROM VISIT_OCCURRENCE vo
JOIN OBSERVATION_PERIOD op
ON op.PERSON_ID = vo.PERSON_ID
AND vo.VISIT_START_DATE BETWEEN op.OBSERVATION_PERIOD_START_DATE AND op.OBSERVATION_PERIOD_END_DATE
AND vo.VISIT_END_DATE > op.OBSERVATION_PERIOD_END_DATE
Tagging my friends who might be interested: @clairblacketer, @Patrick_Ryan, @krfeeney, @ronaldcornet, @Rijnbeek, @MaximMoinat, @Sebastiaan_van_Sandi
This is kind of related to this post - but this older post was more about what to do when an end date is missing.