Exemplo n.º 1
0
        public void PrintPatientResult(int id)
        {
            try
            {

                objPatientResults obj = new objPatientResults();
                var sp = dbm.Samples
                    .Include(o => o.Patient)
                    .Include(o => o.Clinic)
                      .Include(o => o.Clinic.ClinicGroup)
                      .Include(o => o.ClinicMaterial)
                      .Include(o => o.Doctor)
                      .SingleOrDefault(o => o.SampleID == id);
                obj.SampleID = sp.SampleID.ToString();
                obj.Clinic = sp.Clinic.ClinicGroup.Description + " - " + sp.Clinic.Description;
                if (sp.SamplePaymentTypeID == 1)
                {
                    obj.Clinic += " (О)";
                }
                else
                {
                    obj.Clinic += " (К)";
                }
                obj.DoctorFIO = sp.Doctor.Lastname + " " + sp.Doctor.Initials;
                obj.PatientFIO = sp.Patient.Lastname + " " + sp.Patient.Initials;
                obj.PatientSex = sp.Patient.Sex;
                obj.BirthDate = DateTime.Parse(sp.Patient.Birthdate.ToString()).ToShortDateString();
                obj.ClinicMaterial = sp.ClinicMaterial.Description;
                obj.DateDeliverySample = sp.DatetimeDelivery.ToString();
                obj.DateRecieveSample = sp.DatetimeCapture.ToString();
                Patient patientObj = sp.Patient;
                patientObj.PrintedResults = 1;
                dbm.SaveChanges();
                // Получение собственно результатов
                obj.listAnalysis = new List<_itemAnalysis>();
                // получаем анализы для пациента
                int tempsample = int.Parse(obj.SampleID);
                var model = dbm.MBAnalysis.Where(o => o.SampleID == tempsample).ToList();
                foreach (var itemAnalysis in model)
                {
                    var itemsBac = dbm.MBAnalysisBacterioscopies.Include(o => o.MBBacterioscopyOrganismType).Where(o => o.MBAnalysisID == itemAnalysis.MBAnalysisID).ToList();
                    var itemsRO = dbm.ROes.Include(o => o.OrganismType).Include(o => o.ROandClinicalTests).Where(o => o.MBAnalysisID == itemAnalysis.MBAnalysisID).ToList();
                    _itemAnalysis tempIA = new _itemAnalysis();
                    tempIA.itemMBAnalysis = itemAnalysis;
                    tempIA.listBacterioscopy = itemsBac;
                    tempIA.listROes = new List<_itemRO>();
                    foreach (var itemRO in itemsRO)
                    {
                        var itemsROClinicTest = dbm.ROandClinicalTests.Include(o => o.AntibioticType).Include(o => o.Method).Where(o => o.ROID == itemRO.ROID).ToList();

                        _itemRO tempRO = new _itemRO();
                        tempRO.itemRO = itemRO;
                        tempRO.listROandClinicalTests = itemsROClinicTest;
                        tempIA.listROes.Add(tempRO);
                    }
                    obj.listAnalysis.Add(tempIA);
                }

                // Завершение получения результатов

                Printing objPrinter = new Printing();
                string resAddress = objPrinter.PrintPatientResults(obj);
                Response.ContentType = "application/text";
                Response.AddHeader("Content-Disposition", @"filename=""result_" + obj.SampleID.ToString() + ".rtf");
                Response.TransmitFile(@resAddress);
            }
            catch (DataException ex)
            {
                string strMessage = "Ошибка " + ex.Message + ". Попробуйте повторить действие. В случае постоянного возникновения ошибки обратитесь к администратору";
                Response.Write(strMessage);
            }
        }
Exemplo n.º 2
0
        public void Index(vwReportIndex model)
        {
            int statusContract = 0;
            int statusClinic = 0;
            int statusMBAnalysis = 0;
            int statusClinicMaterials = 0;
            if (model.selectedClinic[0] == "ALL")
            {
                statusClinic = 1;
            }
            if (model.selectedClinicMaterial[0] == "ALL")
            {
                statusClinicMaterials = 1;
            }
            if (model.selectedContract[0] == "ALL")
            {
                statusContract = 1;
            }
            if (model.selectedMBAnalysis[0] == "ALL")
            {
                statusMBAnalysis = 1;
            }
            IEnumerable<vwTotalInfoForReport> obj = dbm.vwTotalInfoForReports.ToList();
            if (statusContract != 1)
            {
                //var obj = db.Samples.Where(o => o.SamplePaymentTypeID == 2 && arr.Contains(o.SampleID))
             obj = obj.Where(o => model.selectedContract.Contains(o.ContractID.ToString() )).ToList();
            }

            if (statusClinic != 1)
            {
                //var obj = db.Samples.Where(o => o.SamplePaymentTypeID == 2 && arr.Contains(o.SampleID))
                obj = obj.Where(o => model.selectedClinic.Contains(o.ClinicContractID.ToString())).ToList();
            }

            if (statusClinicMaterials != 1)
            {
                //var obj = db.Samples.Where(o => o.SamplePaymentTypeID == 2 && arr.Contains(o.SampleID))
                obj = obj.Where(o => model.selectedClinicMaterial.Contains(o.ClinicMaterialID.ToString())).ToList();
            }

            if (statusMBAnalysis != 1)
            {
                //var obj = db.Samples.Where(o => o.SamplePaymentTypeID == 2 && arr.Contains(o.SampleID))
                obj = obj.Where(o => model.selectedMBAnalysis.Contains(o.MBAnalysisTypeID.ToString())).ToList();
            }

            obj = obj.Where(o => o.DatetimeDelivery >= DateTime.Parse(model.dateStart) && o.DatetimeDelivery <= (DateTime.Parse(model.dateEnd)).AddDays(1));

            Printing objPrinter = new Printing();
            string resAddress = objPrinter.PrintReport(obj);
            Response.ContentType = "application/text";
            Response.AddHeader("Content-Disposition", @"filename=""report_" + DateTime.Now.ToString() + ".xls");
            Response.TransmitFile(@resAddress);
        }
