code View

id 2
Title EVI-CS03 /Active urgent checks
Type evidenza
Highlight group filequery1003.cs, Evidenze
Description Pazienti con verifiche urgenti attive
Code
        var q_uvu = db.d_events
           .AsNoTracking()
           .Where(x => x.event_type.ToLower() == "app_verify" &&
                       //x.event_type == "APP_VERIFY" && 
                       x.date_apt_exe == null)
           .Select(s => new
           {
               s.id_person,
               idApt = (string.IsNullOrEmpty(s.id_event) ? "" : "!")
           }).Distinct();

        //verifiche urgenti

        var qry = (from p in db.d_person.Where(w => w.date_stopped == null)
                   from q in q_uvu.Where(w => p.id_person == w.id_person).DefaultIfEmpty()
                   from e in db.d_events.Where(w => p.id_person == w.id_person && w.event_type == "APP_VERIFY" && w.event_status == "APE-001")
                   from s in db.d_status.Where(w => w.id_person == p.id_person && w.domain == "TARV" && w.active == true).DefaultIfEmpty()
                   select new
                   {
                       p.id_person,
                       q.idApt,
                       p.id_dream,
                       p.pe_surname,
                       p.pe_name,
                       p.pe_sex,
                       p.pe_dob,
                       e.date_apt,
                       description = s.status,
                       e.ev_vn1
                   }).ToList()
                   .Select(s => new
                   {
                       s.id_person,
                       s.idApt,
                       s.id_dream,
                       s.pe_surname,
                       s.pe_name,
                       s.pe_sex,
                       _data = (s.pe_dob.HasValue) ? s.pe_dob.Value.ToShortDateString() : "",
                       _dataApt = (s.date_apt.HasValue) ? s.date_apt.Value.ToShortDateString() : "",
                       s.description,
                       s.ev_vn1
                   }).DistinctBy(p => p.id_person);

 
        dt = qry.ToDataTable();
        dt.TableName = "lst_data";

 

Ordine