Exemplo n.º 1
0
        public void GeneratePatientReport(List <PatientReportModel> model, Refer ReferDoctor, Patient PatientInfo, UserEmployee PatientDoctor, string BranchName)
        {
            //StreamWriter sq = new StreamWriter(Server.MapPath("/images/") + "log.txt");
            //sq.Close();
            //StreamWriter sw = new StreamWriter(Server.MapPath("/images/") + "log.txt");
            //sw.WriteLine("patient report method start....");
            string filename = "Report-" + PatientInfo.Id + ".pdf";

            if (!System.IO.File.Exists(Request.MapPath("/PatientsReport/") + filename))
            {
                var path = Server.MapPath("/images/");
                // sw.WriteLine("condition true of patient report. file doesn't exist..");
                // sw.WriteLine("class going to instantiate report.");
                PatientReport Report = new PatientReport(path, model, ReferDoctor, PatientInfo, PatientDoctor, BranchName);
                //sw.WriteLine("report class instantiated");
                PdfDocument pdf = Report.CreateDocument();
                //sw.WriteLine("report is created.");

                pdf.Save(Server.MapPath("/PatientsReport/") + filename);
                //sw.WriteLine("report saved successfully");
                //    System.IO.FileInfo fi=new System.IO.FileInfo(Request.MapPath("/PatientsReport/") + filename);
                //    fi.Delete();
            }
            // ...and start a viewer.
            //sw.WriteLine("report process start.");
            Process.Start(Server.MapPath("/PatientsReport/") + filename);
            //sw.WriteLine("report PROCESS END");
            //sw.Close();
        }
Exemplo n.º 2
0
        public PredictionViewModel(PatientEntity model)
        {
            ShowImageCommand       = new DelegateCommand(OnShowImageCommand);
            LogOffCommand          = new DelegateCommand(OnLogOffCommand);
            SetHansanetCommand     = new DelegateCommand(OnSetHansanetCommand);
            SelectAllCommand       = new DelegateCommand(OnSelectAllComand);
            SaveCommand            = new DelegateCommand(OnSaveCommand);
            StartPredictionCommand = new DelegateCommand(OnStartPredictionCommand);
            BackCommand            = new DelegateCommand(OnBackCommand);
            PatientEntity          = model;
            string path = Path.Combine(Program.BaseDir(), "Uploads");

            PatientReport = new PatientReport();
            PatientReport = new Patient().GetLastestReport(model.Id);
            if (PatientReport != null)
            {
                PatientReport.OSPosteriorReportDatas = new ObservableCollection <ReportData>();
                PatientReport.ODPosteriorReportDatas = new ObservableCollection <ReportData>();

                var osResult = new Patient().GetPosteriorOSReportData(PatientReport.Id, true);
                foreach (var osData in osResult)
                {
                    osData.ImageUrl  = Path.Combine(path, osData.Img);
                    osData.BitMapImg = new System.Windows.Media.Imaging.BitmapImage(new Uri(osData.ImageUrl));
                    osData.FileName  = Path.GetFileName(osData.ImageUrl);
                    PatientReport.OSPosteriorReportDatas.Add(osData);
                }
                var odResult = new Patient().GetPosteriorODReportData(PatientReport.Id, true);
                foreach (var odData in odResult)
                {
                    odData.ImageUrl  = Path.Combine(path, odData.Img);
                    odData.BitMapImg = new System.Windows.Media.Imaging.BitmapImage(new Uri(odData.ImageUrl));
                    odData.FileName  = Path.GetFileName(odData.ImageUrl);
                    PatientReport.ODPosteriorReportDatas.Add(odData);
                }

                PatientReport.OSAnteriorReportDatas = new ObservableCollection <ReportData>();
                PatientReport.ODAnteriorReportDatas = new ObservableCollection <ReportData>();

                var osAnResult = new Patient().GetOSAnteriorReportData(PatientReport.Id, true);
                foreach (var osData in osAnResult)
                {
                    osData.ImageUrl  = Path.Combine(path, osData.Img);
                    osData.BitMapImg = new System.Windows.Media.Imaging.BitmapImage(new Uri(osData.ImageUrl));
                    osData.FileName  = Path.GetFileName(osData.ImageUrl);
                    PatientReport.OSAnteriorReportDatas.Add(osData);
                }
                var odAnResult = new Patient().GetODAnteriorReportData(PatientReport.Id, true);
                foreach (var odData in odAnResult)
                {
                    odData.ImageUrl  = Path.Combine(path, odData.Img);
                    odData.BitMapImg = new System.Windows.Media.Imaging.BitmapImage(new Uri(odData.ImageUrl));
                    odData.FileName  = Path.GetFileName(odData.ImageUrl);
                    PatientReport.ODAnteriorReportDatas.Add(odData);
                }
            }
        }
 public CameraViewModel(PatientEntity patient, PatientReport report = null)
 {
     PatientEntity = patient;
     Initialize();
     if (report != null)
     {
         PatientReport = report;
     }
 }
        public async Task <ActionResult> GetPatientReport(long patientId)
        {
            var patient = _service.GetPatientById(patientId);

            if (patient == null)
            {
                return(NotFound());
            }
            var patientReport = new PatientReport(patient, _service.GetSimilarPatients(patientId));

            return(Ok(patientReport));
        }
 private void Initialize()
 {
     LogOffCommand       = new DelegateCommand(OnLogOffCommand);
     CameraEntity        = new CameraEntity();
     CameraEntity.Eye    = "OD";
     SaveCommand         = new DelegateCommand(OnSaveCommand);
     CamStartCommand     = new DelegateCommand(OnCamStartCommand);
     CamStopCommand      = new DelegateCommand(OnCamStopCommand);
     CamPosteriorCommand = new DelegateCommand(OnCamPosteriorCommand);
     CamAnteriorCommand  = new DelegateCommand(OnCamAnteriorCommand);
     CaptureCommand      = new DelegateCommand(OnCaptureCommand);
     ReportViewCommand   = new DelegateCommand(OnReportViewCommand);
     BackCommand         = new DelegateCommand(OnBackCommand);
     PatientReport       = new PatientReport();
     ConnectCamera();
 }
        public async Task <IActionResult> Post([FromBody] PatientReport report)
        {
            //figure out if the user has permission to accsess the apointment the report will
            // be associated with, and if not return 403 forbidden

            //if they do, create the report with the given details.
            var new_report = await _clinicRepository.AddPatientReportAsync(report);

            if (new_report is Domain.Models.PatientReport)
            {
                return(CreatedAtAction(nameof(Get), new { id = new_report.Id }, new_report));
            }
            else
            {
                return(BadRequest("Request could not be processed."));
            }
        }