Exemplo n.º 3
0
        public void PrintPatientContract(int id)
        {
            try
            {
                objPatientContract obj = new objPatientContract();
                var sp = dbm.Samples
                    .Include(o => o.Patient)
                    .Include(o => o.Clinic)
                      .Include(o => o.Clinic.ClinicGroup)
                      .Include(o => o.ClinicMaterial)
                      .Include(o => o.Doctor)
                      .SingleOrDefault(o => o.SampleID == id);
                obj.SampleID = sp.SampleID.ToString();
                obj.Clinic = sp.Clinic.ClinicGroup.Description + " - " + sp.Clinic.Description;
                if (sp.SamplePaymentTypeID == 1)
                {
                    obj.Clinic += " (О)";
                }
                else
                {
                    obj.Clinic += " (К)";
                }
                obj.DoctorFIO = sp.Doctor.Lastname + " " + sp.Doctor.Initials;
                obj.PatientFIO = sp.Patient.Lastname + " " + sp.Patient.Initials;
                obj.PatientSex = sp.Patient.Sex;
                obj.BirthDate = DateTime.Parse(sp.Patient.Birthdate.ToString()).ToShortDateString();
                obj.ClinicMaterial = sp.ClinicMaterial.Description;
                obj.DateDeliverySample = sp.DatetimeDelivery.ToString();
                obj.DateRecieveSample = sp.DatetimeCapture.ToString();
                obj.DateContractStart = DateTime.Now.ToShortDateString();
                obj.DateContractEnd = DateTime.Now.AddDays(5).ToShortDateString();

                decimal total = 0;
                var al = dbm.vwMBAnalysisForSampleWithPrices.Where(o => o.SampleID == id).OrderBy(o => o.MBAnalysisTypesDesc).ToList();
                int cntAl = 0;
                obj.AnalysisList = new List<TableAnalysisItem>();
                foreach (var itemal in al)
                {
                    cntAl++;
                    total += (decimal)itemal.Price;
                    obj.AnalysisList.Add(new TableAnalysisItem
                    {
                        AnalysisPosition = cntAl.ToString(),
                        AnalysisCode = itemal.Code,
                        AnalysisDescription = itemal.MBAnalysisTypesDesc,
                        AnalysisPrice = itemal.Price.ToString()
                    });
                }

                var ads = dbm.SamplesAndAdditionalServices.Include(o => o.AdditionalService).Where(o => o.SampleID == id).OrderBy(o => o.AdditionalService.Description).ToList();
                int cntAds = 0;
                obj.AddServiceList = new List<TableAddServiceItem>();
                foreach (var itemads in ads)
                {
                    cntAds++;
                    total += (decimal)itemads.AdditionalService.Price;
                    obj.AddServiceList.Add(new TableAddServiceItem
                    {
                        AddServicePosition = cntAds.ToString(),
                        AddServiceCode = "-",
                        AddServiceDescription = itemads.AdditionalService.Description,
                        AddServicePrice = itemads.AdditionalService.Price.ToString()
                    });
                }
                int sum = (int)total;
                obj.TotalSum = sum.ToString();
                //new Diagnostics_FP.GeneratedXML.GeneratedPatientContract().CreatePackage(AppDomain.CurrentDomain.BaseDirectory + "Output" + obj.SampleID + ".docx", obj);
                //   string path = AppDomain.CurrentDomain.BaseDirectory;
                //  string fileName = "Output.docx";

                Printing objPrinter = new Printing();
                string resAddress = objPrinter.PrintContractForPatient(obj);
                Response.ContentType = "application/text";
                Response.AddHeader("Content-Disposition", @"filename=""contract_" + obj.SampleID.ToString() + ".rtf");
                Response.TransmitFile(@resAddress);
            }
            catch (DataException ex)
            {
                string strMessage = "Ошибка " + ex.Message + ". Попробуйте повторить действие. В случае постоянного возникновения ошибки обратитесь к администратору";
                Response.Write(strMessage);
            }
        }