I have the following model
public class AgendaExame
{
public int Id {get; set;}
public int PacienteId {get; set;}
public int ExameId {get; set;}
public DateTime Data {get; set;}
public DateTime ProximaData {get; set;}
}
The use of this model is to save the exam and date that was done, and when will the next exam ( ProximaData
)
Following this saved information:
ID, PacienteId, ExameId, DATA, PROXIMADATA
1 1 1 01/01/2018 01/01/2019
2 1 2 01/01/2018 01/01/2019
3 1 1 31/12/2018 31/12/2019
When I filter between 01/01/2019
and 31/01/2019
I need to search for the exams certain patients need to perform.
However, as we can see in line 3, the patient performed 1 day in advance of the examination, so his next date is only on day 31/12
, so it should not be on day 01/01
What I've tried so far was this:
var busca = db.AgendaExames.AsQueryable()
.Where(x =>
x.ProximaData != null &&
DbFunctions.TruncateTime(x.ProximaData ) >= model.Inicio &&
DbFunctions.TruncateTime(x.ProximaData ) <= model.Fim);
But this code only searches the ones I have to perform, I still need to check if the patient did not take the exam in advance (as explained above)
Summary: Save exam and track when your next exam will be