Beispiel #1
0
        public PatientViewModel()
        {
            this.SavePatientDataCommand = new RelayCommand(this.SavePatientData);
            Months = GetMonths();

            using (MedicineContext db = new MedicineContext())
            {
                db.SocialStatuses.Load();
                db.Policies.Load();
                db.Disabilities.Load();
                SocialStatuses = db.SocialStatuses.Local.ToBindingList();
                Policies       = db.Policies.Local.ToBindingList();
                Disabilities   = db.Disabilities.Local.ToBindingList();
            }
            if (SingletonVMP.VMP.Patient == null)
            {
                Patient = new Patient();
                SingletonVMP.VMP.Patient = Patient;
            }
            else
            {
                Patient = SingletonVMP.VMP.Patient;
                GetBirthday();
                GetDisability();
                SelectedSocialStatus = SocialStatuses.FirstOrDefault(x => x.Id == Patient.SocialStatusId);
                SelectedPolicy       = Policies.FirstOrDefault(x => x.Id == Patient.PoliceId);
            }
        }
        public void UnlinkPolicy(int policyId)
        {
            var sGpolicy = Policies?.FirstOrDefault(p => p.PolicyId == policyId);

            if (sGpolicy == null)
            {
                throw new BusinessException($"This Policy is not linked.");
            }

            Policies.Remove(sGpolicy);
        }
Beispiel #3
0
        public SignatureDialog(Window owner, SignatureDocument document, Signature parentSignature)
        {
            InitializeComponent();

            Owner = owner;

            Items = new ObservableCollection <SignedItem>();
            Items.Add(new SignedItem()
            {
                Type = parentSignature == null ? SignedItemType.Document : SignedItemType.Signature
            });

            CertificateList = new ObservableCollection <X509Certificate2>(Utils.GetCertificates().OfType <X509Certificate2>());

            SelectedPolicy      = Policies?.FirstOrDefault();
            SelectedCertificate = CertificateList.FirstOrDefault();

            _document        = document;
            _parentSignature = parentSignature;
            _lastDirectory   = Path.GetDirectoryName(document.BaseUri);

            DataContext = this;
        }
