Example #1
0
        private int UpdateDetails(PatientDetails newPatientDetails, PatientDetailsModel sessionDetails)
        {
            int result;

            if (sessionDetails != null)
            {
                sessionDetails.DateOfBirth = newPatientDetails.DateOfBirth;
                sessionDetails.Ethnicity   = (int)newPatientDetails.Ethnicity;
                sessionDetails.Gender      = (int)newPatientDetails.Gender;
                result = PatientProcessor.UpdatePatientDetails(sessionDetails);
            }
            else
            {
                sessionDetails = new PatientDetailsModel
                {
                    DateOfBirth = newPatientDetails.DateOfBirth,
                    Ethnicity   = (int)newPatientDetails.Ethnicity,
                    Gender      = (int)newPatientDetails.Gender
                };
                result = PatientProcessor.SavePatientDetails(SessionController.GetId(HttpContext.Session), sessionDetails);
            }

            if (result == 1)
            {
                SessionController.UpdatePatientDetails(HttpContext.Session, sessionDetails);
            }
            return(result);
        }
Example #2
0
 public static void UpdatePatientDetails(ISession session, PatientDetailsModel patientDetails)
 {
     if (patientDetails != null)
     {
         session.Set(PATIENT_DETAILS, patientDetails.Serialize());
     }
 }
        public IActionResult Details(int patientId)
        {
            var model = new PatientDetailsModel
            {
                Patient = _patientClient.GetPatientById(patientId)
            };

            return(View(model));
        }
Example #4
0
        public static void Login(ISession session, PatientModel patient, PatientDetailsModel patientDetails)
        {
            session.Set(LOGIN_STATUS, new byte[] { (byte)UserType.Patient });
            session.Set(LOGIN_ID, BitConverter.GetBytes(patient.Id));

            if (patientDetails != null)
            {
                session.Set(PATIENT_DETAILS, patientDetails.Serialize());
            }
        }
Example #5
0
 public static int UpdatePatientDetails(PatientDetailsModel patientDetailsModel)
 {
     return(SqlDataAccess.Save <PatientDetailsModel>
            (
                @"UPDATE dbo.PatientDetails
             SET DateOfBirth = @DateOfBirth, Gender = @Gender, Ethnicity = @Ethnicity
             WHERE Id = @Id",
                patientDetailsModel
            ));
 }
        public IActionResult UpdatePatientBackground(PatientDetailsModel model)
        {
            var succeded = _patientClient.UpdateBackground(model.Patient.Id, model.Patient.Background);

            if (!succeded)
            {
                throw new NotImplementedException();
            }

            return(RedirectToAction("Details", new { patientId = model.Patient.Id }));
        }
Example #7
0
        public IActionResult Details(PatientDetails patientDetails)
        {
            PatientDetailsModel sessionDetails = SessionController.GetPatientDetails(HttpContext.Session);
            int result = UpdateDetails(patientDetails, sessionDetails);

            // Add validation
            // Insert details into db, either updating the details or creating a new row in the db
            if (result == 0)
            {
                ViewData["ErrorMessage"] = "There was a problem saving your details.";
            }
            else
            {
                // Update session details
                ViewData["SuccessMessage"] = "Your details have been updated.";
            }
            return(View(patientDetails));
        }
Example #8
0
        public static int SavePatientDetails(int patientId, PatientDetailsModel patientDetailsModel)
        {
            int resultId = SqlDataAccess.SaveReturnId <PatientDetailsModel>
                           (
                @"INSERT into dbo.PatientDetails (DateOfBirth, Gender, Ethnicity)
                    VALUES (@DateOfBirth, @Gender, @Ethnicity)",
                patientDetailsModel
                           );

            return(SqlDataAccess.Save <PatientModel>
                   (
                       @"UPDATE dbo.Patient
                    SET FK_PatientDetails_Id = @Details
                    WHERE Id = @Id",
                       new PatientModel {
                Id = patientId, Details = resultId
            }
                   ));
        }
Example #9
0
        public IActionResult Details()
        {
            PatientDetailsModel patientDetailsModel = SessionController.GetPatientDetails(HttpContext.Session);
            PatientDetails      patientDetails      = null;

            // Check that patient details were extracted from the session controller
            // Null details means that the logged on patient does not have details saved yet
            if (patientDetailsModel != null)
            {
                patientDetails = new PatientDetails
                {
                    DateOfBirth = patientDetailsModel.DateOfBirth,
                    Gender      = (Gender)patientDetailsModel.Gender,
                    Ethnicity   = (Ethnicity)patientDetailsModel.Ethnicity
                };
            }

            return(View(patientDetails));
        }
