Beispiel #1
0
 public List <ContactTracing> getTier0(ContactTracing contactTracing, ContactTracing nextTimeIn)
 {
     using (var context = new COVID19Entities())
     {
         if (nextTimeIn == null)
         {
             var endHour          = contactTracing.RegisterDateTime.Date + dtpTime.Value.TimeOfDay;
             var getDirectContact = (from x in context.ContactTracings
                                     where x.Contact != contactTracing.Contact
                                     where x.LocationID == contactTracing.LocationID && x.RegisterDateTime >= contactTracing.RegisterDateTime && x.RegisterDateTime < endHour
                                     select x).ToList();
             return(getDirectContact);
         }
         else
         {
             //Assumes infected takes 5 minute to travel to each room
             var endTime          = nextTimeIn.RegisterDateTime.AddMinutes(-5);
             var getDirectContact = (from x in context.ContactTracings
                                     where x.Contact != contactTracing.Contact
                                     where x.LocationID == contactTracing.LocationID && x.RegisterDateTime >= contactTracing.RegisterDateTime && x.RegisterDateTime < endTime
                                     select x).ToList();
             return(getDirectContact);
         }
     }
 }
Beispiel #2
0
 private void MainMenu_Load(object sender, EventArgs e)
 {
     using (var context = new COVID19Entities())
     {
         var getSuspected = (from x in context.ContactTracings
                             where x.Temp >= 38
                             select x.FullName).Distinct();
         foreach (var item in getSuspected)
         {
             cbSuspectedPeople.Items.Add(item);
         }
     }
 }
Beispiel #3
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     lbRecords.Items.Clear();
     lbTier0.Items.Clear();
     lbTier1.Items.Clear();
     lbTier2.Items.Clear();
     lbTier3.Items.Clear();
     using (var context = new COVID19Entities())
     {
         if (cbSuspectedPeople.SelectedItem != null)
         {
             var getContact = (from x in context.ContactTracings
                               where x.FullName == cbSuspectedPeople.SelectedItem.ToString()
                               select x.Contact).FirstOrDefault();
             Route(getContact);
         }
     }
 }
Beispiel #4
0
        public List <ContactTracing> getNonDirect(ContactTracing nextTimeIn, List <long> RoomsPassed)
        {
            //Assumes infected takes 5 minute to travel to each room
            if (nextTimeIn != null)
            {
                var endTime            = nextTimeIn.RegisterDateTime.AddMinutes(-5);
                var getIndirectContact = new List <ContactTracing>();
                using (var context = new COVID19Entities())
                {
                    foreach (var item in RoomsPassed)
                    {
                        getIndirectContact.AddRange((from x in context.ContactTracings
                                                     where x.Contact != nextTimeIn.Contact
                                                     where x.LocationID == item && x.RegisterDateTime >= endTime && x.RegisterDateTime < nextTimeIn.RegisterDateTime
                                                     select x).ToList());
                    }
                    return(getIndirectContact);
                }
            }
            else
            {
                var leavingTime        = dtpTime.Value.Date.AddMinutes(-5);
                var getIndirectContact = new List <ContactTracing>();

                using (var context = new COVID19Entities())
                {
                    var getContact = (from x in context.ContactTracings
                                      where x.FullName == cbSuspectedPeople.SelectedItem.ToString()
                                      select x.Contact).FirstOrDefault();
                    foreach (var item in RoomsPassed)
                    {
                        getIndirectContact.AddRange((from x in context.ContactTracings
                                                     where x.Contact != getContact
                                                     where x.LocationID == item && x.RegisterDateTime >= leavingTime && x.RegisterDateTime < dtpTime.Value
                                                     select x).ToList());
                    }
                    return(getIndirectContact);
                }
            }
        }
