private void calculateMatch(Organ r) { // This will query the recipient wait list with information from the added organ r. // Next it will extract the top recipient from the wait list. // It will then add the recipient to the match table, intiating the trigger which will prompt the owner if they want to accept the organ. // FUTURE: Deal with cases where there is no need for the organ. RecipientWaitList waitList = new RecipientWaitList(); int userID = r.MedicalPersonnelID; Medical_Personnel m = (from Medical_Personnel in OrganDonorSystemDB.Medical_Personnel where Medical_Personnel.medicalPersonnelId == userID select Medical_Personnel).Single(); waitList.populateList(r.organType_organtypeID, r.BloodType_BloodTypeID, m.State, m.City); if (waitList.getList().Count() > 0) { Recipient reciever = waitList.getList()[0]; MatchTable newEntry = new MatchTable(); newEntry.acceptedOrDeclined = null; newEntry.medicalPersonnelIdForRecipient = reciever.medicalPersonnelID; newEntry.organID = r.OrganID; newEntry.organType = r.organType_organtypeID; newEntry.recipientID = reciever.recipentID; OrganDonorSystemDB.AddToMatchTables(newEntry); OrganDonorSystemDB.SaveChanges(); } }
public UserHomeViewModel(String userID) { //getting logged in infromation int number; bool result = Int32.TryParse(userID, out number); loggedIn = number; if (loggedIn != null) { Medical_Personnel currentUser = (from Medical_Personnel in OrganDonorSystemDB.Medical_Personnel where Medical_Personnel.medicalPersonnelId == loggedIn select Medical_Personnel).Single(); userName = currentUser.userName; instName = currentUser.medicalFacility; city = currentUser.City.city1; state = currentUser.State.state1; numberOfStars = (from Award in OrganDonorSystemDB.Awards where Award.medicalPersonnelID == loggedIn select Award.awardType).Single(); numberOfDonors = (from Donor in OrganDonorSystemDB.Donors where Donor.medicalPersonnelId == loggedIn select Donor.DonorID).Count(); numberOfRecipients = (from Recipient in OrganDonorSystemDB.Recipients where Recipient.medicalPersonnelID == loggedIn select Recipient.recipentID).Count(); numberOfOrgans = (from Organ in OrganDonorSystemDB.Organs where Organ.MedicalPersonnelID == loggedIn select Organ.OrganID).Count(); } }
private List <Recipient> sortList(List <Recipient> rlist, State state, City city) { List <Tuple <Recipient, int> > scoredList = new List <Tuple <Recipient, int> >(); for (int x = 0; x < rlist.Count; x++) { int score = Convert.ToInt32(rlist[x].severity); int medical_id_for_recipient = rlist[x].medicalPersonnelID; Medical_Personnel m = (from Medical_Personnel in OrganDonorSystemDatabase.Medical_Personnel where Medical_Personnel.medicalPersonnelId == medical_id_for_recipient select Medical_Personnel).Single(); if (m.State.stateID != state.stateID) { score = score - 2; } if (m.City.cityID != city.cityID) { score = score - 1; } Tuple <Recipient, int> temp_tuple = new Tuple <Recipient, int>(rlist[x], score); scoredList.Add(temp_tuple); } scoredList.Sort((x, y) => y.Item2.CompareTo(x.Item2)); rlist = new List <Recipient>(); foreach (Tuple <Recipient, int> x in scoredList) { rlist.Add(x.Item1); } return(rlist); }
public ActionResult Register(Medical_Personnel r) { CityStateViewModel list = new CityStateViewModel(); list.changeCities(r.State_StateID); ViewData["list"] = list.listStates; ViewData["listCities"] = list.listCities; try { if (ModelState.IsValid && r.userName != null && list.checkCityState(r.City_CityID, r.State_StateID)) { OrganDonorSystemDB.Medical_Personnel.AddObject(r); OrganDonorSystemDB.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception e) { return(View()); } return(View()); }