Beispiel #4
0
        public static string Print(Settings settings)
        {
            List <SocialStatus> SocialStatuses;
            List <Policy>       Policies;
            List <Disability>   Disabilities;
            List <EyeSide>      EyeSides;

            Directory.CreateDirectory(settings.SavePath);
            Object template = Template;

            Word.Application app = new Word.Application();
            app.Visible = true;
            try
            {
                Word.Document doc = app.Documents.Add(ref template, ref missingObj, ref missingObj, ref missingObj);

                using (MedicineContext db = new MedicineContext())
                {
                    db.SocialStatuses.Load();
                    db.Policies.Load();
                    db.Disabilities.Load();
                    db.EyeSides.Load();
                    SocialStatuses = db.SocialStatuses.Local.ToList();
                    Policies       = db.Policies.Local.ToList();
                    Disabilities   = db.Disabilities.Local.ToList();
                    EyeSides       = db.EyeSides.Local.ToList();
                }

                //Общая информация о пациенте
                ReplaceText(app, "#Name", VMP.Patient.Name);
                ReplaceText(app, "#Birthday", VMP.Patient.Birthday.ToShortDateString());
                ReplaceText(app, "#Policy", Policies.FirstOrDefault(x => x.Id == VMP.Patient.PoliceId).Name);
                ReplaceText(app, "#PoliceNumber", VMP.Patient.PoliceNumber);
                ReplaceText(app, "#Address", VMP.Patient.Address);
                ReplaceText(app, "#Phone", VMP.Patient.Phone);
                ReplaceText(app, "#lgota", GetLgota(Disabilities));
                ReplaceText(app, "#SocialStatus", GetSocialStatus(SocialStatuses));

                //Основной анамнез
                ReplaceText(app, "#Complaints", VMP.GeneralHistory.Complaints);
                ReplaceText(app, "#DiseaseHistory", VMP.GeneralHistory.DiseaseHistory);
                ReplaceText(app, "#Operations ", string.IsNullOrEmpty(VMP.GeneralHistory.Operations) ? "отрицает" : VMP.GeneralHistory.Operations);
                ReplaceText(app, "#ChronicDiseases", string.IsNullOrEmpty(VMP.GeneralHistory.ChronicDiseases) ? "отрицает" : VMP.GeneralHistory.ChronicDiseases);
                ReplaceText(app, "#AllergyHistory", string.IsNullOrEmpty(VMP.GeneralHistory.AllergyHistory) ? "отрицает" : VMP.GeneralHistory.AllergyHistory);

                //Объективно
                GetObjectively(app, EyeSides);

                //Данные дополнительных исследований
                //Общий анализ крови

                if (VMP.AdditionalResearch.GeneralBloodAnalysis.IsNull())
                {
                    ClearText(doc, "GBA");
                }
                else
                {
                    ReplaceText(app, "#GeneralBloodDate", VMP.AdditionalResearch.GeneralBloodAnalysis.Date == null ? ": " : $" от {VMP.AdditionalResearch.GeneralBloodAnalysis.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#Hb", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.Hb) ? "" : $"Hb {VMP.AdditionalResearch.GeneralBloodAnalysis.Hb}; ");
                    ReplaceText(app, "#E_C", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.E_C) ? "" : $"э/ц {VMP.AdditionalResearch.GeneralBloodAnalysis.E_C}х10^12/л; ");
                    ReplaceText(app, "#CP", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.CP) ? "" : $"ЦП {VMP.AdditionalResearch.GeneralBloodAnalysis.CP}; ");
                    ReplaceText(app, "#L_C", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.L_C) ? "" : $"л/ц {VMP.AdditionalResearch.GeneralBloodAnalysis.L_C}х10^9/л; ");
                    ReplaceText(app, "#T_C", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.T_C) ? "" : $"т/ц {VMP.AdditionalResearch.GeneralBloodAnalysis.T_C}х10^9/л; ");
                    ReplaceText(app, "#P_YA", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.P_YA) ? "" : $"п/я {VMP.AdditionalResearch.GeneralBloodAnalysis.P_YA}%; ");
                    ReplaceText(app, "#C_YA", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.C_YA) ? "" : $"с/я {VMP.AdditionalResearch.GeneralBloodAnalysis.C_YA}%; ");
                    ReplaceText(app, "#E_O", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.E_O) ? "" : $"э/о {VMP.AdditionalResearch.GeneralBloodAnalysis.E_O}%; ");
                    ReplaceText(app, "#L_F", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.L_F) ? "" : $"л/ф {VMP.AdditionalResearch.GeneralBloodAnalysis.L_F}%; ");
                    ReplaceText(app, "#MO", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.MO) ? "" : $"мо {VMP.AdditionalResearch.GeneralBloodAnalysis.MO}%; ");
                    ReplaceText(app, "#COE", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralBloodAnalysis.COE) ? "" : $"СОЭ {VMP.AdditionalResearch.GeneralBloodAnalysis.COE}мм/ч; ");
                }


                //Биохимический анализ крови
                if (VMP.AdditionalResearch.ChemistryBloodAnalysis.IsNull())
                {
                    ClearText(doc, "CBA");
                }
                else
                {
                    ReplaceText(app, "#ChemistryBloodDate", VMP.AdditionalResearch.ChemistryBloodAnalysis.Date == null ? ": " : $" от {VMP.AdditionalResearch.ChemistryBloodAnalysis.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#Creatinine", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.Creatinine) ? "" : $"креатинин {VMP.AdditionalResearch.ChemistryBloodAnalysis.Creatinine} ммоль/л; ");
                    ReplaceText(app, "#ChemistryBloodUrea", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.Urea) ? "" : $"мочевина {VMP.AdditionalResearch.ChemistryBloodAnalysis.Urea} ммоль/л; ");
                    ReplaceText(app, "#CommonXC", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.CommonXC) ? "" : $"общих ХС {VMP.AdditionalResearch.ChemistryBloodAnalysis.CommonXC} ммоль/л; ");
                    ReplaceText(app, "#ChemistryBloodGlucose", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.Glucose) ? "" : $"глюкоза {VMP.AdditionalResearch.ChemistryBloodAnalysis.Glucose} ммоль/л; ");
                    ReplaceText(app, "#TotalBilirubin", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.TotalBilirubin) ? "" : $"общий билирубин {VMP.AdditionalResearch.ChemistryBloodAnalysis.TotalBilirubin} ммоль/л; ");
                    ReplaceText(app, "#TotalProtein", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.TotalProtein) ? "" : $"общий белок {VMP.AdditionalResearch.ChemistryBloodAnalysis.TotalProtein} г/л; ");
                    ReplaceText(app, "#Albumen", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.Albumen) ? "" : $"альбумин {VMP.AdditionalResearch.ChemistryBloodAnalysis.Albumen} г/л; ");
                    ReplaceText(app, "#ALT", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.ALT) ? "" : $"АЛТ {VMP.AdditionalResearch.ChemistryBloodAnalysis.ALT} Ед; ");
                    ReplaceText(app, "#ACT", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.ACT) ? "" : $"АСТ {VMP.AdditionalResearch.ChemistryBloodAnalysis.ACT} Ед; ");
                    ReplaceText(app, "#TG", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.TG) ? "" : $"ТГ {VMP.AdditionalResearch.ChemistryBloodAnalysis.TG} мкмоль/л; ");
                    ReplaceText(app, "#LPVP", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.LPVP) ? "" : $"ЛПВП {VMP.AdditionalResearch.ChemistryBloodAnalysis.LPVP} ммоль/л; ");
                    ReplaceText(app, "#LPNP", string.IsNullOrEmpty(VMP.AdditionalResearch.ChemistryBloodAnalysis.LPNP) ? "" : $"ЛПНП {VMP.AdditionalResearch.ChemistryBloodAnalysis.LPNP} ммоль/л; ");
                }

                //MP
                if (VMP.AdditionalResearch.MP.IsNull())
                {
                    ClearText(doc, "MP");
                }
                else
                {
                    ReplaceText(app, "#MPDate", VMP.AdditionalResearch.MP.Date == null ? ": " : $" от {VMP.AdditionalResearch.MP.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#MPResult", string.IsNullOrEmpty(VMP.AdditionalResearch.MP.Result) ? "" : $" {VMP.AdditionalResearch.MP.Result} результат; ");
                }

                //Общий анализ мочи
                if (VMP.AdditionalResearch.GeneralUrineAnalysis.IsNull())
                {
                    ClearText(doc, "GUA");
                }
                else
                {
                    ReplaceText(app, "#GeneralUrineDate", VMP.AdditionalResearch.GeneralUrineAnalysis.Date == null ? ": " : $" от {VMP.AdditionalResearch.GeneralUrineAnalysis.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#UrineColor", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Color) ? "" : $"цвет {VMP.AdditionalResearch.GeneralUrineAnalysis.Color.ToLower()}, ");
                    ReplaceText(app, "#UrineDensity", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Density) ? "" : $"плотность {VMP.AdditionalResearch.GeneralUrineAnalysis.Density.ToLower()}, ");
                    ReplaceText(app, "#UrineReaction", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Reaction) ? "" : $"реакция {VMP.AdditionalResearch.GeneralUrineAnalysis.Reaction.ToLower()}, ");
                    ReplaceText(app, "#UrineProtein", (string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Protein) && string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.ProteinWeight)) ? "" : $"{GetUrineProtein()}, ");
                    ReplaceText(app, "#UrineGlucose", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Glucose) ? "" : $"глюкоза {VMP.AdditionalResearch.GeneralUrineAnalysis.Glucose.ToLower()}, ");
                    ReplaceText(app, "#Urine_L_C", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.L_C) ? "" : $"л/ц {VMP.AdditionalResearch.GeneralUrineAnalysis.L_C} в п.зр., ");
                    ReplaceText(app, "#UrineEpithelialCells", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.EpithelialCells) ? "" : $"эпителиальные клетки {VMP.AdditionalResearch.GeneralUrineAnalysis.EpithelialCells}, ");
                    ReplaceText(app, "#UrineSlime", string.IsNullOrEmpty(VMP.AdditionalResearch.GeneralUrineAnalysis.Slime) ? "" : $"слизь {VMP.AdditionalResearch.GeneralUrineAnalysis.Slime.ToLower()}");
                }

                //Кал на я/г
                if (VMP.AdditionalResearch.Feces.IsNull())
                {
                    ClearText(doc, "FA");
                }
                else
                {
                    ReplaceText(app, "#FecesDate", VMP.AdditionalResearch.Feces.Date == null ? ": " : $" от {VMP.AdditionalResearch.Feces.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#FecesResult", string.IsNullOrEmpty(VMP.AdditionalResearch.Feces.Result) ? "" : $"{VMP.AdditionalResearch.GeneralUrineAnalysis.Color}.");
                }

                //ЭКГ
                if (VMP.AdditionalResearch.ECG.IsNull())
                {
                    ClearText(doc, "ECG");
                }
                else
                {
                    ReplaceText(app, "#ECGDate", VMP.AdditionalResearch.ECG.Date == null ? ": " : $" от {VMP.AdditionalResearch.ECG.Date?.ToShortDateString()}: ");
                    ReplaceText(app, "#ECGRhythm", string.IsNullOrEmpty(VMP.AdditionalResearch.ECG.Rhythm) ? "" : $"ритм {VMP.AdditionalResearch.ECG.Rhythm.ToLower()}, ");
                    ReplaceText(app, "#ECGRate", VMP.AdditionalResearch.ECG.Rate == 0 ? "" : $"ЧСС {VMP.AdditionalResearch.ECG.Rate} уд/ мин. ");
                    ReplaceText(app, "#ECGAdditionalInfo", string.IsNullOrEmpty(VMP.AdditionalResearch.ECG.AdditionalInfo) ? "" : $"{VMP.AdditionalResearch.ECG.AdditionalInfo}");
                }


                //Дополнительные исследования
                if (VMP.AdditionalResearch.OtherResearches != null)
                {
                    ReplaceList(app, "#AdditionalResearches", VMP.AdditionalResearch.OtherResearches);
                }


                //Осмотр специалистов
                if (VMP.SpecialistInspections != null)
                {
                    ReplaceList(app, "#SpecialistInspections", VMP.SpecialistInspections);
                }

                //Диагноз
                ReplaceText(app, "#MKB", VMP.Diagnos.DiagnosisCode);
                ReplaceText(app, "#GeneralDiagnosis", GetDiagnos());
                ReplaceText(app, "#CompanionDiagnosis", VMP.Diagnos.Companion);
                ReplaceText(app, "#VMPFor", VMP.Diagnos.VMPFor);

                //Подписи
                ReplaceText(app, "#DoctorPosition", settings.DoctorPosition);
                ReplaceText(app, "#DoctorName", settings.DoctorName);
                ReplaceText(app, "#BossDoctorPosition", settings.BossDoctorPosition);
                ReplaceText(app, "#BossDoctorName", settings.BossDoctorName);

                string name = String.Format($"{VMP.Patient.Name}.docx");

                Object fileFormat = Word.WdSaveFormat.wdFormatDocumentDefault;
                Object fileName   = settings.SavePath + @"\" + name;


                doc.SaveAs(fileName, fileFormat, falseObj, missingObj, falseObj, missingObj, falseObj, falseObj, falseObj, falseObj, missingObj, missingObj, missingObj, missingObj, missingObj, missingObj);
                ((Word._Document)doc).Close(ref saveChanges);
                app.Quit();
                return("ВМП сформирован");
            }
            catch (Exception ex)
            {
                app.Quit();
                return("Ошибка формирования ВМП: " + ex.Message);
            }
        }
