/// <summary> /// Fills the encounter results datagrid with the search results. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rgEncounterResults_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e) { // Get the medic information from session or data. TrinityClassLibrary_BL.Medic medic = GetCurrentMedic(); // Get all encounter status records from viewstate or data. List <TrinityClassLibrary_BL.EncounterStatus> allEncounterStatus = GetAllEncounterStatus(); // Get all rigs from viewstate or data. List <TrinityClassLibrary_BL.Rig> allRigs = GetAllRigs(); // Get all of the patient encounters that match the search criteria entered by the user. List <TrinityClassLibrary_BL.Patient> patientEncounters = TrinityClassLibrary_DAL.PatientProvider.Search(null, txtFName.Text, txtLName.Text, null, null, null, null, null, null, null, null, null, null, null, null, null, txtSSN.Text); // Remove patient encounters that medics are not allowed to view. patientEncounters = FilterPatientEncounters(medic, patientEncounters); // Add the information to a list to be used as the datasource for gird. List <EncounterResults> encounters = new List <EncounterResults>(); foreach (TrinityClassLibrary_BL.Patient patient in patientEncounters) { // Get the encounter status description. string currentEncounterStatus = GetPatientEncounterStatus(allEncounterStatus, patient); // Get the name of the patient's rig. string currentRig = GetRig(allRigs, patient.RigID); string name = BuildName(patient.FirstName, patient.LastName); string address = BuildPatientAddress(patient); // Create the entry for the list. EncounterResults currentEncounter = new EncounterResults(patient.PatientID, name, Convert.ToDateTime(patient.EncounterDate), patient.SSN, address, patient.HomePhone, currentRig, currentEncounterStatus); encounters.Add(currentEncounter); } ViewState["EncountersCount"] = encounters.Count; rgEncounterResults.DataSource = encounters; }
/// <summary> /// Fills the encounter results datagrid with the search results. /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rgEncounterResults_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e) { // Get the medic information from session or data. //TrinityClassLibrary_BL.Medic medic = GetCurrentMedic(); // Get all encounter status records from viewstate or data. List <TrinityClassLibrary_BL.EncounterStatus> allEncounterStatus = GetAllEncounterStatus(); // Get all rigs from viewstate or data. List <TrinityClassLibrary_BL.Rig> allRigs = GetAllRigs(); // Get all of the patient encounters that match the search criteria entered by the user. Int32?RigID = null; if (this.ddlWorksites.SelectedIndex > 0) { RigID = Convert.ToInt32(this.ddlWorksites.SelectedItem.Value); } List <TrinityClassLibrary_BL.Patient> patientEncounters = TrinityClassLibrary_DAL.PatientProvider.Search(RigID, txtFName.Text, txtLName.Text, null, null, null, null, null, null, null, null, null, null, null, null, null, this.txtSSN.Text.Trim()); // Remove patient encounters that medics are not allowed to view. //patientEncounters = FilterPatientEncounters(medic, patientEncounters); // Add the information to a list to be used as the datasource for gird. List <EncounterResults> encounters = new List <EncounterResults>(); //Get the customer id for the current user. Int32 CustID = GetCustomerID(); //Get the list of rigs for the selected customer. List <TMMModel.Customer_Worksite> cwList = GetRigsForCustomer(CustID); foreach (TrinityClassLibrary_BL.Patient patient in patientEncounters) { //If the date pickers have been populated, filter the results by the selected dates. Boolean addEncounter = true; if (patient.EncounterDate.HasValue && this.rdpEncounterStartDate.SelectedDate.HasValue && addEncounter) { addEncounter = (patient.EncounterDate.Value > this.rdpEncounterStartDate.SelectedDate.Value); } if (patient.EncounterDate.HasValue && this.rdpEncounterEndDate.SelectedDate.HasValue && addEncounter) { addEncounter = (patient.EncounterDate.Value < this.rdpEncounterEndDate.SelectedDate.Value); } if (addEncounter) { addEncounter = (patient.RigID.HasValue && isRigAssignedToCustomer(cwList, patient.RigID.Value)); } //If the patient encounter date fallse within the selected range... if (addEncounter) { // Get the encounter status description. string currentEncounterStatus = GetPatientEncounterStatus(allEncounterStatus, patient); // Get the name of the patient's rig. string currentRig = GetRig(allRigs, patient.RigID); string name = BuildName(patient.FirstName, patient.LastName); string address = BuildPatientAddress(patient); // Create the entry for the list. EncounterResults currentEncounter = new EncounterResults(patient.PatientID, name, Convert.ToDateTime(patient.EncounterDate), patient.SSN, address, patient.HomePhone, currentRig, currentEncounterStatus); encounters.Add(currentEncounter); } } ViewState["EncountersCount"] = encounters.Count; rgEncounterResults.DataSource = encounters; }