protected void Page_Load(object sender, EventArgs e) { searchType = Request.Form[searchTypeKey]; patientFilter = Request.Form[searchFilterKey]; SetSearchCookie(searchType); if (!string.IsNullOrEmpty(patientFilter.Replace(" ", ""))) { DataTable searchResults = SearchForPatients(searchType, patientFilter); int recordCount = searchResults.Rows.Count; // If we have 1 result, return encrypted id to client if (recordCount == 1) { string pId = searchResults.Rows[0][Patient.PatientId].ToString(); string encpId = Caisis.Security.CustomCryptoHelper.Encrypt(pId); SetSingleResultMessages(recordCount, encpId); } else { // If search count is below or search limit, bind to control for // rendering if (recordCount <= MaxSearchResults) { PatientsRptr.DataSource = searchResults; PatientsRptr.DataBind(); } SetMessages(recordCount); } } else { SetMessages(0); } }
private void BuildPatientList(string search) { string searchType = SearchOptionsDropdown.Value; string datasetSql = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]); PatientController pc = new PatientController(); SearchController sc = new SearchController(); UserController uc = new UserController(); DataTable searchResults = new DataTable(); SearchController ct = new SearchController(); string datasetSQL = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]); bool canViewIdentifiers = uc.CanViewPatientIdentifiers(); bool searchByLastNameMRN = canViewIdentifiers && searchType == PatientController.LAST_NAME_MRN_IDENTIFIER; if (searchByLastNameMRN) { searchResults = sc.FindPatient(search, datasetSql).Tables[0]; } else { searchResults = ct.FindPatientByIdentifier(search, searchType, datasetSQL).Tables[0]; } var results = from p in searchResults.AsEnumerable() let pid = (int)p[Patient.PatientId] let fName = p[Patient.PtFirstName].ToString() let lName = p[Patient.PtLastName].ToString() let fullName = pc.GetPatientName(fName, lName, false) let mrn = pc.GetPatientMRN(p[Patient.PtMRN].ToString()) let identifier = canViewIdentifiers && searchByLastNameMRN ? mrn : pc.GetPatientIdentifier(pid, searchType) let displayName = canViewIdentifiers ? fullName : "" let patient = new { PatientName = displayName, Identifier = identifier, PatientId = pid, EncPatientId = Security.CustomCryptoHelper.Encrypt(pid.ToString()) } orderby patient.PatientName ascending select patient; PatientsRptr.DataSource = results; PatientsRptr.DataBind(); }