Beispiel #5
0
        public int DisplayPolicyUsers(string policyName, bool onlyCount = false)
        {
            var users  = new List <string>();
            var policy = Policies.FirstOrDefault(x => x.Name.ToLower() == policyName.ToLower());

            if (policy != null)
            {
                if (policy.IsFineGrained)
                {
                    users = policy.AppliesToUsers;
                }
                else
                {
                    var domUsers = new List <string>();
                    Users.ForEach(x => domUsers.Add(x.Username));

                    var fgUsers = new List <string>();
                    Policies.Where(x => x.IsFineGrained).ToList()
                    .ForEach(p => p.AppliesToUsers.ForEach(x => fgUsers.Add(x)));

                    users = domUsers.Where(p => fgUsers.All(p2 => p2.ToLower() != p.ToLower()))
                            .Distinct().ToList();
                }

                if (!onlyCount)
                {
                    _logger.Log($"-----------------------------------");

                    var contents        = string.Empty;
                    var now             = DateTime.Now;
                    var path            = string.IsNullOrEmpty(Config.OutputPath) ? "c:\\" : Config.OutputPath;
                    var cleanPolicyName = Regex.Replace(policy.Name, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);
                    var fileNameNow     = now.ToString("yyyyMddHHmm");
                    var fileName        = $"policyusers_{cleanPolicyName}_{fileNameNow}.txt";
                    var filePath        = Path.Combine(path, fileName);
                    var fileNow         = now.ToString("MM/dd/yyyy h:mm tt");

                    foreach (var user in users)
                    {
                        _logger.Log($"User: {user}");

                        if (Config.SaveOutput)
                        {
                            contents += $"{user}\n";
                        }
                    }

                    if (Config.SaveOutput)
                    {
                        File.WriteAllText(filePath, contents);
                    }

                    _logger.Log($"-----------------------------------");
                }
            }
            else
            {
                _logger.Log($"Policy not found: {policyName}");
            }
            return(users.Count);
        }