I have a list of patients (VisitID) who have been restrained. Some of the patients have multiple eprisodes they are restrained. The episodes are designated by different order dates and OrderID.
The seconde list are the mandatory 2 hour assessments done by the staff to review the well being of the restrained patients (VisitID) and ActivityDateTime
What I need to do is compare the Assessment list and assign them to the correct restraint order if the assessment was done (ActivityDateTime) on or after the order date and before a subsequent order date for the same paitent (VisitID).
I have attached two files of data: Patients and Assessments.
What is the syntax to create this query?