Beispiel #5
0
        public void Route(string phoneNumber)
        {
            using (var context = new COVID19Entities())
            {
                var symptoms = (from x in context.ContactTracings
                                where x.Contact == phoneNumber
                                where x.Temp >= 38
                                orderby x.RegisterDateTime descending
                                select x.RegisterDateTime).FirstOrDefault().Date.AddDays(-14);

                var UserHistory = (from x in context.ContactTracings
                                   where x.Contact == phoneNumber
                                   where x.RegisterDateTime >= symptoms
                                   select x).ToList();

                var groupDates = (from x in UserHistory
                                  group x by x.RegisterDateTime.Date into y
                                  orderby y.Key descending
                                  select y);
                var list    = new List <ContactTracing>();
                var listNon = new List <ContactTracing>();
                foreach (var item in groupDates)
                {
                    var contactTracing = new List <ContactTracing>();
                    lbRecords.Items.Add(item.Key);
                    foreach (var records in item)
                    {
                        contactTracing.Add(records);
                    }
                    for (int i = 0; i <= contactTracing.Count() - 1; i++)
                    {
                        if (i != contactTracing.Count() - 1)
                        {
                            lbRecords.Items.Add($"\tCurrent: IT-{contactTracing[i].Location.LocationFloor}-{contactTracing[i].Location.LocationUnitNumber} " +
                                                $"Time in: {contactTracing[i].RegisterDateTime}");
                            lbRecords.Items.Add($"\t\tTravelled rooms: {String.Join(",", RouteTracing(contactTracing[i], contactTracing[i + 1]))}");
                            lbRecords.Items.Add("");
                            list.AddRange(getTier0(contactTracing[i], contactTracing[i + 1]));
                            listNon.AddRange(getNonDirect(contactTracing[i + 1], RouteTracing(contactTracing[i], contactTracing[i + 1])));
                        }
                        else
                        {
                            lbRecords.Items.Add($"\tCurrent: IT-{contactTracing[i].Location.LocationFloor}-{contactTracing[i].Location.LocationUnitNumber} " +
                                                $"Time in: {contactTracing[i].RegisterDateTime}");
                            if (contactTracing[i].Location.LocationFloor != 1)
                            {
                                lbRecords.Items.Add($"\t\tTravelled rooms: {String.Join(",", RouteTracing(contactTracing[i], null))}");
                                lbRecords.Items.Add("");
                                list.AddRange(getTier0(contactTracing[i], null));
                                listNon.AddRange(getNonDirect(null, RouteTracing(contactTracing[i], null)));
                            }
                            else
                            {
                                lbRecords.Items.Add("");
                                list.AddRange(getTier0(contactTracing[i], null));
                            }
                        }
                    }
                }
                var groupList = (from x in list
                                 group x by x.Contact into y
                                 orderby y.Count() descending
                                 select y);
                foreach (var tier0 in groupList)
                {
                    lbTier0.Items.Add($"{tier0.Select(x => x.FullName).FirstOrDefault()} - {tier0.Key}({tier0.Count()})");
                    var toRemove = listNon.Where(x => x.Contact == tier0.Key).Select(x => x).ToList();
                    foreach (var item in toRemove)
                    {
                        listNon.Remove(item);
                    }
                }
                var groupNonList = (from x in listNon
                                    group x by x.Contact into y
                                    orderby y.Count()
                                    select y).ToList();
                foreach (var records in groupNonList)
                {
                    var ninetyPercentile      = Math.Round(0.9 * groupNonList.Count(), 0, MidpointRounding.AwayFromZero);
                    var seventyFivePercentile = Math.Round(0.75 * groupNonList.Count(), 0, MidpointRounding.AwayFromZero);
                    var getIndex = groupNonList.IndexOf(records) + 1;
                    if (getIndex >= ninetyPercentile)
                    {
                        lbTier1.Items.Add($"{records.Select(x => x.FullName).FirstOrDefault()} - {records.Key}({records.Count()})");
                    }
                    else if (getIndex >= seventyFivePercentile && getIndex < ninetyPercentile)
                    {
                        lbTier2.Items.Add($"{records.Select(x => x.FullName).FirstOrDefault()} - {records.Key}({records.Count()})");
                    }
                    else if (getIndex < ninetyPercentile)
                    {
                        lbTier3.Items.Add($"{records.Select(x => x.FullName).FirstOrDefault()} - {records.Key}({records.Count()})");
                    }
                }
            }
        }