コード例 #1
0
        public IActionResult RegisterVisit()
        {
            Users user = new Users {
                Id = Int64.Parse(HttpContext.User.FindFirst(ClaimTypes.Actor).Value)
            };
            Patient patient = VisitModel.Visit.Patient;

            patient.Status = new PatientStatus
            {
                Id = Constants.STATUS_ACTIVE
            };
            patient.UpdateStatus();

            Encounter encounter = new Encounter
            {
                Type = new EncounterType {
                    Id = Constants.ENCOUNTER_VISIT
                },
                Patient   = patient,
                CreatedBy = user
            };

            encounter.Create(IPatientService);

            Visit visit = VisitModel.Visit;

            visit.Type = new VisitType {
                Id = Constants.VISIT_FACILITY
            };
            visit.CreatedBy = user;
            visit.CreatedOn = DateTime.Now;
            visit.Save();

            Referral referral = VisitModel.Referral;

            if (!referral.Type.Id.Equals(0))
            {
                referral.Visit     = visit;
                referral.CreatedBy = user;
                referral.Save();

                var      seps    = new string[] { "," };
                string[] doctors = VisitModel.DoctorString.Split(seps, StringSplitOptions.RemoveEmptyEntries);
                foreach (string doc in doctors)
                {
                    new ReferralDoctors
                    {
                        Referral = referral,
                        Doctor   = new Doctor {
                            Id = Convert.ToInt64(doc)
                        }
                    }.Save();
                }
            }

            Bills bill = VisitModel.Bill;

            bill.Visit     = visit;
            bill.CreatedBy = user;
            bill.Save();

            if (VisitModel.Waiver)
            {
                bill.Waiver       = bill.Amount;
                bill.WaiverReason = VisitModel.WaiverReason;
                bill.WaivedBy     = user;
                bill.UpdateWaiver();

                bill.Flag = new BillsFlag {
                    Id = 1
                };
                bill.ProcessedBy = user;
                bill.UpdateProcess();
            }

            BillsItem item = VisitModel.Item;

            item.Bill      = bill;
            item.CreatedBy = user;
            item.Save();

            Queues queue = VisitModel.Queue;

            queue.Bill      = bill;
            queue.CreatedBy = user;
            queue.Save();

            return(LocalRedirect("/registration/search"));
        }
コード例 #2
0
        public IActionResult RegisterVisit()
        {
            Users user = new Users {
                Id = Int64.Parse(HttpContext.User.FindFirst(ClaimTypes.Actor).Value)
            };
            Patient patient = VisitModel.Visit.Patient;

            patient.Status = new PatientStatus
            {
                Id = Constants.STATUS_ACTIVE
            };
            patient.UpdateStatus();

            Encounter encounter = new Encounter
            {
                Type = new EncounterType {
                    Id = Constants.ENCOUNTER_VISIT
                },
                Patient   = patient,
                CreatedBy = user
            };

            encounter.Create(IPatientService);

            Visit visit = VisitModel.Visit;

            visit.Type = new VisitType {
                Id = Constants.VISIT_FACILITY
            };
            visit.CreatedBy = user;
            visit.CreatedOn = DateTime.Now;
            visit.Save();

            Referral referral = VisitModel.Referral;

            if (!referral.Type.Id.Equals(0))
            {
                referral.Visit     = visit;
                referral.CreatedBy = user;
                referral.Save();

                var      seps    = new string[] { "," };
                string[] doctors = VisitModel.DoctorString.Split(seps, StringSplitOptions.RemoveEmptyEntries);
                foreach (string doc in doctors)
                {
                    new ReferralDoctors
                    {
                        Referral = referral,
                        Doctor   = new Doctor {
                            Id = Convert.ToInt64(doc)
                        }
                    }.Save();
                }
            }

            Bills bill = VisitModel.Bill;

            bill.Visit      = visit;
            bill.Department = new Department {
                Id = Constants.DEPT_REGISTRATION
            };
            bill.CreatedBy = user;
            bill.Save();

            if (VisitModel.Waiver)
            {
                bill.Waiver       = bill.Amount;
                bill.WaiverReason = VisitModel.WaiverReason;
                bill.WaivedBy     = user;
                bill.UpdateWaiver();

                bill.Flag = new BillingFlag {
                    Id = Constants.FLAG_CLEARED
                };
                bill.ProcessedBy = user;
                bill.UpdateProcess();
            }

            BillsItem item = VisitModel.Item;

            item.Bill      = bill;
            item.CreatedBy = user;
            item.Save();

            //INVOICE/FLAG/CLEAR
            if (VisitModel.Waiver)
            {
                Invoice invoice = new Invoice {
                    Patient = patient,
                    Flag    = new BillingFlag {
                        Id = Constants.FLAG_CLEARED
                    },
                    CreatedBy = user,
                    Notes     = "Waivered Bill"
                };
                invoice.Save();

                InvoiceDetails details = new InvoiceDetails {
                    Invoice   = invoice,
                    Item      = item,
                    CreatedBy = user,
                    Notes     = "Waivered Item"
                };
                details.Save();

                InvoicePayment payment = new InvoicePayment {
                    Invoice   = invoice,
                    CreatedBy = user,
                    Notes     = "Waiver Payment"
                };
                payment.Save();

                InvoicePaymentDetails pd = new InvoicePaymentDetails {
                    Mode = new BillingMode {
                        Id = Constants.MODE_WAIVER
                    },
                    Reference = "CASHIER-00",
                    Amount    = bill.Amount,
                    Notes     = "Waiver Payment"
                };
                pd.Save();
            }

            Queues queue = VisitModel.Queue;

            queue.Visit     = visit;
            queue.Item      = item;
            queue.CreatedBy = user;
            queue.Save();

            return(LocalRedirect("/registration/search"));
        }