Ejemplo n.º 1
0
        /// <summary>
        /// Get detail of registration
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public LoketResponse GetDetail(LoketRequest request)
        {
            LoketResponse response = new LoketResponse();

            QueuePoli qry = _unitOfWork.RegistrationRepository.GetFirstOrDefault(x => x.ID == request.Data.Id);

            if (qry != null)
            {
                response.Entity = Mapper.Map <QueuePoli, LoketModel>(qry);

                // reformat gender
                response.Entity.PatientGender = response.Entity.PatientGender == "M" ? Messages.Male : Messages.Female;
                response.Entity.PatientType   = response.Entity.PatientType == "2" ? Messages.Company : Messages.General;
                if (response.Entity.Type == (int)RegistrationTypeEnum.MCU)
                {
                    response.Entity.SortNumberCode = "M-" + string.Format("{0:D3}", qry.SortNumber);
                }
                else
                {
                    response.Entity.SortNumberCode = qry.Poli1.Code.Trim() + "-" + string.Format("{0:D3}", qry.SortNumber);
                }
                FormMedical formMedical = _unitOfWork.FormMedicalRepository.GetFirstOrDefault(x => x.ID == qry.FormMedicalID);
                if (formMedical != null)
                {
                    response.Entity.NecessityType = int.Parse(formMedical.Necessity);
                    response.Entity.PaymentType   = int.Parse(formMedical.PaymentType);
                    response.Entity.PaymentNumber = formMedical.Number;
                }
            }

            return(response);
        }
Ejemplo n.º 2
0
        public FormMedical update(long medicalid, FormMedical request)
        {
            FormMedical response = new FormMedical();
            var         qry      = _unitOfWork.FormMedicalRepository.GetById(medicalid);

            try
            {
                qry.BenefitPaid     = request.BenefitPaid;
                qry.BenefitPlan     = request.BenefitPlan;
                qry.DiscountAmount  = request.DiscountAmount;
                qry.DiscountPercent = request.DiscountPercent;
                qry.TotalPrice      = request.TotalPrice;
                qry.Remark          = request.Remark;
                _unitOfWork.FormMedicalRepository.Update(qry);
                _unitOfWork.Save();
                response = qry;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(response);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create or edit registration
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public LoketResponse CreateOrEdit(LoketRequest request)
        {
            LoketResponse response = new LoketResponse();

            try
            {
                if (request.Data.Id > 0)
                {
                    var qry = _unitOfWork.RegistrationRepository.GetById(request.Data.Id);
                    if (qry != null)
                    {
                        // save the old data
                        var _oldentity = Mapper.Map <QueuePoli, LoketModel>(qry);

                        // update data
                        qry.Status   = request.Data.Status;
                        qry.PoliFrom = request.Data.PoliFromID;
                        qry.PoliTo   = request.Data.PoliToID;
                        qry.DoctorID = request.Data.DoctorID;
                        qry.Type     = (short)request.Data.Type;
                        qry.ReffID   = request.Data.ReffID;
                        qry.Remark   = request.Data.Remark;
                        qry.DoctorID = request.Data.DoctorID == 0 ? (int?)null : request.Data.DoctorID;
                        qry.FormMedical.Necessity   = request.Data.NecessityType.ToString();
                        qry.FormMedical.PaymentType = request.Data.PaymentType.ToString();
                        qry.FormMedical.Number      = request.Data.PaymentNumber;

                        _unitOfWork.RegistrationRepository.Update(qry);
                        int resultAffected = _unitOfWork.Save();
                        if (resultAffected > 0)
                        {
                            response.Message = string.Format(Messages.ObjectHasBeenUpdated2, "Registration", qry.ID);

                            CommandLog(true, ClinicEnums.Module.REGISTRATION, Constants.Command.EDIT_REGISTRATION, request.Data.Account, request.Data, _oldentity);
                        }
                        else
                        {
                            response.Status  = false;
                            response.Message = string.Format(Messages.UpdateObjectFailed, "Registration");

                            CommandLog(false, ClinicEnums.Module.REGISTRATION, Constants.Command.EDIT_REGISTRATION, request.Data.Account, request.Data, _oldentity);
                        }
                    }
                    else
                    {
                        response.Status  = false;
                        response.Message = string.Format(Messages.UpdateObjectFailed, "Registration");

                        CommandLog(false, ClinicEnums.Module.REGISTRATION, Constants.Command.EDIT_REGISTRATION, request.Data.Account, request.Data);
                    }
                }
                else
                {
                    var queueEntity = Mapper.Map <LoketModel, QueuePoli>(request.Data);
                    queueEntity.CreatedBy       = request.Data.Account.UserCode;
                    queueEntity.CreatedDate     = DateTime.Now;
                    queueEntity.TransactionDate = DateTime.Now;
                    queueEntity.Status          = (int)RegistrationStatusEnum.New;
                    queueEntity.ClinicID        = GetClinicID(request.Data.Account.Organization);
                    queueEntity.PoliFrom        = 1;
                    queueEntity.SortNumber      = GenerateSortNumber(request.Data.PoliToID, request.Data.DoctorID);
                    queueEntity.DoctorID        = request.Data.DoctorID == 0 ? (int?)null : request.Data.DoctorID;

                    // create form medical
                    var formMedical = new FormMedical
                    {
                        ClinicID    = request.Data.Account.ClinicID,
                        PatientID   = request.Data.PatientID,
                        PaymentType = request.Data.PaymentType.ToString(),
                        Number      = request.Data.PaymentNumber,
                        Necessity   = request.Data.NecessityType.ToString(),
                        CreatedBy   = request.Data.Account.UserCode,
                        CreatedDate = DateTime.Now,
                        StartDate   = DateTime.Now,
                        EndDate     = DateTime.Now
                    };

                    // reference to queue
                    queueEntity.FormMedical = formMedical;

                    _unitOfWork.RegistrationRepository.Insert(queueEntity);
                    int resultAffected = _unitOfWork.Save();
                    if (resultAffected > 0)
                    {
                        response.Message = string.Format(Messages.ObjectHasBeenAdded, "Registration", queueEntity.PatientID, queueEntity.ID);

                        CommandLog(true, ClinicEnums.Module.REGISTRATION, Constants.Command.ADD_NEW_REGISTRATION, request.Data.Account, request.Data);
                    }
                    else
                    {
                        response.Status  = false;
                        response.Message = string.Format(Messages.AddObjectFailed, "Registration");

                        CommandLog(false, ClinicEnums.Module.REGISTRATION, Constants.Command.ADD_NEW_REGISTRATION, request.Data.Account, request.Data);
                    }
                }
            }
            catch (Exception ex)
            {
                response.Status  = false;
                response.Message = Messages.GeneralError;

                if (request.Data != null && request.Data.Id > 0)
                {
                    ErrorLog(ClinicEnums.Module.REGISTRATION, Constants.Command.EDIT_REGISTRATION, request.Data.Account, ex);
                }
                else
                {
                    ErrorLog(ClinicEnums.Module.REGISTRATION, Constants.Command.ADD_NEW_REGISTRATION, request.Data.Account, ex);
                }
            }

            return(response);
        }
Ejemplo n.º 4
0
        public ActionResult Save(long medicalid, FormMedical formMedical)
        {
            var response = new CashierHandler(_unitOfWork).update(medicalid, formMedical);

            return(RedirectToAction("ListPatien", "Cashier"));
        }