Esempio n. 1
0
        public PatientResponse GetPatients(PatientRequest request)
        {
            var patientList = new PatientRepository().GetPatients();
            var result      = patientList.AsQueryable();

            if (!string.IsNullOrEmpty(request.Name))
            {
                result = result.Where(p => p.FirstName.ToLowerInvariant().Contains(request.Name.ToLowerInvariant()) | p.LastName.ToLowerInvariant().Contains(request.Name.ToLowerInvariant()));
            }
            if (request.BirthYear.HasValue)
            {
                result = result.Where(p => p.BirthDate.Year == request.BirthYear);
            }
            if (request.Gender.HasValue)
            {
                result = result.Where(p => p.Gender == request.Gender);
            }
            if (!string.IsNullOrEmpty(request.PatientNumber))
            {
                result = result.Where(p => p.PatientNumber.ToLowerInvariant() == request.PatientNumber.ToLowerInvariant());
            }
            return(new PatientResponse
            {
                Patients = result.ToList()
            });
        }
Esempio n. 2
0
        public virtual List <PatientRequest> GetAllTestRequest()
        {
            SqlConnection connection = new SqlConnection(Connection);

            string query = "SELECT *FROM [PatientRequestTest]";

            connection.Open();

            SqlCommand            command         = new SqlCommand(query, connection);
            SqlDataReader         reader          = command.ExecuteReader();
            List <PatientRequest> TestRequestList = new List <PatientRequest>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    int            patientId   = (int)reader["PatientID"];
                    int            testID      = (int)reader["TestID"];
                    PatientRequest TestRequest = new PatientRequest(patientId, testID);

                    TestRequestList.Add(TestRequest);
                }
                reader.Close();
            }
            connection.Close();
            return(TestRequestList);
        }
Esempio n. 3
0
        public void AddPatientRequestToQueue(PatientOrganRequestViewModel model)
        {
            var isOrganInfoExist = _organInfoService.IfOrganInfoExists(model.OrganInfoId);

            if (!isOrganInfoExist)
            {
                throw new ArgumentException(nameof(model.OrganInfoId));
            }

            if (!Enum.IsDefined(typeof(PatientRequestPriority), model.QueryPriority))
            {
                model.QueryPriority = PatientRequestPriority.Normal;
            }

            var user            = _userManager.FindByEmailAsync(model.Email).Result;
            var patientUserInfo = user == null
                ? _userInfoService.RegisterPatient(model)
                : _userInfoService.GetUserInfoByUserId(user.Id);

            var patientRequest = new PatientRequest()
            {
                OrganInfoId   = model.OrganInfoId,
                PatientInfoId = patientUserInfo.UserInfoId,
                Priority      = model.QueryPriority,
                Message       = model.AdditionalInfo,
                Status        = PatientRequestStatuses.AwaitingForDonor
            };

            _patientRequestsRepository.Add(patientRequest);

            //TODO: send email to patient email with credentials
            //TODO: send email to clinic that query has been added
        }
