예제 #1
0
        public List <OPDHistoryModel> GetGenericReport(Expression <Func <OPDHistory, bool> > predicate)
        {
            try
            {
                List <OPDHistoryModel> list = new List <OPDHistoryModel>();

                using (var db = new HMSEntities())
                {
                    var data = db.OPDHistories.Where(predicate).OrderBy(t => t.InTime).ToList();
                    foreach (OPDHistory t in data)
                    {
                        OPDHistoryModel model = new OPDHistoryModel();
                        model.Id                  = t.Id;
                        model.PatientId           = t.PatientId;
                        model.PatientName         = t.PatientDetail != null ? t.PatientDetail.FullName : "";
                        model.CasePaperNumber     = t.PatientDetail != null ? t.PatientDetail.CasePaperNumber : "";
                        model.Sequence            = t.Sequence;
                        model.InTime              = t.InTime;
                        model.OutTime             = t.OutTime;
                        model.IsCharity           = t.IsCharity;
                        model.IsLabCharity        = t.IsLabCharity;
                        model.ECGAmount           = t.ECGAmount;
                        model.ConsultingDoctorId  = t.ConsultingDoctorId;
                        model.DoctorNames         = t.DoctorDetail.FullName;
                        model.IsECG               = t.IsECG.HasValue ? t.IsECG : false;
                        model.IsXRAY              = t.IsXRAY.HasValue ? t.IsXRAY : false;
                        model.XRAYAmount          = t.XRAYAmount;
                        model.NumberofXRAY        = t.NumberofXRAY.HasValue ? t.NumberofXRAY : 0;
                        model.ThirdPartyLabId     = t.ThirdPartyLabId;
                        model.ThirdPartyLabAmoumt = t.ThirdPartyLabAmoumt;
                        model.StatusId            = t.StatusId;
                        model.StatusName          = t.Status != null ? t.Status.Name : "";
                        model.Amount              = t.Amount;
                        model.PaidAmount          = t.PaidAmount;
                        model.DueAmount           = t.DueAmount;
                        model.TotalAmount         = t.TotalAmount;
                        model.LabTestingAmount    = t.LabTestingAmount;
                        model.ReceivedBy          = t.ReceivedBy;
                        model.Diagnose            = t.Diagnose;
                        model.Madicines           = t.Madicines;
                        model.CreatedBy           = t.CreatedBy;
                        model.ModifiedBy          = t.ModifiedBy;
                        model.OPDHistoryUpdates   = new List <OPDHistoryUpdateModel>();
                        model.OPDHistoryUpdates.AddRange(OPDHistoryUpdate.GetPayingPatient(model.Id.Value));
                        model.TPLabs = new List <LookupModel>();
                        model.TPLabs.AddRange(TPLabPatientMapping.GetLabByOPD(model.Id.Value));
                        list.Add(model);
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public bool Print(Guid?id, string printOption)
        {
            try
            {
                OPDHistory      entity = new OPDHistory();
                OPDHistoryModel model  = entity.GetById(id.Value);

                string renamefileName = DateTime.Now.Ticks.ToString() + ".pdf";
                string path           = ConfigurationManager.AppSettings["SaveReport"].ToString() + DateTime.Now.ToString("dd-MM-yyyy");
                if (ErrorLog.IsFolderExist(path))
                {
                    path = path + "\\" + renamefileName;
                }


                // Create a Document object //
                var document = new iTextSharp.text.Document(PageSize.A4, 50, 50, 10, 10);

                // Create a new PdfWrite object, writing the output to a MemoryStream //
                FileStream output = new FileStream(path, FileMode.Create);
                var        writer = PdfWriter.GetInstance(document, output);

                // Method To Set Page Header And Footer //
                //setBillHeaderFooter(writer, document);

                // Open the Document for writing //
                document.Open();

                if (printOption == "Bill")
                {
                    setBillPageBody(document, model);
                    new BillHistory().Update(model.Id);
                }
                else if (printOption == "Prescription")
                {
                    setPrescriptionPageBody(document, model);
                }
                else if (printOption == "Both")
                {
                    setBillPageBody(document, model);
                    setPrescriptionPageBody(document, model);
                }

                // flush and clear the document from memory //
                document.Close();

                System.Diagnostics.Process.Start(path);

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        private void setPrescriptionPageBody(Document document, OPDHistoryModel model)
        {
            try
            {
                var boldTableFont  = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["bodyboldTable11"]), iTextSharp.text.Font.BOLD);
                var bodyFontNormal = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["bodyboldTable12"]), iTextSharp.text.Font.NORMAL);
                var headerFont     = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["headerFont"]), iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);
                var bigheaderFont  = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["bigheaderFont"]), iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);

                setPrescriptionPageHeader(document);

                PdfPTable table = new PdfPTable(2);
                table.DeleteBodyRows();
                table.WidthPercentage     = 100;
                table.HorizontalAlignment = 0;
                table.SpacingBefore       = 5;
                table.SpacingAfter        = 10;

                newCell(table, "DRUG SLIP", bigheaderFont, 1, 2, 2);
                blankCell(table, 2);
                newCell(table, "Name : " + model.PatientDetails.FullName, bodyFontNormal);
                newCell(table, "Date. : " + model.InTime.Value.ToShortDateString(), bodyFontNormal, 2, 0);
                newCell(table, "O.P.D No. : " + model.CasePaperNumber, bodyFontNormal, 0, 0, 2);

                blankCell(table, 2);
                newCell(table, "", bodyFontNormal, 0, 2, 2);
                newCell(table, "Rx", bigheaderFont, 0, 0);
                newCell(table, "Date: " + DateTime.Now.ToShortDateString(), boldTableFont, 2, 0);
                blankCell(table, 2);


                string[] splitArray = model.Madicines.Split(new string[] { "\\line" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var item in splitArray)
                {
                    string[] spArray = item.Split('$');
                    newCell(table, spArray[0].Trim(), bodyFontNormal, 0, 0);
                    newCell(table, spArray[1].Trim(), bodyFontNormal, 0, 0);
                    blankCell(table, 2);
                }

                for (int i = 0; i < 5; i++)
                {
                    blankCell(table, 2);
                }
                newCell(table, "Doctor's Sign.", bodyFontNormal, 2, 0, 2);
                document.Add(table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
 public bool Update(OPDHistoryModel model)
 {
     try
     {
         OPDHistory entity = new OPDHistory();
         return(entity.Update(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
        public OPDHistoryModel GetById(Guid id)
        {
            try
            {
                OPDHistoryModel model = new OPDHistoryModel();
                using (var db = new HMSEntities())
                {
                    OPDHistory entity = db.OPDHistories.Find(id);
                    if (entity != null)
                    {
                        model.Id                  = entity.Id;
                        model.PatientId           = entity.PatientId;
                        model.PatientName         = entity.PatientDetail != null ? entity.PatientDetail.FullName : "";
                        model.CasePaperNumber     = entity.PatientDetail != null ? entity.PatientDetail.CasePaperNumber : "";
                        model.Sequence            = entity.Sequence;
                        model.InTime              = entity.InTime;
                        model.OutTime             = entity.OutTime;
                        model.IsCharity           = entity.IsCharity;
                        model.IsLabCharity        = entity.IsLabCharity;
                        model.IsECG               = entity.IsECG.HasValue ? entity.IsECG : false;
                        model.IsXRAY              = entity.IsXRAY.HasValue ? entity.IsXRAY : false;
                        model.StatusId            = entity.StatusId;
                        model.StatusName          = entity.Status != null ? entity.Status.Name : "";
                        model.Amount              = entity.Amount;
                        model.PaidAmount          = entity.PaidAmount;
                        model.DueAmount           = entity.DueAmount;
                        model.TotalAmount         = entity.TotalAmount;
                        model.LabTestingAmount    = entity.LabTestingAmount;
                        model.ECGAmount           = entity.ECGAmount;
                        model.XRAYAmount          = entity.XRAYAmount;
                        model.NumberofXRAY        = entity.NumberofXRAY.HasValue ? entity.NumberofXRAY : 0;
                        model.ReceivedBy          = entity.ReceivedBy;
                        model.ConsultingDoctorId  = entity.ConsultingDoctorId;
                        model.ThirdPartyLabId     = entity.ThirdPartyLabId;
                        model.ThirdPartyLabAmoumt = entity.ThirdPartyLabAmoumt;
                        model.Diagnose            = entity.Diagnose;
                        model.Madicines           = entity.Madicines;
                        model.CreatedBy           = entity.CreatedBy;
                        model.ModifiedBy          = entity.ModifiedBy;
                        model.PatientDetails      = PatientDetail.SetModel(entity.PatientDetail);
                    }
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        private OPDHistoryModel assignModel()
        {
            try
            {
                OPDHistoryModel model = new OPDHistoryModel();
                model.Id               = this.primaryId;
                model.Diagnose         = !string.IsNullOrEmpty(rtxtDiagnose.Text) ? readRichTextbox(rtxtDiagnose.Lines) : "";
                model.Madicines        = !string.IsNullOrEmpty(rtxtMedicine.Text) ? readRichTextbox(rtxtMedicine.Lines) : "";
                model.StatusId         = new Guid(ddlStatus.SelectedValue.ToString());
                model.Amount           = !string.IsNullOrEmpty(txtOPDAmount.Text) ? Convert.ToDecimal(txtOPDAmount.Text) : Convert.ToDecimal(0.00);
                model.LabTestingAmount = !string.IsNullOrEmpty(txtLabAmount.Text) ? Convert.ToDecimal(txtLabAmount.Text) : Convert.ToDecimal(0.00);
                model.PayingAmount     = !string.IsNullOrEmpty(txtPayingAmount.Text) ? Convert.ToDecimal(txtPayingAmount.Text) : Convert.ToDecimal(0.00);
                model.PaidAmount       = !string.IsNullOrEmpty(txtPaidAmount.Text) ? Convert.ToDecimal(txtPaidAmount.Text) : Convert.ToDecimal(0.00);
                initialPaid            = model.PaidAmount.Value;
                model.DueAmount        = !string.IsNullOrEmpty(txtDueAmount.Text) ? Convert.ToDecimal(txtDueAmount.Text) : Convert.ToDecimal(0.00);
                initialDues            = model.DueAmount.Value;
                model.TotalAmount      = !string.IsNullOrEmpty(lblTotalAmount.Text) ? Convert.ToDecimal(lblTotalAmount.Text) : Convert.ToDecimal(0.00);
                model.PatientId        = patientId;
                model.InTime           = dtpInTime.Value;
                model.IsCharity        = chkCharity.Checked;
                model.IsLabCharity     = chkLabCharity.Checked;
                model.IsECG            = chkECG.Checked;
                model.IsXRAY           = chkXRay.Checked;
                model.ECGAmount        = !string.IsNullOrEmpty(txtECG.Text) ? Convert.ToDecimal(txtECG.Text) : Convert.ToDecimal(0.00);
                model.XRAYAmount       = !string.IsNullOrEmpty(txtXRay.Text) ? Convert.ToDecimal(txtXRay.Text) : Convert.ToDecimal(0.00);
                model.Sequence         = sequence;
                //if (ddlThirdParty.SelectedIndex > 0)
                //    model.ThirdPartyLabId = new Guid(ddlThirdParty.SelectedValue.ToString());

                model.ThirdPartyLabAmoumt = !string.IsNullOrEmpty(txtThirdPartyAmount.Text) ? Convert.ToDecimal(txtThirdPartyAmount.Text) : Convert.ToDecimal(0.00);
                //if (ddlConsulting.SelectedIndex > 0)
                model.ConsultingDoctorId = new Guid(ddlConsulting.SelectedValue.ToString());
                model.NumberofXRAY       = chkXRay.Checked && txtNumberOfXRay.Text != string.Empty ? Convert.ToInt32(txtNumberOfXRay.Text) : 0;
                return(model);
            }
            catch (Exception ex)
            {
                Utility.ErrorLog.Logging("OPD History", ex.Message.ToString(), ex.StackTrace.ToString());
                return(null);
            }
        }
        public bool CreateOPD(PatientDetailModel model)
        {
            try
            {
                bool isSaved = false;


                using (var db = new HMSEntities())
                {
                    bool isExpire = UpdateCasePaperDate(model);

                    OPDHistoryModel historyEntity = new OPDHistoryModel();
                    historyEntity.PatientId       = model.Id;
                    historyEntity.InTime          = DateTime.Now;
                    historyEntity.IsCharity       = false;
                    historyEntity.IsLabCharity    = false;
                    historyEntity.IsECG           = false;
                    historyEntity.IsXRAY          = false;
                    historyEntity.CasePaperNumber = model.CasePaperNumber;
                    //historyEntity.Amount = isExpire ? OPDRate.GetRatesByType("New").Rate : OPDRate.GetRatesByType("FollowUP").Rate;
                    //historyEntity.DueAmount = isExpire ? OPDRate.GetRatesByType("New").Rate : OPDRate.GetRatesByType("FollowUP").Rate;
                    historyEntity.ECGAmount           = 0.00M;
                    historyEntity.XRAYAmount          = 0.00M;
                    historyEntity.ThirdPartyLabAmoumt = 0.00M;
                    historyEntity.ConsultingDoctorId  = new DoctorDetail().GetName("SIR");
                    historyEntity.TotalAmount         = historyEntity.PaidAmount = historyEntity.LabTestingAmount = Convert.ToDecimal(0.00);
                    historyEntity.PatientDetails      = new PatientDetailModel();
                    historyEntity.PatientDetails      = model;
                    historyEntity.NumberofXRAY        = 0;

                    isSaved = new OPDHistory().Create(historyEntity, isExpire ? 0 : 1);
                }

                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        private bool saveData()
        {
            try
            {
                bool            isSave = false;
                OPDHistoryModel model  = assignModel();
                if (model != null)
                {
                    isSave = service.Update(assignModel());
                    if (isSave)
                    {
                        //if (isStatusHasInProgress)
                        //{
                        if (sequence != null)
                        {
                            TokenList frm = TokenList.Instance;
                            frm.removeSequence(sequence.Value);
                        }

                        //}
                        return(isSave);
                    }
                    else
                    {
                        return(isSave);
                    }
                }
                else
                {
                    return(isSave);
                }
            }
            catch (Exception ex)
            {
                Utility.ErrorLog.Logging("OPD History", ex.Message.ToString(), ex.StackTrace.ToString());
                return(false);
            }
        }
예제 #9
0
        private void setBillPageBody(iTextSharp.text.Document document, OPDHistoryModel model)
        {
            try
            {
                var boldTableFont  = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["bodyboldTable11"]), iTextSharp.text.Font.BOLD);
                var bodyFontNormal = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["bodyboldTable12"]), iTextSharp.text.Font.NORMAL);
                var headerFont     = FontFactory.GetFont("verdana", Convert.ToInt32(ConfigurationManager.AppSettings["headerFont"]), iTextSharp.text.Font.BOLD, iTextSharp.text.Color.BLACK);

                setBillPageHeader(document);

                //Patient Details
                PdfPTable table = new PdfPTable(2);
                table.DeleteBodyRows();
                table.WidthPercentage     = 100;
                table.HorizontalAlignment = 0;
                table.SpacingBefore       = 5;
                table.SpacingAfter        = 10;


                newCell(table, "Name : " + model.PatientDetails.FullName, boldTableFont, 0, 0);
                newCell(table, "Date. : " + model.InTime.Value.ToShortDateString(), boldTableFont, 2, 0);
                newCell(table, "O.P.D No. : " + model.CasePaperNumber, boldTableFont, 0, 0);
                newCell(table, "Receipt No. : " + new BillHistory().GetByOPDId(model.Id.Value).ReceiptNumber.ToString(), boldTableFont, 2, 0);

                document.Add(table);

                // Bill Details
                table = new PdfPTable(3);
                table.DeleteBodyRows();
                table.WidthPercentage     = 100;
                table.HorizontalAlignment = 0;
                table.SpacingBefore       = 5;
                table.SpacingAfter        = 10;



                newCell(table, "Received for ", boldTableFont, -1, -1, 2);
                newCell(table, "Rs", boldTableFont, 1, -1);

                int srNo = 1;
                newCell(table, srNo.ToString(), bodyFontNormal, 1, 4);
                newCell(table, "Conc. FEE. :", bodyFontNormal, 0, 8);

                PdfPCell cell = new PdfPCell(new Phrase(model.Amount.ToString(), bodyFontNormal));
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.Border = PdfCell.LEFT_BORDER;
                cell.Border = PdfCell.RIGHT_BORDER;
                table.AddCell(cell);

                if (model.LabTestingAmount.HasValue && model.LabTestingAmount.Value != Convert.ToDecimal(0.00))
                {
                    srNo++;
                    newCell(table, srNo.ToString(), bodyFontNormal, 1, 4);
                    newCell(table, "Labarotry. FEE. ", bodyFontNormal, 0, 8);
                    newCell(table, model.LabTestingAmount.ToString(), bodyFontNormal, 1, 8);
                }


                newCell(table, "Total", boldTableFont, 2, -1, 2);
                newCell(table, model.TotalAmount.ToString(), boldTableFont, 1, -1, 2);

                for (int i = 0; i < 5; i++)
                {
                    blankCell(table, 3);
                }
                newCell(table, "Signature", boldTableFont, 2, 0, 3);

                table.SetWidths(new int[] { 1, 12, 6 });

                document.Add(table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
        private void FillFormData(Guid?id)
        {
            try
            {
                OPDHistoryModel model = service.GetById(id.Value);
                if (model != null)
                {
                    Patients.OPDHistory frm = new Patients.OPDHistory(model.Id);
                    Patients.OPDHistory.isControlsEnabled = true;
                    frm.sequence              = model.Sequence;
                    frm.patientId             = model.PatientId;
                    frm.lblName.Text          = model.PatientDetails.FullName;
                    frm.lblCasePaper.Text     = model.PatientDetails.CasePaperNumber;
                    frm.lblMobile.Text        = model.PatientDetails.MobileNumber;
                    frm.lblDepartment.Text    = model.PatientDetails.DepartmentName;
                    frm.lblExpDate.Text       = model.PatientDetails.CasePaperExpiryDate.HasValue ? model.PatientDetails.CasePaperExpiryDate.Value.ToShortDateString() : "--";
                    frm.lblRefDr.Text         = model.PatientDetails.RefferedDoctor.HasValue ? model.PatientDetails.RefferedDoctorName : "--";
                    frm.dtpInTime.Value       = model.InTime.Value;
                    frm.chkCharity.Checked    = model.IsCharity.HasValue ? model.IsCharity.Value : false;
                    frm.chkXRay.Checked       = model.IsXRAY.HasValue ? model.IsXRAY.Value : false;
                    frm.chkECG.Checked        = model.IsECG.HasValue ? model.IsECG.Value : false;
                    frm.chkLabCharity.Checked = model.IsLabCharity.HasValue ? model.IsLabCharity.Value : false;
                    string diagnose = !string.IsNullOrEmpty(model.Diagnose) ? model.Diagnose.Trim() : string.Empty;
                    frm.rtxtDiagnose.Text = setRichTextbox(diagnose);
                    string madicines = !string.IsNullOrEmpty(model.Madicines) ? model.Madicines : string.Empty;
                    frm.rtxtMedicine.Text   = setRichTextbox(madicines);
                    frm.txtOPDAmount.Text   = model.Amount.HasValue ? Convert.ToString(model.Amount) : "0.00";
                    frm.txtLabAmount.Text   = model.LabTestingAmount.HasValue ? Convert.ToString(model.LabTestingAmount) : "0.00";
                    frm.txtECG.Text         = model.ECGAmount.HasValue ? Convert.ToString(model.ECGAmount) : "0.00";
                    frm.txtXRay.Text        = model.XRAYAmount.HasValue ? Convert.ToString(model.XRAYAmount) : "0.00";
                    frm.initialPaid         = model.PaidAmount.HasValue ? model.PaidAmount.Value : Convert.ToDecimal(0.00);
                    frm.txtPaidAmount.Text  = model.PaidAmount.HasValue ? Convert.ToString(model.PaidAmount) : "0.00";
                    frm.initialDues         = model.DueAmount.HasValue ? model.DueAmount.Value : Convert.ToDecimal(0.00);
                    frm.txtDueAmount.Text   = model.DueAmount.HasValue ? Convert.ToString(model.DueAmount) : "0.00";
                    frm.lblTotalAmount.Text = Convert.ToString(model.TotalAmount);
                    frm.getStatus(model.StatusId);
                    frm.ddlStatus.SelectedValue     = model.StatusId;
                    frm.ddlConsulting.SelectedValue = model.ConsultingDoctorId.HasValue ? model.ConsultingDoctorId : docService.GetInHouse("SIR");
                    frm.txtThirdPartyAmount.Text    = model.ThirdPartyLabAmoumt.HasValue ? Convert.ToString(model.ThirdPartyLabAmoumt) : "0.00";
                    frm.ddlThirdParty.SelectedValue = model.ThirdPartyLabId.HasValue ? model.ThirdPartyLabId : Guid.Empty;
                    frm.txtNumberOfXRay.Text        = model.NumberofXRAY.HasValue ? Convert.ToString(model.NumberofXRAY) : "0";
                    tmrRefresh.Stop();
                    tmrRefresh.Enabled = false;

                    frm.ShowDialog();
                    if (isSubmited)
                    {
                        getPandingPatient();
                        getWaitingPatient();
                    }
                    getDashboardCounts();
                    tmrRefresh.Enabled = true;
                    tmrRefresh.Start();

                    isSubmited = false;
                }
            }
            catch (Exception ex)
            {
                isSubmited = false;
                Utility.ErrorLog.Logging("Main Dashboard", ex.Message.ToString(), ex.StackTrace.ToString());
            }
        }
예제 #11
0
        public bool Update(OPDHistoryModel model)
        {
            try
            {
                bool isSaved = false;
                List <OPDHistoryUpdateModel> listUpdateModel = new List <OPDHistoryUpdateModel>();

                using (var db = new HMSEntities())
                {
                    OPDHistory entity = db.OPDHistories.Find(model.Id);
                    listUpdateModel            = OPDHistoryModifications(entity, model);
                    entity.PatientId           = model.PatientId;
                    entity.InTime              = model.InTime;
                    entity.OutTime             = model.OutTime;
                    entity.IsCharity           = model.IsCharity;
                    entity.IsLabCharity        = model.IsLabCharity;
                    entity.IsECG               = model.IsECG.HasValue ? model.IsECG : false;
                    entity.IsXRAY              = model.IsXRAY.HasValue ? model.IsXRAY : false;
                    entity.ConsultingDoctorId  = model.ConsultingDoctorId;
                    entity.StatusId            = model.StatusId;
                    entity.Amount              = model.Amount;
                    entity.PaidAmount          = model.PaidAmount;
                    entity.DueAmount           = model.DueAmount;
                    entity.TotalAmount         = model.TotalAmount;
                    entity.LabTestingAmount    = model.LabTestingAmount;
                    entity.ECGAmount           = model.ECGAmount.HasValue ? model.ECGAmount : 0.00M;
                    entity.XRAYAmount          = model.XRAYAmount.HasValue ? model.XRAYAmount : 0.00M;
                    entity.NumberofXRAY        = model.NumberofXRAY.HasValue ? model.NumberofXRAY : 0;
                    entity.ThirdPartyLabId     = model.ThirdPartyLabId;
                    entity.ThirdPartyLabAmoumt = model.ThirdPartyLabAmoumt.HasValue ? model.ThirdPartyLabAmoumt : 0.00M;
                    string status = Status.GetNameById(model.StatusId);
                    if (status == OPD_STATUS.Done.ToString())
                    {
                        entity.ReceivedBy = UserDetailSession.Id;
                    }
                    else
                    {
                        entity.ReceivedBy = model.ReceivedBy;
                    }
                    entity.Diagnose   = model.Diagnose;
                    entity.Madicines  = model.Madicines;
                    entity.ModifiedBy = UserDetailSession.Id;

                    db.SaveChanges();

                    OPDHistoryUpdate opdHistoryUpdate = new OPDHistoryUpdate();
                    opdHistoryUpdate.Create(listUpdateModel);

                    if (status == OPD_STATUS.Done.ToString())
                    {
                        BillHistoryModel billModel = new BillHistoryModel();
                        billModel.PatientId    = model.PatientId.Value;
                        billModel.OPDHistoryId = model.Id.Value;
                        new BillHistory().Create(billModel);
                    }

                    isSaved = true;
                }



                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #12
0
        public bool Create(OPDHistoryModel model, int isFollowUp = 0)
        {
            try
            {
                bool isSaved = false;

                if (!IsExist(model.CasePaperNumber))
                {
                    using (var db = new HMSEntities())
                    {
                        OPDHistory entity = new OPDHistory();
                        entity.PatientId          = model.PatientId;
                        entity.Sequence           = getLastSerial();
                        entity.InTime             = model.InTime;
                        entity.OutTime            = model.OutTime;
                        entity.IsCharity          = model.IsCharity.HasValue ? model.IsCharity : false;
                        entity.IsLabCharity       = model.IsLabCharity;
                        entity.ConsultingDoctorId = model.ConsultingDoctorId;
                        entity.IsECG      = model.IsECG.HasValue ? model.IsECG : false;
                        entity.IsXRAY     = model.IsXRAY.HasValue ? model.IsXRAY : false;
                        entity.StatusId   = Status.GetStatus(t => t.Name == OPD_STATUS.Waiting.ToString()).FirstOrDefault().Id;
                        entity.IsFollowUp = isFollowUp;
                        if (!entity.IsCharity.Value)
                        {
                            if (isFollowUp == 0)
                            {
                                entity.Amount = OPDRate.GetRatesByType("New").Rate;
                            }
                            else if (isFollowUp == 1)
                            {
                                entity.Amount = OPDRate.GetRatesByType("FollowUP").Rate;
                            }
                        }
                        else
                        {
                            entity.Amount           = 0.00M;
                            entity.LabTestingAmount = 0.00M;
                            entity.XRAYAmount       = 0.00M;
                            entity.ECGAmount        = 0.00M;
                        }
                        model.PayingAmount         = entity.Amount;
                        entity.PaidAmount          = entity.Amount;
                        entity.DueAmount           = model.ECGAmount + model.XRAYAmount; //model.DueAmount != null ? model.DueAmount : Convert.ToDecimal(0.00);
                        entity.TotalAmount         = entity.Amount + model.ECGAmount + model.XRAYAmount;
                        entity.LabTestingAmount    = model.LabTestingAmount != null ? model.LabTestingAmount : Convert.ToDecimal(0.00);
                        entity.ECGAmount           = model.ECGAmount.HasValue ? model.ECGAmount : 0.00M;
                        entity.XRAYAmount          = model.XRAYAmount.HasValue ? model.XRAYAmount : 0.00M;
                        entity.NumberofXRAY        = model.NumberofXRAY.HasValue ? model.NumberofXRAY : 0;
                        entity.ThirdPartyLabId     = model.ThirdPartyLabId;
                        entity.ThirdPartyLabAmoumt = model.ThirdPartyLabAmoumt.HasValue ? model.ThirdPartyLabAmoumt : 0.00M;
                        entity.ReceivedBy          = model.ReceivedBy;
                        entity.Diagnose            = model.Diagnose;
                        entity.Madicines           = model.Madicines;
                        entity.CreatedBy           = UserDetailSession.Id;

                        db.OPDHistories.Add(entity);
                        db.SaveChanges();
                        model.Id = entity.Id;
                        List <OPDHistoryUpdateModel> listUpdateModel = new List <OPDHistoryUpdateModel>();
                        listUpdateModel = OPDHistoryModifications(model);
                        OPDHistoryUpdate opdHistoryUpdate = new OPDHistoryUpdate();
                        opdHistoryUpdate.Create(listUpdateModel);
                        isSaved = true;
                    }
                }


                return(isSaved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }