Пример #1
0
        public ResponseHistoriesList GetAllHistories([FromBody] PatientHistoryModel identification)
        {
            ResponseHistoriesList ans = null;

            try
            {
                if (ValidateSecurityAPI())
                {
                    ans = PatientHistoryModel.GetAllHistories(identification);
                }
                else
                {
                    ans = new ResponseHistoriesList()
                    {
                        IsSuccessful = false, ResponseMessage = AppManagement.MSG_API_Validation_Failure
                    };
                }
            }
            catch (Exception ex)
            {
                ans = new ResponseHistoriesList()
                {
                    IsSuccessful = false, ResponseMessage = AppManagement.MSG_GenericExceptionError
                };
            }

            return(ans);
        }
Пример #2
0
        public async Task <IHttpActionResult> UpdatePatientHistory(PatientHistoryModel patientHistory)
        {
            if (patientHistory == null)
            {
                return(BadRequest("Please provide valid inputs!"));
            }

            //CommonResponse validatedResponse = await AuthService.ValidateUserAndToken();
            //if (!validatedResponse.IsError)
            {
                if (await PatientHistoryService.UpdatePatientHistory(patientHistory))
                {
                    return(Ok("Patient History Updated Successfully!"));
                }
                else
                {
                    return(BadRequest("Failed to Update Patient History!"));
                }
                //}
                //else
                //{
                //    return Unauthorized();
                //}
            }
        }
Пример #3
0
        public Response SaveHistory([FromBody] PatientHistoryModel attachmentsModel)
        {
            Response ans = null;

            try
            {
                if (ValidateSecurityAPI())
                {
                    ans = PatientHistoryModel.SaveAttachment(attachmentsModel);
                }
                else
                {
                    ans = new Response()
                    {
                        IsSuccessful = false, ResponseMessage = AppManagement.MSG_API_Validation_Failure
                    };
                }
            }
            catch (Exception ex)
            {
                ans = new Response()
                {
                    IsSuccessful = false, ResponseMessage = AppManagement.MSG_GenericExceptionError
                };
            }

            return(ans);
        }
        public async Task <ActionResult> CreatePatientHistory([FromBody] PatientHistoryModel patientHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var instance = PatientHistory.Create(patientHistory.PatientId);

            try
            {
                var newPatientHistory = await _repository.AddAsync(instance);

                if (newPatientHistory == null)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false
                    }));
                }
                return(CreatedAtRoute("GetPatientHistoryRoute", new { id = newPatientHistory.HistoryId },
                                      new ApiResponse {
                    Status = true, PatientHistory = newPatientHistory
                }));
            }
            catch
            {
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }
        public async Task <ActionResult> UpdatePatientHistory(Guid id, [FromBody] PatientHistoryModel patientHistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var instance = await _repository.GetByIdAsync(id);

            try
            {
                instance.Update(patientHistory.PatientId, patientHistory.DoctorId, patientHistory.Prescription, patientHistory.Description, patientHistory.Recommendations, patientHistory.Date);

                var status = await _repository.UpdateAsync(instance);

                if (!status)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false
                    }));
                }
                return(Ok(new ApiResponse {
                    Status = true, PatientHistory = instance
                }));
            }
            catch
            {
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }
Пример #6
0
        public static async Task <List <PatientHistoryModel> > SearchPatientHistory(PatientHistoryModel patientHistory)
        {
            List <PatientHistoryModel> PatientHistories = new List <PatientHistoryModel>();

            using (SqlConnection dbConn = new SqlConnection(connectionString))
            {
                var           query = "SELECT Patient_History.ID, PatientID,Patient.Name,Patient.NIC,Symptoms,Diagnosis,Changes,Remarks,LabReport,Prescription,DateAdded,DateModified FROM Patient_History INNER JOIN Patient ON Patient_History.PatientID = Patient.ID  WHERE Patient.NIC = '" + patientHistory.NIC + "'";
                SqlDataReader reader;

                try
                {
                    dbConn.Open();
                    SqlCommand cmd = new SqlCommand(query, dbConn);
                    reader = await cmd.ExecuteReaderAsync();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            PatientHistoryModel patientHistoryItem = new PatientHistoryModel();
                            patientHistoryItem.ID           = reader.GetInt32(0);
                            patientHistoryItem.PatientID    = reader.GetInt32(1);
                            patientHistoryItem.Name         = reader.GetString(2);
                            patientHistoryItem.NIC          = reader.GetString(3);
                            patientHistoryItem.Symptoms     = reader.GetString(4);
                            patientHistoryItem.Diagnosis    = reader.GetString(5);
                            patientHistoryItem.Changes      = reader.GetString(6);
                            patientHistoryItem.Remarks      = reader.GetString(7);
                            patientHistoryItem.LabReport    = reader.GetString(8);
                            patientHistoryItem.Prescription = reader.GetString(9);
                            patientHistoryItem.DateAdded    = reader.GetDateTime(10);
                            patientHistoryItem.DateModified = reader.GetDateTime(11);
                            PatientHistories.Add(patientHistoryItem);
                        }
                    }
                }
                catch (Exception ex)
                {
                    reader = null;
                    Console.WriteLine(ex);
                }
                finally
                {
                    dbConn.Close();
                }

                return(PatientHistories);
            }
        }