Esempio n. 4
0
        public ActionResult GetListData()
        {
            var _draw          = Request.Form.GetValues("draw").FirstOrDefault();
            var _start         = Request.Form.GetValues("start").FirstOrDefault();
            var _length        = Request.Form.GetValues("length").FirstOrDefault();
            var _sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var _sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();
            var _searchValue   = Request.Form.GetValues("search[value]").FirstOrDefault();

            int _pageSize = _length != null?Convert.ToInt32(_length) : 0;

            int _skip = _start != null?Convert.ToInt32(_start) : 0;

            var request = new PatientRequest
            {
                Draw          = _draw,
                SearchValue   = _searchValue,
                SortColumn    = _sortColumn,
                SortColumnDir = _sortColumnDir,
                PageSize      = _pageSize,
                Skip          = _skip,
                Data          = new PatientModel()
            };

            if (Session["UserLogon"] != null)
            {
                request.Data.Account = (AccountModel)Session["UserLogon"];
            }

            var response = new PatientHandler(_unitOfWork, _context).GetListData(request);

            return(Json(new { data = response.Data, recordsFiltered = response.RecordsFiltered, recordsTotal = response.RecordsTotal, draw = response.Draw }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public DonorRequestDetailsViewModel(DonorRequest request, PatientRequest patientRequest = null)
        {
            Id                = request.Id;
            Message           = request.Message;
            Status            = request.Status;
            DonorInfoId       = request.DonorInfoId;
            DonorInfo         = new UserInfoDetailedViewModel(request.DonorInfo);
            OrganInfoId       = request.OrganInfoId;
            OrganInfo         = new OrganInfoDetailsViewModel(request.OrganInfo);
            TransplantOrganId = request.TransplantOrganId;
            MedicalExamsCount = request.DonorMedicalExams?.Count ?? 0;

            var lastExam = request.DonorMedicalExams?.LastOrDefault();

            if (lastExam != null)
            {
                LastDonorMedicalExam = new DonorMedicalExamListItemViewModel(lastExam);
                MedicalExamClinic    = new ClinicListItemViewModel(lastExam.Clinic);
            }

            if (patientRequest != null && patientRequest.PatientInfo != null)
            {
                PatientRequest = new PatientRequestDetailsViewModel(patientRequest);
            }
        }
Esempio n. 6
0
        public async Task <DatabaseModels.Patient> CheckIfAlreadyPresent(PatientRequest patientRequest)
        {
            var response = await Task <DatabaseModels.Patient> .Run(() =>
                                                                    _apiContext.Patients.Where(a => a.FirstName == patientRequest.FirstName &&
                                                                                               a.LastName == patientRequest.LastName &&
                                                                                               a.DateOfBirth == patientRequest.DateOfBirth).FirstOrDefault());

            return(response);
        }
        public async Task <IActionResult> Add([FromBody] PatientRequest request)
        {
            var outputHandler = await _service.Add(request);

            if (outputHandler.IsErrorOccured)
            {
                return(BadRequest(outputHandler.Message));
            }
            return(Created("", outputHandler.Message));
        }
Esempio n. 8
0
 public PatientRequestListItemViewModel(PatientRequest patientRequest)
 {
     Id                    = patientRequest.Id;
     Message               = patientRequest.Message;
     Status                = patientRequest.Status;
     FullName              = patientRequest.PatientInfo.FirstName + " " + patientRequest.PatientInfo.SecondName;
     PatientInfoId         = patientRequest.PatientInfoId;
     OrganInfoId           = patientRequest.OrganInfoId;
     OrganInfoName         = patientRequest.OrganInfo.Name;
     HasLinkedDonorRequest = patientRequest.RequestsRelation != null &&
                             patientRequest.RequestsRelation.IsActive;
     Priority = patientRequest.Priority;
 }
Esempio n. 9
0
        public async Task <IActionResult> Create([FromBody] PatientRequest request)
        {
            try
            {
                await patientService.CreateAsync(request);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Esempio n. 10
0
        public async Task <IActionResult> Edit([FromRoute] Guid id, [FromBody] PatientRequest request)
        {
            try
            {
                var patient = await patientService.EditAsync(id, request);

                return(Ok(patient));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
        public void AcceptPatientRequest(PatientRequest request)
        {
            if (request.IsAccepted)
            {
                this.roles.ChangeRoleFor(request.UserId, Roles.Patient);
            }
            else
            {
                this.roles.ChangeRoleFor(request.UserId, Roles.User);
            }

            this.requests.Update(request);
            this.requests.Save();
        }
        public void AcceptPatientRequest(PatientRequest request)
        {
            if (request.IsAccepted)
            {
                this.roles.ChangeRoleFor(request.UserId, Roles.Patient);
            }
            else
            {
                this.roles.ChangeRoleFor(request.UserId, Roles.User);
            }

            this.requests.Update(request);
            this.requests.Save();
        }
Esempio n. 13
0
        public PatientRequestDetailsViewModel(PatientRequest request, DonorRequest donorRequest = null)
        {
            Id            = request.Id;
            Message       = request.Message;
            Status        = request.Status;
            PatientInfoId = request.PatientInfoId;
            PatientInfo   = new UserInfoDetailedViewModel(request.PatientInfo);
            OrganInfoId   = request.OrganInfoId;
            OrganInfo     = new OrganInfoDetailsViewModel(request.OrganInfo);

            if (donorRequest != null)
            {
                DonorRequest = new DonorRequestDetailsViewModel(donorRequest);
            }
        }
Esempio n. 14
0
        public async Task <IActionResult> UpdatePatient([Required(ErrorMessage = "Patient Id is Required")] Guid id,
                                                        [Required] PatientRequest patientRequest)
        {
            var patientExists = await _patientService.CheckIfIdExists(id);

            var patientUri = new Uri($"v1/patients/{id}", UriKind.Relative);

            if (patientExists == false)
            {
                return(StatusCode(304));
            }
            await _patientService.UpdatePatient(id, patientRequest);

            return(Ok());
        }
Esempio n. 15
0
        public async Task <IActionResult> AddPatient(PatientRequest patientRequest)
        {
            var patientExists = await _patientService.CheckIfAlreadyPresent(patientRequest);

            var patientUri = new Uri($"v1/patients", UriKind.Relative);

            if (patientExists != null)
            {
                return(Conflict(patientExists));
            }
            var addPatientTask = _patientService.AddPatient(patientRequest);
            var patient        = await addPatientTask;

            return(Created(patientUri, patient));
        }
Esempio n. 16
0
        public ActionResult CreateOrEditPatient(PatientModel _model)
        {
            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }

            if (_model == null)
            {
                if (Session["PatientModel"] == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }
                else
                {
                    _model = (PatientModel)Session["PatientModel"];
                }
            }
            var request = new PatientRequest
            {
                Data = _model
            };

            PatientResponse _response = new PatientValidator(_unitOfWork, _context).Validate(request);

            if (_response.IsNeedConfirmation)
            {
                Session["PatientModel"] = _model;
            }
            ViewBag.Response     = $"{_response.Status};{_response.Message}";
            ViewBag.Confirmation = $"{_response.IsNeedConfirmation};{_response.Message}";
            ViewBag.Relation     = BindDropDownRelation();
            ViewBag.PatientType  = BindDropDownPatientType();
            ViewBag.City         = BindDropDownCity();
            ViewBag.EmpReff      = BindDropDownEmployeeReff();
            ViewBag.Marital      = BindDropDownMaritalStatus();
            ViewBag.ReffRelation = BindDropDownReffRelation();
            ViewBag.ActionType   = request.Data.Id > 0 ? ClinicEnums.Action.Edit : ClinicEnums.Action.Add;

            if (_response.Status && _model.IsFromRegistration)
            {
                return(RedirectToAction("CreateRegistrationForNewPatient", "Loket", new { patientID = _response.Entity.Id }));
            }
            else
            {
                return(View("CreateOrEditPatient", _model));
            }
        }
Esempio n. 17
0
        public JsonResult DeletePatient(int id)
        {
            var request = new PatientRequest
            {
                Data = new PatientModel
                {
                    Id      = id,
                    Account = Session["UserLogon"] == null ? new AccountModel() : (AccountModel)Session["UserLogon"]
                },
                Action = ClinicEnums.Action.DELETE.ToString()
            };

            PatientResponse _response = new PatientValidator(_unitOfWork, _context).Validate(request);

            return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
        public async Task CreateAsync(PatientRequest request)
        {
            Patient patient = Protect(request);

            var inBase = await applicationContext.Patients.FirstOrDefaultAsync(x => x.Name == patient.Name &&
                                                                               x.Surname == patient.Surname &&
                                                                               x.DOB == patient.DOB);

            if (inBase != null)
            {
                throw new Exception(localizer["Patient already exists."]);
            }

            await applicationContext.Patients.AddAsync(patient);

            await applicationContext.SaveChangesAsync();
        }
Esempio n. 19
0
        public static bool AddNewAppointment(DateTime timeStart, DateTime timeEnd, int docId, int currentUserId)
        {
            var todaydate = DateTime.Today.ToString("dd/MM/yyyy");

            using (DoctorAppoinmentDbContext db = new DoctorAppoinmentDbContext())
            {
                PatientRequest newReq = new PatientRequest();
                newReq.UserId    = currentUserId;
                newReq.DocId     = docId;
                newReq.Date      = todaydate;
                newReq.TimeStart = timeStart;
                newReq.TimeEnd   = timeEnd;
                db.PatientRequests.Add(newReq);
                db.SaveChanges();
                return(true);
            }
        }
Esempio n. 20
0
        public virtual int AddTestRequest(PatientRequest testRequest)
        {
            SqlConnection connection = new SqlConnection(Connection);

            string query = "INSERT INTO [PatientRequestTest] VALUES(@PatientID,@TestID)";

            connection.Open();

            SqlCommand command = new SqlCommand(query, connection);

            command.Parameters.AddWithValue("@PatientID", testRequest.patientID);
            command.Parameters.AddWithValue("@TestID", testRequest.TestID);

            int rowAffected = command.ExecuteNonQuery();

            return(rowAffected);
        }
Esempio n. 21
0
        public ActionResult CreateOrEditPatient()
        {
            PatientResponse _response = new PatientResponse();

            if (Request.QueryString["id"] != null)
            {
                var request = new PatientRequest
                {
                    Data = new PatientModel
                    {
                        Id = long.Parse(Request.QueryString["id"].ToString()),
                    }
                };
                if (Session["UserLogon"] != null)
                {
                    request.Data.Account = (AccountModel)Session["UserLogon"];
                }

                PatientResponse resp = new PatientHandler(_unitOfWork, _context).GetDetail(request);

                PatientModel _model = resp.Entity;

                ViewBag.Response     = _response;
                ViewBag.Relation     = BindDropDownRelation();
                ViewBag.PatientType  = BindDropDownPatientType();
                ViewBag.City         = BindDropDownCity();
                ViewBag.EmpReff      = BindDropDownEmployeeReff();
                ViewBag.Marital      = BindDropDownMaritalStatus();
                ViewBag.ReffRelation = BindDropDownReffRelation();
                ViewBag.ActionType   = ClinicEnums.Action.Edit;
                return(View(_model));
            }
            else
            {
                ViewBag.ActionType   = ClinicEnums.Action.Add;
                ViewBag.Response     = _response;
                ViewBag.Relation     = BindDropDownRelation();
                ViewBag.PatientType  = BindDropDownPatientType();
                ViewBag.EmpReff      = BindDropDownEmployeeReff();
                ViewBag.Marital      = BindDropDownMaritalStatus();
                ViewBag.City         = BindDropDownCity();
                ViewBag.ReffRelation = BindDropDownReffRelation();
                return(View("CreateOrEditPatient", new PatientModel()));
            }
        }
Esempio n. 22
0
        protected void btnTestRequst_Click(object sender, EventArgs e)
        {
            if (txtMobileNo.Text.Length != 11)
            {
                messageLabel.ForeColor = Color.Red;
                messageLabel.Text      = "Please Enter valid mobile No.";
                return;
            }
            else
            {
                messageLabel.Text = "";
                testList          = (List <Tests>)ViewState["Test"];

                string   name        = txtPatientName.Text;
                DateTime dateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text);
                int      mobileNo    = Convert.ToInt32(txtMobileNo.Text);
                HiddenField1.Value = patientManager.Get8Digits();
                string   billNo   = HiddenField1.Value;
                DateTime billDate = System.DateTime.Now;
                decimal  totalFee = testList.Sum(x => x.testFee);
                decimal  PaidBill = 0;

                Patients patient = new Patients(name, dateOfBirth, mobileNo, billNo, billDate, totalFee, PaidBill);

                try
                {
                    patientManager.AddPatient(patient);
                }
                catch (Exception exception)
                {
                    lblMessage.Visible = true;
                    lblMessage.Text    = exception.Message;
                }
                int PatientId = patientManager.GetAllPatient().Max(x => x.ID);
                foreach (var test in testList)
                {
                    int            patientID   = PatientId;
                    int            testID      = test.ID;
                    PatientRequest testRequest = new PatientRequest(patientID, testID);
                    TestRequestManager.AddTestRequest(testRequest);
                }

                Generate_PDF();
            }
        }
Esempio n. 23
0
        public async Task <PatientResponse> EditAsync(Guid id, PatientRequest request)
        {
            Patient newPatient = Protect(request);
            Patient patient    = await GetAsync(id);

            if (patient == null)
            {
                throw new Exception(localizer["Patient with this identifier doesn`t exist."]);
            }

            patient    = newPatient;
            patient.Id = id;

            applicationContext.Patients.Update(patient);
            await applicationContext.SaveChangesAsync();

            return(await GetPatientResponseAsync(patient.Id));
        }
        public async Task <Patient> UpdatePatient(Guid id, PatientRequest patientRequest)
        {
            var response = await _database.UpdatePatient(patientRequest, id);

            return(new Patient
            {
                Id = response.Id,
                Email = response.Email,
                DateOfBirth = response.DateOfBirth,
                CreatedAt = response.CreatedAt.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:sszzz"),
                FirstName = response.FirstName,
                Gender = response.Gender,
                IsActive = response.IsActive,
                LastName = response.LastName,
                Phone = response.Phone,
                UpdatedAt = response.UpdatedAt.HasValue ?
                            response.UpdatedAt.Value.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:sszzz") : string.Empty
            });
        }
Esempio n. 25
0
 public System.IAsyncResult BeginDoseCheck(
     Credentials credentials,
     AccountRequest accountRequest,
     PatientRequest patientRequest,
     PatientInformationRequester patientInformationRequester,
     string drugId,
     string drugTypeId,
     string birthDateCCYYMMDD,
     string gender,
     string diagnosis,
     string doseType,
     string dose,
     string doseUOM,
     string weightInKg,
     string includeSchema,
     System.AsyncCallback callback,
     object asyncState)
 {
     return(base.Channel.BeginDoseCheck(credentials, accountRequest, patientRequest, patientInformationRequester, drugId, drugTypeId, birthDateCCYYMMDD, gender, diagnosis, doseType, dose, doseUOM, weightInKg, includeSchema, callback, asyncState));
 }
Esempio n. 26
0
 public System.IAsyncResult BeginDrugSearchWithFormularyWithFavoritesV2(
     Credentials credentials,
     AccountRequest accountRequest,
     PatientRequest patientRequest,
     PatientInformationRequester patientInformationRequester,
     string healthplanID,
     string healthplanTypeID,
     string eligibilityIndex,
     string drugName,
     string includeObsolete,
     string searchBrandGeneric,
     string searchRxOTC,
     string searchDrugSupply,
     string locationId,
     string providerId,
     System.AsyncCallback callback,
     object asyncState)
 {
     return(base.Channel.BeginDrugSearchWithFormularyWithFavoritesV2(credentials, accountRequest, patientRequest, patientInformationRequester, healthplanID, healthplanTypeID, eligibilityIndex, drugName, includeObsolete, searchBrandGeneric, searchRxOTC, searchDrugSupply, locationId, providerId, callback, asyncState));
 }
Esempio n. 27
0
 public Result DrugSearchWithFormularyWithFavoritesV3(
     Credentials credentials,
     AccountRequest accountRequest,
     PatientRequest patientRequest,
     PatientInformationRequester patientInformationRequester,
     string healthplanId,
     string healthplanTypeId,
     string eligibilityIndex,
     string drugName,
     string drugTypeId,
     string includeObsolete,
     string searchBrandGeneric,
     string searchRxOTC,
     string searchDrugSupply,
     string locationId,
     string providerId,
     string includeCopay,
     string includeSchema)
 {
     return(base.Channel.DrugSearchWithFormularyWithFavoritesV3(credentials, accountRequest, patientRequest, patientInformationRequester, healthplanId, healthplanTypeId, eligibilityIndex, drugName, drugTypeId, includeObsolete, searchBrandGeneric, searchRxOTC, searchDrugSupply, locationId, providerId, includeCopay, includeSchema));
 }
Esempio n. 28
0
        public async Task <DatabaseModels.Patient> UpdatePatient(PatientRequest patientRequest, Guid id)
        {
            var request = new DatabaseModels.Patient
            {
                Id          = id,
                UpdatedAt   = DateTime.Now,
                Email       = patientRequest.Email,
                DateOfBirth = patientRequest.DateOfBirth,
                FirstName   = patientRequest.FirstName,
                Gender      = patientRequest.Gender,
                IsActive    = patientRequest.IsActive,
                LastName    = patientRequest.LastName,
                Phone       = patientRequest.Phone
            };
            var entry = _apiContext.Patients.First(e => e.Id == request.Id);

            _apiContext.Entry(entry).CurrentValues.SetValues(request);

            var response = await _apiContext.SaveChangesAsync();

            return(request);
        }
Esempio n. 29
0
        public JsonResult UseExistingPatientData(string isUseExisting)
        {
            var _model    = new PatientModel {
            };
            var _response = new PatientResponse {
            };

            if (Session["UserLogon"] != null)
            {
                _model.Account = (AccountModel)Session["UserLogon"];
            }

            if (Session["PatientModel"] != null)
            {
                _model = (PatientModel)Session["PatientModel"];
                _model.IsUseExistingData = isUseExisting == "yes" ? true : false;
                var request = new PatientRequest
                {
                    Data = _model
                };
                _response        = new PatientValidator(_unitOfWork, _context).Validate(request);
                ViewBag.Response = $"{_response.Status};{_response.Message}";

                ViewBag.Relation     = BindDropDownRelation();
                ViewBag.PatientType  = BindDropDownPatientType();
                ViewBag.City         = BindDropDownCity();
                ViewBag.EmpReff      = BindDropDownEmployeeReff();
                ViewBag.Marital      = BindDropDownMaritalStatus();
                ViewBag.ReffRelation = BindDropDownReffRelation();
                ViewBag.ActionType   = request.Data.Id > 0 ? ClinicEnums.Action.Edit : ClinicEnums.Action.Add;
            }
            else
            {
                _response.Status  = false;
                _response.Message = Messages.SessionExpired;
            }

            return(Json(new { Status = _response.Status, Message = _response.Message }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 30
0
        public async Task <DatabaseModels.Patient> AddPatient(PatientRequest patientRequest)
        {
            var request = new DatabaseModels.Patient
            {
                Id          = new Guid(),
                CreatedAt   = DateTime.Now,
                UpdatedAt   = DateTime.Now,
                Email       = patientRequest.Email,
                DateOfBirth = patientRequest.DateOfBirth,
                FirstName   = patientRequest.FirstName,
                Gender      = patientRequest.Gender,
                IsActive    = patientRequest.IsActive,
                LastName    = patientRequest.LastName,
                Phone       = patientRequest.Phone
            };

            _apiContext.Patients.Add(request);

            var response = await _apiContext.SaveChangesAsync();

            return(request);
        }
Esempio n. 31
0
    public PatientResponse GetPatient(PatientRequest request)
    {
        PatientResponse response = new PatientResponse();

        // Set correlation Id
        response.CorrelationId = request.RequestId;

        try
        {

            // Get customer patient via Patient Facade.
            PatientFacade facade = new PatientFacade();
           response.Name = facade.GetPatient(request.PatientID);

        }
        catch // (Exception ex)
        {
            response.Acknowledge = AcknowledgeType.Failure;
            response.Message = "Request cannot be handled at this time.";
        }

        return response;
    }
 public void Delete(PatientRequest request)
 {
     this.repo.Delete(request);
     this.repo.SaveChanges();
 }
    private void PostSchedule(System.DateTime dateDayToLoad)
    {
        // get selected date's schedule
        if (!string.IsNullOrEmpty(txtDate.Text))
            apptTransfer.date = Convert.ToDateTime(this.txtDate.Text);
        else
        {
            apptTransfer.date = DateTime.Now;
            txtDate.Text = DateTime.Now.ToShortDateString();
        }
        apptTransfer.doctorID = Convert.ToInt32(Session["DocID"]);
        aRequest.date = apptTransfer.date;
        aRequest.docID = apptTransfer.doctorID;
        System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
        proxy = new WebRef.Service();

        // Proxy must accept and hold cookies
        //   proxy.CookieContainer = new System.Net.CookieContainer();
        proxy.Url = new Uri(proxy.Url).AbsoluteUri;
        AppointmentResponse aResponse = proxy.GetDocSchedule(aRequest);
        dsSchedule = aResponse.ds;
        Session["day"] = adap.GetData(DateTime.Now.Day, DateTime.Now.Month, Convert.ToInt32(Session["DocID"]));

        try
        {
            // For each time slot
            for (int x = 0; x < 19; ++x)
            {
                // If value is available, unavailable, or in class.
                if (dsSchedule.Tables[1].Rows[0][x + 8].ToString() == "Yes" || dsSchedule.Tables[1].Rows[0][x + 8].ToString() == "No")
                {
                    cmbArray[x].SelectedValue = dsSchedule.Tables[1].Rows[0][x + 8].ToString();
                }

                // If value is a student appointment
                if (dsSchedule.Tables[1].Rows[0][x + 8].ToString().StartsWith("P"))
                {
                    System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
                    proxy = new WebRef.Service();

                    // Proxy must accept and hold cookies
                    //   proxy.CookieContainer = new System.Net.CookieContainer();
                    proxy.Url = new Uri(proxy.Url).AbsoluteUri;

                    PatientRequest pRequest = new PatientRequest();
                    pRequest.PatientID = Convert.ToInt32(dsSchedule.Tables[1].Rows[0][x + 8].ToString().Substring(3));

                    PatientResponse pResponse = proxy.GetPatient(pRequest);

                    //dsStudent = new DataSet();
                    //// Get student ID
                    //strStudentID = dsSchedule.Tables[0].Rows[0][x+8].ToString().Substring(3);

                    //// Set up SQL query to retrieve student's name
                    //string[] strSelect = new string[2] {"First_Name", "Last_Name"};
                    //string[] strWhere = new string [2] {"PAT", strStudentID};

                    //// Execute query
                    //dsStudent = dbMangler.SelectQuery("SDT", strSelect, strWhere);

                    //// Build student's name
                    //strStudentName = dsStudent.Tables[0].Rows[0][0] + " " + dsStudent.Tables[0].Rows[0][1];

                    //// Add and display student's name to combo box
                    cmbArray[x].Items.Add(new ListItem(pResponse.Name, "PAT" + pRequest.PatientID));
                    cmbArray[x].SelectedValue = "PAT" + pRequest.PatientID;
                }

            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = ex.ToString();
        }

        //btnSubmit.Enabled = true;
        btnFlip.Enabled = true;
    }
 public void Update(PatientRequest request)
 {
     this.repo.Update(request);
     this.repo.SaveChanges();
 }
Esempio n. 35
0
        public async Task <OutputResponse> Add(PatientRequest request)
        {
            using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var mappedPatient = new AutoMapperHelper <PatientDTO, DAL.Models.Patients>().MapToObject(request.Patient);
                mappedPatient.RowAction   = "I";
                mappedPatient.DateCreated = DateTime.UtcNow;

                //if its not data entry (DE), it implies that is self-registration that requires
                //to be confirmed before it becomes a case to avoid bogus reporting
                //and also, set for default values for registration
                if (!mappedPatient.SourceId.ToUpper().Equals("DE"))
                {
                    mappedPatient.IsConfirmed = false;

                    //default mappings
                    var registrationMapping = await _context.RegistrationMappings.FirstOrDefaultAsync();

                    mappedPatient.PatientStatusId  = registrationMapping.PatientStatusId;
                    mappedPatient.DataCenterId     = registrationMapping.DataCenterId;
                    mappedPatient.ClassificationId = registrationMapping.ClassificationId;
                }

                var addedPatient = await _context.Patients.AddAsync(mappedPatient);

                await _context.SaveChangesAsync();

                var patientHistory = new PatientHistory
                {
                    CreatedBy       = request.Patient.CreatedBy,
                    DateCreated     = DateTime.UtcNow,
                    DateReported    = DateTime.UtcNow.Date,
                    PatientId       = addedPatient.Entity.PatientId,
                    PatientStatusId = mappedPatient.PatientStatusId
                };
                await _context.PatientHistory.AddAsync(patientHistory);

                //add the specified symptoms
                foreach (var status in request.PatientDailyStatuses)
                {
                    var mappedStatus = new AutoMapperHelper <PatientDailyStatusDTO, PatientDailyStatuses>().MapToObject(status);
                    mappedStatus.DateCreated   = DateTime.UtcNow;
                    mappedStatus.DateSubmitted = DateTime.UtcNow.Date;
                    mappedStatus.PatientId     = addedPatient.Entity.PatientId;

                    await _context.PatientDailyStatuses.AddAsync(mappedStatus);
                }

                var smsEndpoint = await _bus.GetSendEndpoint(new Uri(_customConfiguration.SmsQueueAddress));

                var emailEndpoint = await _bus.GetSendEndpoint(new Uri(_customConfiguration.EmailQueueAddress));

                var dhisEndpoint = await _bus.GetSendEndpoint(new Uri(_customConfiguration.PatientQueueAddress));

                var phoneNumbers         = new List <string>();
                var emailAddresses       = new List <string>();
                var responseTeamMappings = _context.ResponseTeamMappings.Include("TeamMember")
                                           .Where(x => x.DistrictCode.Equals(request.Patient.DistrictCode));

                foreach (var responseTeam in responseTeamMappings)
                {
                    var phoneNumber  = responseTeam.TeamMember.PhoneNumber;
                    var emailAddress = responseTeam.TeamMember.EmailAddress;

                    if (!string.IsNullOrEmpty(phoneNumber))
                    {
                        phoneNumbers.Add(phoneNumber);
                    }

                    if (!string.IsNullOrEmpty(emailAddress))
                    {
                        emailAddresses.Add(emailAddress);
                    }
                }
                await _context.SaveChangesAsync();

                var fullName = string.Concat(request.Patient.FirstName, " ", request.Patient.OtherNames, " ", request.Patient.LastName);


                if (phoneNumbers.Any() && File.Exists(_smsTemplate))
                {
                    var sms = await File.ReadAllTextAsync(_smsTemplate);

                    sms = sms.Replace("{{FULL_NAME}}", fullName);
                    sms = sms.Replace("{{PHONE_NUMBER}}", string.Concat("+", request.Patient.PhoneNumber));
                    await smsEndpoint.Send(new MessageModelRequest(new MessageModel
                    {
                        SourceAddress = "Thandizo",
                        DestinationRecipients = phoneNumbers,
                        MessageBody = sms
                    }));
                }

                if (emailAddresses.Any() && File.Exists(_customConfiguration.EmailTemplate))
                {
                    var district = await _context.Districts.FindAsync(request.Patient.DistrictCode);

                    var registrationSource = await _context.RegistrationSources.FindAsync(request.Patient.SourceId);

                    var email = await File.ReadAllTextAsync(_customConfiguration.EmailTemplate);

                    email = email.Replace("{{REGISTRATION_SOURCE}}", registrationSource.SourceName);
                    email = email.Replace("{{FULL_NAME}}", fullName);
                    email = email.Replace("{{PHONE_NUMBER}}", string.Concat("+", request.Patient.PhoneNumber));
                    email = email.Replace("{{PHYSICAL_ADDRESS}}", request.Patient.PhysicalAddress);
                    email = email.Replace("{{DISTRICT_NAME}}", district.DistrictName);
                    await emailEndpoint.Send(new MessageModelRequest(new MessageModel
                    {
                        SourceAddress = _customConfiguration.SourceEmailAddress,
                        Subject = _customConfiguration.RegistrationEmailSubject,
                        DestinationRecipients = emailAddresses,
                        MessageBody = email
                    }));
                }

                //for DHIS2 integration
                await dhisEndpoint.Send(new DhisPatientModelRequest(addedPatient.Entity.PatientId));

                scope.Complete();
            }
            return(new OutputResponse
            {
                IsErrorOccured = false,
                Message = MessageHelper.AddNewSuccess
            });
        }
 public void AddPatientRequest(PatientRequest request)
 {
     this.requests.Add(request);
     this.requests.Save();
 }
Esempio n. 37
0
    public PatientResponse GetPatients(PatientRequest request)
    {
        PatientResponse response = new PatientResponse();

        // Set correlation Id
        response.CorrelationId = request.RequestId;

        try
        {

            // Get customer list via Customer Facade.
            PatientFacade facade = new PatientFacade();
            IList<Patient> list = facade.GetPatients(request.SortExpression);

            response.Patients = new PatientTransferObject[list.Count];
            Console.WriteLine(list.Count.ToString());
            // Package customer data in Customer Transfer Object
            int index = 0;
            foreach (Patient patient in list)
            {
                PatientTransferObject transfer = new PatientTransferObject();

                transfer.PatientID = patient.PatientID;
                transfer.FName = patient.fName;
                transfer.LName = patient.LName;
                transfer.Phone = patient.Phone;

                response.Patients[index++] = transfer;
            }

        }
        catch // (Exception ex)
        {
            response.Acknowledge = AcknowledgeType.Failure;
            response.Message = "Request cannot be handled at this time.";
        }

        return response;
    }
 public void Add(PatientRequest request)
 {
     this.repo.Add(request);
     this.repo.SaveChanges();
 }