code View

id 19
Title EVI-CS19 / Patients with adherence to ARV therapy <95%
Type evidenza
Highlight group filequery1003.cs, Evidenze
Description Patients with adherence to ARV therapy <95% ultimo stato tarv,
Code
         var q_uvu = db.d_events
          .AsNoTracking()
          .Where(x => x.event_type.ToLower() == "app_verify" && x.date_apt_exe == null)
          .Select(s => new { s.id_person, idApt = (string.IsNullOrEmpty(s.id_event) ? "" : "!") }).Distinct();


        DateTime datetmp158 = DateTime.Now.AddDays(-60);

        var qry = (from p in db.d_person
                   from s in db.d_status.Where(w => w.id_person == p.id_person && w.domain == "TARV" && w.active == true)
                   from q in q_uvu.Where(w => p.id_person == w.id_person).DefaultIfEmpty()
                   from e in db.d_events_att.Where(w => p.id_person == w.id_person && w.domain == "APP_DRUGS")
                   from far in db.Farmaci.Where(w => e.vt4 == w.idFarmaco)
                   from comp in db.Composti.Where(w => far.idComposto == w.idComposto)
                   where
                     p.date_stopped == null
                     && s.status == "TARV_SI"
                     && e.date_event > datetmp158
                     && comp.ARV == true
                   group new { q, e } by new
                   {
                       p.id_person,
                       p.id_dream,
                       p.pe_surname,
                       p.pe_name,
                       p.pe_sex,
                       p.pe_dob,
                       q.idApt
                   } into g
                   where g.Average(p => p.e.vn8) < 95
                   select new
                   {
                       g.Key.id_person,
                       g.Key.idApt,
                       g.Key.id_dream,
                       g.Key.pe_surname,
                       g.Key.pe_name,
                       g.Key.pe_sex,
                       g.Key.pe_dob,
                       AvgPercA = (System.Double?)g.Average(p => p.e.vn8)
                   }).DistinctBy(d => d.id_person).ToDataTable();   //.AsEnumerable().Distinct().ToDataTable(); 

        dt = qry;
        dt.TableName = "lst_data";

 

Ordine