protected void Bind_GridViewPatient() { string term = TextboxSearch.Text.Trim().ToLower(); List <Classes.Entity.Patient> patients = therapistBLL.GetCurrentPatients(term); ViewState["GridViewPatient"] = patients; GridViewPatient.DataSource = patients; GridViewPatient.DataBind(); UpdatePanelAccounts.Update(); }
protected void Bind_GridViewPatientAndRecord() { string nric = string.Empty; if (ViewState["GridViewPatientSelectedPatientNRIC"] != null) { nric = Convert.ToString(ViewState["GridViewPatientSelectedPatientNRIC"]); } List <Record> records = new RecordBLL().GetRecords(nric); ViewState["GridViewRecords"] = records; GridViewRecords.DataSource = records; GridViewRecords.DataBind(); string term = TextboxSearch.Text.Trim().ToLower(); List <Classes.Entity.Patient> patients = therapistBLL.GetCurrentPatients(term); ViewState["GridViewPatient"] = patients; GridViewPatient.DataSource = patients; GridViewPatient.DataBind(); UpdatePanelNewMedicalNote.Update(); }
public HttpResponseMessage TherapistGetPatients() { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Unauthorized); string jwt; string deviceID; string retrievedNRIC; AccountBLL accountBLL = new AccountBLL(); JWTBLL jwtBll = new JWTBLL(); HttpContext httpContext = HttpContext.Current; string authHeader = httpContext.Request.Headers["Authorization"]; // Ensure Authorization Header exists if (authHeader != null && authHeader.StartsWith("Bearer")) { string authHeaderValue = authHeader.Substring("Bearer ".Length).Trim(); string authHeaderValueDecoded = Encoding.UTF8.GetString(Convert.FromBase64String(authHeaderValue)); string[] authHeaderParts = authHeaderValueDecoded.Split(':'); jwt = authHeaderParts[0]; deviceID = authHeaderParts[1]; } else { return(response); } // Ensure jwt, deviceID exists if (!(!string.IsNullOrEmpty(jwt) && AccountBLL.IsDeviceIDValid(deviceID))) { return(response); } // Validate jwt if (!jwtBll.ValidateJWT(jwt)) { return(response); } else { retrievedNRIC = jwtBll.getNRIC(jwt); } // Validate deviceID for retrievedNRIC if (!(accountBLL.IsValid(retrievedNRIC, deviceID))) { return(response); } // Get all associated patients accountBLL.SetRole(retrievedNRIC, "Therapist"); Account account = accountBLL.GetStatus(retrievedNRIC); if (account.status == 1) { try { TherapistBLL therapistBLL = new TherapistBLL(); List <Classes.Entity.Patient> patients = therapistBLL.GetCurrentPatients(""); string names = ""; for (int i = 0; i < patients.Count; i++) { names += patients[i].nric + " " + patients[i].firstName + " " + patients[i].lastName; if (i != patients.Count - 1) { names += "\r"; } } response = Request.CreateResponse(HttpStatusCode.OK, System.Convert.ToBase64String(Encoding.ASCII.GetBytes(names))); } catch { response = Request.CreateResponse(HttpStatusCode.InternalServerError); } return(response); } return(response); }