Interaction is a child of Patient Case.
Interaction has the fields “Purpose” and “Date.”
How do I write a query that will return all the Interactions of a particular Purpose which are the first chronologically of that Purpose for their particular Patient Case, and are in a particular date range?
Consider the data below:
Id = 1 ; Case = A ; Purpose = a ; Date = Jan 1
Id = 2 ; Case = A ; Purpose = b ; Date = Feb 1
Id = 3 ; Case = A ; Purpose = a ; Date = Feb 10
Id = 4 ; Case = B ; Purpose = a ; Date = Feb 15
Id = 5 ; Case = C ; Purpose = a ; Date = Feb 15
Id = 6 ; Case = C ; Purpose = a ; Date = Mar 1
Supposing I want all the records with purpose a, where the first occurrence of purpose a in the Case is in Feb?
How do I write a query that will just return Ids 4 and 5, but not 3?
EDIT: And by “query” I mean “model conditions”
Question
Query help?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.