Example #10
0
        public PatientResponse AddPatient([FromBody] PatientDetailsModel patientDetailsModel)
        {
            PatientResponse patientResponse = new PatientResponse();

            try
            {
                if (!ModelState.IsValid)
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.BadRequest);
                    patientResponse.Message = "Invalid data";
                    return(patientResponse);
                }

                bool isEmailExists = ValidateEmail(patientDetailsModel.Email);
                if (isEmailExists)
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.BadRequest);
                    patientResponse.Message = "Email already exists";
                    return(patientResponse);
                }

                int coordinatingPersonId = 0;

                if (patientDetailsModel.CoordinatingPerson != null)
                {
                    var coordinatingPerson = Mapper.Map <CoordinatingPersonModel, ContactInfo.DBEntities.Entities.CoordinatingPerson>(patientDetailsModel.CoordinatingPerson);

                    coordinatingPersonId = _patientBL.AddCoordinatingPerson(coordinatingPerson);
                    patientDetailsModel.CoordinatingPerson.CoordinatingPersonId = coordinatingPersonId;
                }
                var patientDetails = Mapper.Map <PatientDetailsModel, ContactInfo.DBEntities.Entities.PatientDetail>(patientDetailsModel);

                if (coordinatingPersonId > 0)
                {
                    patientDetails.CoordinatingPersonId = coordinatingPersonId;
                }

                var patientModel = Mapper.Map <ContactInfo.DBEntities.Entities.PatientDetail, PatientDetailsModel> (_patientBL.AddPatient(patientDetails));

                patientModel.CoordinatingPerson = patientDetailsModel.CoordinatingPerson;

                if (patientModel.PatientId > 0)
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.OK);
                    patientResponse.Message = "Patient added successfully";
                    patientResponse.Data    = patientModel;

                    EmailModel emailModel = new EmailModel();
                    emailModel.Recipient = "";
                    emailModel.Subject   = patientModel.Category + " Case Verification";
                    emailModel.Message   = "test";

                    if (patientModel.IsPoliceVerificationRequired == true)
                    {
                        bool isMailSent = EmailHelper.SendEMail(emailModel);
                    }
                }
                else
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.InternalServerError);
                    patientResponse.Message = "Error while adding";
                }

                return(patientResponse);
            }
            catch (Exception ex)
            {
                patientResponse.Status  = Convert.ToInt32(HttpStatusCode.InternalServerError);
                patientResponse.Message = "Error while adding";

                return(patientResponse);
            }
        }
Example #11
0
        public PatientResponse GetPatient([FromBody] PatientDetailsModel patientDetailsModel)

        {
            PatientResponse patientResponse = new PatientResponse();

            try
            {
                var patientList = _patientBL.GetAllPatientDetails();

                var patientListModel = Mapper.Map <IList <ContactInfo.DBEntities.Entities.PatientDetail>, IList <PatientDetailsModel> >(patientList);

                if (!(string.IsNullOrEmpty(patientDetailsModel.PatientName) && string.IsNullOrEmpty(patientDetailsModel.Email) && string.IsNullOrEmpty(patientDetailsModel.PatientName)))
                {
                    bool isEmail        = Regex.IsMatch(patientDetailsModel.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
                    bool isMobileNumber = Regex.IsMatch(patientDetailsModel.MobileNumber, @"^\d{10}$");

                    if ((!string.IsNullOrEmpty(patientDetailsModel.Email) && !isEmail) ||
                        (!string.IsNullOrEmpty(patientDetailsModel.MobileNumber) && !isMobileNumber))
                    {
                        patientResponse.Status  = Convert.ToInt32(HttpStatusCode.BadRequest);
                        patientResponse.Message = "Invalid data";
                        return(patientResponse);
                    }

                    if (!string.IsNullOrEmpty(patientDetailsModel.Email))
                    {
                        patientListModel = patientListModel.Where(p => p.Email.ToLower() == patientDetailsModel.Email.ToLower()).ToList();
                    }
                    if (!string.IsNullOrEmpty(patientDetailsModel.MobileNumber))
                    {
                        patientListModel = patientListModel.Where(p => p.MobileNumber == patientDetailsModel.MobileNumber).ToList();
                    }
                    if (!string.IsNullOrEmpty(patientDetailsModel.PatientName))
                    {
                        patientListModel = patientListModel.Where(p => p.PatientName.ToLower() == patientDetailsModel.PatientName.ToLower()).ToList();
                    }
                }

                if (patientListModel.Count() > 0)
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.OK);
                    patientResponse.Message = "Patient Details Fetched Successfully";
                    patientResponse.Data    = patientListModel;
                }
                else
                {
                    patientResponse.Status  = Convert.ToInt32(HttpStatusCode.OK);
                    patientResponse.Message = "No patient found";
                    patientResponse.Data    = patientListModel;
                }

                return(patientResponse);
            }
            catch (Exception ex)
            {
                patientResponse.Status  = Convert.ToInt32(HttpStatusCode.InternalServerError);
                patientResponse.Message = "Error while fetching";

                return(patientResponse);
            }
        }