Exemplo n.º 7
0
        public void GeneratePatientReport(List <PatientReportModel> model, Refer ReferDoctor, Patient PatientInfo, UserEmployee PatientDoctor, string BranchName)
        {
            string filename = "Report-" + PatientInfo.Id + ".pdf";

            if (!System.IO.File.Exists(Request.MapPath("/PatientsReport/") + filename))
            {
                var Path = Server.MapPath("/images/");

                PatientReport Report = new PatientReport(Path, model, ReferDoctor, PatientInfo, PatientDoctor, BranchName);

                PdfDocument pdf = Report.CreateDocument();


                pdf.Save(Server.MapPath("/PatientsReport/") + filename);
                //    System.IO.FileInfo fi=new System.IO.FileInfo(Request.MapPath("/PatientsReport/") + filename);
                //    fi.Delete();
            }
            // ...and start a viewer.
            Process.Start(Server.MapPath("/PatientsReport/") + filename);
        }
Exemplo n.º 8
0
        public ActionResult PatientReport(PatientReport obj, TabNameandDoses tbandDosesobj)
        {
            HospitalManagementEntities db = new Models.HospitalManagementEntities();
            int Pid = obj.Pid <= 0 ? 0 :obj.Pid;

            if (Pid != 0)
            {
                SqlCommand cmd = new SqlCommand("sp_insertPatientReport", con);
                con.Open();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Pid", Pid);
                cmd.Parameters.AddWithValue("@did", 1);
                cmd.Parameters.AddWithValue("@PTName", obj.PName != string.Empty?obj.PName:"");
                cmd.Parameters.AddWithValue("@Gender", obj.Gender != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@ReferBy", obj.Referby != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@HT", obj.HT != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@WT", obj.WT != string.Empty ? obj.WT : "");
                cmd.Parameters.AddWithValue("@Age", obj.Age != string.Empty ? obj.Age : "");
                cmd.Parameters.AddWithValue("@Emergency", obj.Emergency != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@Review", obj.Reveiw != string.Empty ? obj.Reveiw      : "");
                cmd.Parameters.AddWithValue("@Complain", obj.Complain != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@History", obj.History != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@Dx", obj.Dx != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@Investigation", obj.Investigation != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@Advice", obj.Advice != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@GC", obj.GCs != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@Temp", obj.Temp != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@PR", obj.PR != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@LR", obj.LR != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@BP", obj.BP != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@SPO2", obj.SPO2 != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@PA", obj.PA != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@CNS", obj.CNS != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@GRBS", obj.GRBS);
                cmd.Parameters.AddWithValue("@HR", obj.HR != string.Empty ? obj.PName : "");
                cmd.Parameters.AddWithValue("@CreatedBy", obj.CreatedBY);
                cmd.Parameters.AddWithValue("@CreatedDatetime", DateTime.Now);
                cmd.Parameters.AddWithValue("@UpdatedBy", obj.Updatedby);
                cmd.Parameters.AddWithValue("@Updateddatetime", DateTime.Now);
                Int32 i = Convert.ToInt32(cmd.ExecuteScalar());

                if (i > 0)
                {
                    TabNameandDoses tbobj = new TabNameandDoses();
                    StringBuilder   tb    = new StringBuilder();
                    if (tbandDosesobj.txtSearchMedicines1 != string.Empty)
                    {
                    }
                    tb.Append(tbandDosesobj.Doses1);

                    return(View(obj));
                }
                else
                {
                    ViewBag.Visable = false;
                    ViewBag.Message = "Record Failed To Insert";
                    return(View(obj));
                }
            }
            else
            {
                ViewBag.Visable = false;
                ViewBag.Message = "Record Failed To Insert";
                return(View(obj));
            }
        }
        void CreateReport(PatientReport report)
        {
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (sender, e) =>
            {
                string path     = Path.Combine(Program.BaseDir(), "Uploads");
                string dir      = Path.Combine(Program.BaseDir(), "Uploads", PatientEntity.UniqueID.ToString(), report.UniqueID.ToString());
                string filePDF  = Path.Combine(dir, "report.pdf");
                string fileHTML = Path.Combine(dir, "report.html");
                if (!File.Exists(filePDF))
                {
                    string text = Common.Helper.ReadAllTextReportFile();

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    //else if (File.Exists(filePDF))
                    //    File.Delete(filePDF);

                    string            posteriorHTML = "<tr>";
                    string            anteriorHTML = "<tr>";
                    string            prediction = string.Empty;
                    int               posteriorCount = 0, anteriorCount = 0;
                    List <ReportData> posteriorDatas = new Patient().GetPosteriorReportData(report.Id);
                    List <ReportData> anteriorDatas  = new Patient().GetAnteriorReportData(report.Id);

                    if (posteriorDatas != null)
                    {
                        bool docReview = posteriorDatas.Any(x => x.Prediction == "Doctor review recommended");
                        bool noDR      = posteriorDatas.Any(x => x.Prediction == "No DR detected");
                        bool badImg    = posteriorDatas.Any(x => x.Prediction == "Bad Image");

                        if (docReview)
                        {
                            prediction = "EXAMINATION RESULT: Diabetic Retinopathy Suspected - Doctor Review Recommended                    * KINDLY CORRELATE CLINICALLY *";
                        }
                        else if (noDR)
                        {
                            prediction = "EXAMINATION RESULT: No Abnormlities detected                    * KINDLY CORRELATE CLINICALLY *";
                        }
                        else if (badImg)
                        {
                            prediction = "EXAMINATION RESULT: Bad Image                    * KINDLY CORRELATE CLINICALLY *";
                        }
                        else
                        {
                            prediction = "EXAMINATION RESULT:                     * KINDLY CORRELATE CLINICALLY *";
                        }

                        foreach (var item in posteriorDatas)
                        {
                            item.ImageUrl = Path.Combine(path, item.Img);
                            item.FileName = Path.GetFileName(item.ImageUrl);
                            string result = item.Prediction + " | " + (item.Eye == "OS" ? "Right Eye" : "Left Eye");
                            if (posteriorCount != 0 && (posteriorCount % 2 == 0))
                            {
                                posteriorHTML += "<tr><td style='width:33.33%; vertical-align:top;padding-bottom:15px;'><table style='width:100%;height:200px;margin-bottom:10px;'><tr><td><img style='max-width:200px;max-height:200px;' src='" + item.FileName + "' /></td></tr></table><h3 style='font-size: 14px;color:#333;font-weight:400;margin:0;'>" + result + "</h3></td>";
                            }
                            else
                            {
                                posteriorHTML += "<td style='width:33.33%; vertical-align:top;padding-bottom:15px;'><table style='width:100%;height:200px;margin-bottom:10px;'><tr><td><img style='max-width:200px;max-height:200px;' src='" + item.FileName + "' /></td></tr></table><h3 style='font-size: 14px;color:#333;font-weight:400;margin:0;'>" + result + "</h3></td>" + (posteriorCount != 0 ? "</tr>" : "");
                            }
                            posteriorCount++;
                        }
                    }

                    foreach (var item in anteriorDatas)
                    {
                        item.ImageUrl = Path.Combine(path, item.Img);
                        item.FileName = Path.GetFileName(item.ImageUrl);
                        string result = item.Prediction + " | " + item.Eye == "OS" ? "Right Eye" : "Left Eye";
                        if (posteriorCount != 0 && (posteriorCount % 2 == 0))
                        {
                            anteriorHTML += "<tr><td style='width:33.33%; vertical-align:top;padding-bottom:15px;'><table style='width:100%;height:200px;margin-bottom:10px;'><tr><td><img style='max-width:200px;max-height:200px;' src=" + item.FileName + " /></td></tr></table><h3 style='font-size: 14px;color:#333;font-weight:400;margin:0;'>" + result + "</h3></td>";
                        }
                        else
                        {
                            anteriorHTML += "<td style='width:33.33%; vertical-align:top;padding-bottom:15px;'><table style='width:100%;height:200px;margin-bottom:10px;'><tr><td><img style='max-width:200px;max-height:200px;' src=" + item.FileName + " /></td></tr></table><h3 style='font-size: 14px;color:#333;font-weight:400;margin:0;'>" + result + "</h3></td>" + (posteriorCount != 0 ? "</tr>" : "");
                        }
                        anteriorCount++;
                    }
                    text = string.Format(text, DateTime.Now.ToShortDateString(), PatientEntity.Nm, PatientEntity.DocNm, PatientEntity.HospitalNm, PatientEntity.Id.ToString(), PatientEntity.HospitalID, PatientEntity.HospitalScreening, PatientEntity.Mob, PatientEntity.Age, PatientEntity.Sex, PatientEntity.Hypertension, PatientEntity.Cataract, PatientEntity.LaserTreatment, PatientEntity.AllergyDrugs, PatientEntity.CurrentMedications, PatientEntity.Info, posteriorHTML, PatientEntity.OtherOption, PatientEntity.OthersID, anteriorHTML, predictionResult, PatientEntity.PatientId);
                    System.IO.File.WriteAllText(fileHTML, text);


                    HtmlToPdf   converter = new HtmlToPdf();
                    PdfDocument doc       = converter.ConvertUrl(fileHTML);
                    //doc.Margins = new PdfMargins(5);

                    doc.Save(filePDF);
                    doc.Close();
                }
            };

            bw.RunWorkerCompleted += (sender, e) =>
            {
                if (e.Error != null)
                {
                    //ModernDialog.ShowMessage(e.Error.InnerException.Message, "Error Alert", MessageBoxButton.OK);
                    ModernDialog.ShowMessage("Internal Server Error. Please contact your administrator", "Error Alert", MessageBoxButton.OK);
                }
            };
            bw.RunWorkerAsync();
        }
        public ReportViewModel(PatientEntity model, PatientReport obj)
        {
            ShowImageCommand = new DelegateCommand(OnShowImageCommand);
            BackCommand      = new DelegateCommand(OnBackCommand);
            LogOffCommand    = new DelegateCommand(OnLogOffCommand);
            PrintPDFCommand  = new DelegateCommand(OnPrintPDFCommand);
            string path = Path.Combine(Program.BaseDir(), "Uploads");

            ReportDatas   = new ObservableCollection <ReportData>();
            PatientEntity = model;
            if (PatientEntity.Sex == "m")
            {
                PatientEntity.Sex = "Male";
            }
            else
            {
                PatientEntity.Sex = "Female";
            }

            if (PatientEntity.MaritalStatus == "No")
            {
                PatientEntity.MaritalStatus = "Single";
            }
            else
            {
                PatientEntity.MaritalStatus = "Married";
            }

            if (PatientEntity.IfResidentOfM == "Yes")
            {
                PatientEntity.OtherOption = "IC Number:";
                PatientEntity.OthersID    = PatientEntity.IcNumber;
            }
            else
            {
                PatientEntity.OtherOption = PatientEntity.OtherOption + ":";
            }

            if (obj != null)
            {
                PatientReport = obj;
            }
            else
            {
                PatientReport = new Patient().GetLastestReport(model.Id);
            }

            if (PatientReport != null)
            {
                var  osResult  = new Patient().GetPosteriorOSReportData(PatientReport.Id, false);
                var  odResult  = new Patient().GetPosteriorODReportData(PatientReport.Id, false);
                bool docReview = osResult.Any(x => x.Prediction == "Doctor review recommended");
                if (!docReview)
                {
                    docReview = odResult.Any(x => x.Prediction == "Doctor review recommended");
                }

                bool noDR = osResult.Any(x => x.Prediction == "No DR detected");
                if (!noDR)
                {
                    noDR = odResult.Any(x => x.Prediction == "No DR detected");
                }

                bool badImg = osResult.Any(x => x.Prediction == "Bad Image");
                if (!badImg)
                {
                    badImg = odResult.Any(x => x.Prediction == "Bad Image");
                }

                if (docReview)
                {
                    PredictionResult = "EXAMINATION RESULT: Diabetic Retinopathy Suspected - Doctor Review Recommended                    * KINDLY CORRELATE CLINICALLY *";
                }
                else if (noDR)
                {
                    PredictionResult = "EXAMINATION RESULT: No Abnormlities detected                    * KINDLY CORRELATE CLINICALLY *";
                }
                else if (badImg)
                {
                    PredictionResult = "EXAMINATION RESULT: Bad Image                    * KINDLY CORRELATE CLINICALLY *";
                }
                else
                {
                    PredictionResult = "EXAMINATION RESULT:                     * KINDLY CORRELATE CLINICALLY *";
                }

                foreach (var data in osResult)
                {
                    data.ImageUrl = Path.Combine(path, data.Img);
                    data.FileName = Path.GetFileName(data.ImageUrl);
                    OSReportDatas.Add(data);
                }
                foreach (var data in odResult)
                {
                    data.ImageUrl = Path.Combine(path, data.Img);
                    data.FileName = Path.GetFileName(data.ImageUrl);
                    ODReportDatas.Add(data);
                }
            }

            var report = new Patient().GetAllReport(model.Id);

            foreach (var item in report)
            {
                var result = new Patient().GetAllReportData(item.Id);
                item.ReportDatas = new ObservableCollection <ReportData>();
                foreach (var data in result)
                {
                    data.ImageUrl = Path.Combine(path, data.Img);
                    item.ReportDatas.Add(data);
                }
                PatientReports.Add(item);
            }

            TakeReportCommand     = new DelegateCommand(OnTakeReportCommand);
            PreviousReportCommand = new DelegateCommand(OnPreviousReportCommand);
            FtpTransferCommand    = new DelegateCommand(OnFtpTransferCommand);
            ViewReportDataCommand = new DelegateCommand(OnViewReportDataCommand);
            SaveNextCommand       = new DelegateCommand(OnSaveNextCommand);
            SaveExitCommand       = new DelegateCommand(OnSaveExitCommand);
            SendMailCommand       = new DelegateCommand(OnSendMailCommand);
            ViewPDFCommand        = new DelegateCommand(OnViewPDFCommand);
            if (PatientReport != null)
            {
                CreateReport(PatientReport);
            }
        }