Esempio n. 1
0
        public ReportHistoryViewModel(PatientEntity model)
        {
            ShowImageCommand = new DelegateCommand(OnShowImageCommand);
            LogOffCommand    = new DelegateCommand(OnLogOffCommand);
            PatientEntity    = model;

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

            if (PatientEntity.Sex == "m")
            {
                PatientEntity.Sex = "Male";
            }
            else
            {
                PatientEntity.Sex = "Female";
            }

            if (PatientEntity.AllergyDrugs == "Yes")
            {
                ShowAllergyOption = true;
            }

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

            string path   = Path.Combine(Program.BaseDir(), "Uploads");
            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);
            }
            ViewReportDataCommand = new DelegateCommand(OnViewReportDataCommand);
        }
        private APIResult SyncPatientDetails(PatientEntity patient, bool isUpdate)
        {
            APIResult result = new APIResult();
            string    token  = new User().GetToken(Program.UserId());
            string    url    = string.Empty;

            if (isUpdate)
            {
                url = ConfigurationManager.AppSettings["updatePatientAPI"].ToString() + "/" + patient.PatientId + "?token=" + token;
            }
            else
            {
                url = ConfigurationManager.AppSettings["addPatientAPI"].ToString() + "?token=" + token;
            }

            object objct = new
            {
                p_id              = patient.Id,
                name              = patient.Nm,
                pMName            = patient.MNm,
                pLName            = patient.LNm,
                notResident       = patient.NotResident,
                ifResidentOfM     = patient.IfResidentOfM,
                IcNumber          = patient.IcNumber,
                otherOption       = patient.OtherOption,
                othersID          = patient.OthersID,
                doctosName        = patient.DocNm,
                hospitalScreening = patient.HospitalScreening,
                hospitalName      = patient.HospitalNm,
                hospitalID        = patient.HospitalID,
                p_email           = patient.Email,
                marital_status    = patient.MaritalStatus == "Married" ? "Yes" : "No",
                age = patient.Age,
                sex = patient.Sex == "Male" ? "m" : "f",
                permanent_address = patient.PerAdr,
                area                      = patient.Area,
                phone_res                 = patient.ResidentPh,
                mobile                    = patient.Mob,
                occupation                = patient.Occupation,
                working_at                = patient.WorkingAt,
                currentMedications        = patient.CurrentMedications,
                laser_treatment           = patient.LaserTreatment,
                have_cataract             = patient.Cataract,
                have_hypertension         = patient.Hypertension,
                allergy_to_drugs          = patient.AllergyDrugs,
                have_diabetes             = patient.Diabetic,
                additional_info           = patient.Info,
                emg_contact_name          = patient.EmergContactNm,
                emg_phone                 = patient.EmergPh,
                name_of_the_stated_onsent = patient.StatedConsentPerson,
                relation_with_patient     = patient.Relation,
                term_conditation          = patient.TermsCondition,
                collection_id             = patient.CollectionID,
                install_id                = patient.InstallID,
                update_at                 = patient.MDt.Ticks,
                create_at                 = patient.CDt.Ticks,
                UniqueID                  = patient.UniqueID,
                allergy_drugs_details     = patient.AllergyDrugsDtl,
                MedicalInsurance          = patient.MedicalInsurance
            };
            var json = new JavaScriptSerializer().Serialize(objct);

            try
            {
                result = RestCalls.SyncReport(url, json, isUpdate);
                if (result.status == "ok")
                {
                    if (isUpdate)
                    {
                        bool newReport = PatientReports.Any(x => x.Sync == false);
                        if (newReport)
                        {
                            result = SyncPatientReport(PatientReports, PatientEntity.PatientId);
                        }
                    }
                    else
                    {
                        PatientEntity.PatientId = result.user;
                        new Patient().UpdatePatientId(patient.Id, result.user);
                        SyncPatientReport(PatientReports, result.user);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
                ModernDialog.ShowMessage("An error has occurred on the server", "Alert", MessageBoxButton.OK);
            }
            return(result);
        }
        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);
            }
        }