Пример #7
0
        public static async Task <bool> UpdatePatientHistory(PatientHistoryModel patientHistory)
        {
            string SQL = "UPDATE Patient_History SET Changes = @chgs, Remarks = @rem, Prescription = @pres, DateModified = @dateMod WHERE PatientID = @patID";

            using (SqlConnection dbConn = new SqlConnection(connectionString))
            {
                try
                {
                    dbConn.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = SQL;
                    cmd.Connection  = dbConn;
                    //cmd.Parameters.AddWithValue("@ID", patientHistory.ID);
                    cmd.Parameters.AddWithValue("@patID", patientHistory.PatientID);
                    //cmd.Parameters.AddWithValue("@NIC", patientHistory.NIC);
                    //cmd.Parameters.AddWithValue("@sym", patientHistory.Symptoms);
                    //cmd.Parameters.AddWithValue("@diag", patientHistory.Diagnosis);
                    cmd.Parameters.AddWithValue("@chgs", patientHistory.Changes);
                    cmd.Parameters.AddWithValue("@rem", patientHistory.Remarks);
                    //cmd.Parameters.AddWithValue("@labRep", patientHistory.LabReport);
                    cmd.Parameters.AddWithValue("@pres", patientHistory.Prescription);
                    //cmd.Parameters.AddWithValue("@dateAdd", patientHistory.DateAdded);
                    cmd.Parameters.AddWithValue("@dateMod", patientHistory.DateModified);
                    await cmd.ExecuteNonQueryAsync();

                    dbConn.Close();

                    return(true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return(false);
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
Пример #8
0
        public static async Task <bool> AddPatientHistory(PatientHistoryModel patientHistory)
        {
            string SQL = "INSERT INTO Patient_History(PatientID,NIC,Symptoms,Diagnosis,Changes,Remarks,LabReport,Prescription,DateAdded,DateModified)" +
                         "VALUES(@patID,@NIC,@sym,@diag,@chgs,@rem,@labRep,@pres,@dateAdd,@dateMod)";

            using (SqlConnection dbConn = new SqlConnection(connectionString))
            {
                try
                {
                    dbConn.Open();
                    SqlCommand cmd = new SqlCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = SQL;
                    cmd.Connection  = dbConn;
                    cmd.Parameters.AddWithValue("@patID", patientHistory.PatientID);
                    cmd.Parameters.AddWithValue("@NIC", patientHistory.NIC);
                    cmd.Parameters.AddWithValue("@sym", patientHistory.Symptoms);
                    cmd.Parameters.AddWithValue("@diag", patientHistory.Diagnosis);
                    cmd.Parameters.AddWithValue("@chgs", patientHistory.Changes);
                    cmd.Parameters.AddWithValue("@rem", patientHistory.Remarks);
                    cmd.Parameters.AddWithValue("@labRep", patientHistory.LabReport);
                    cmd.Parameters.AddWithValue("@pres", patientHistory.Prescription);
                    cmd.Parameters.AddWithValue("@dateAdd", patientHistory.DateAdded);
                    cmd.Parameters.AddWithValue("@dateMod", patientHistory.DateModified);
                    await cmd.ExecuteNonQueryAsync();

                    dbConn.Close();

                    return(true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    return(false);
                }
                finally
                {
                    dbConn.Close();
                }
            }
        }
        public async Task <ActionResult> UpdatePatientHistory(Guid id, [FromBody] PatientHistoryModel patientHistory, [FromHeader(Name = "Authorization")] string value)
        {
            var token    = new JwtSecurityTokenHandler().ReadJwtToken(value);
            var issuer   = token.Claims.First(claim => claim.Type == "iss").Value;
            var audience = token.Claims.First(claim => claim.Type == "aud").Value;

            if (issuer != "MyIssuer" || audience != "MyAudience")
            {
                return(Unauthorized());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var instance = await _repository.GetByIdAsync(id);

            try
            {
                instance.Update(patientHistory.Smoke, patientHistory.Drink, patientHistory.Gender, patientHistory.Weight, patientHistory.Height,
                                patientHistory.HealthConditions, patientHistory.Allergies, patientHistory.Consultations, patientHistory.LastVisit);

                var status = await _repository.UpdateAsync(instance);

                if (!status)
                {
                    return(BadRequest(new ApiResponse {
                        Status = false
                    }));
                }
                return(Ok(new ApiResponse {
                    Status = true, PatientHistory = instance
                }));
            }
            catch
            {
                return(BadRequest(new ApiResponse {
                    Status = false
                }));
            }
        }
Пример #10
0
        public async Task <IHttpActionResult> SearchPatientHistory(PatientHistoryModel patientHistory)
        {
            //CommonResponse validatedResponse = await AuthService.ValidateUserAndToken();
            //if (!validatedResponse.IsError)
            //{
            var patientsHistories = await PatientHistoryService.SearchPatientHistory(patientHistory);

            if (patientsHistories.Count > 0)
            {
                return(Ok(patientsHistories));
            }
            else
            {
                return(BadRequest("No Such Patient Exists!"));
            }
            //}
            //else
            //{
            //    return Unauthorized();
            //}
        }