public FormPatientHistory(Patient patient)
        {
            InitializeComponent();

            Methods.SetWindowsIcon(this);

            UCPatientHistory ucPatientHistory = new UCPatientHistory(patient.Id);

            ucPatientHistory.Dock = DockStyle.Fill;
            this.Controls.Add(ucPatientHistory);
            //ucPatientHistory.SetAcceptCancelButtons(this);
            ucPatientHistory.Disposed += delegate { this.Close(); };
        }
        public FormPatientDoc(Patient p)
        {
            DataLayer.BeginTransaction();

            InitializeComponent();

            Methods.SetWindowsIcon(this);

            KeyPreview = true;

            ucDoc = new UCpatientDocument();
            //ucDoc.Height = this.Height - 50;
            ucDoc.Dock = DockStyle.Fill;
            this.Disposed += (x, y) => DataLayer.EndTransaction();
            ucContainer.Controls.Add(ucDoc);
            ucDoc.docForThisPatient = p;
        }
        public UCDefinePatientMainInfo(Patient p)
        {
            DataLayer.BeginTransaction();
            InitializeComponent();

            SetIcons();

            this.Disposed += (x, y) => DataLayer.EndTransaction();

            lstIns.DataSource = DataLayer.GetInsurances(true);
            grdPatient.DataSource =new BindingList<Patient> ( DataLayer.GetPatients(true));

            clear();
            GridViewRowInfo a = grdPatient.Rows.FirstOrDefault(x => (x.DataBoundItem as Patient).AccountantCode == p.AccountantCode);
            if (a != null)
                a.IsSelected = true;

            ucFilter1.Grid = grdPatient;
        }
Exemple #4
0
        internal void setPatientHistory(Patient p)
        {
            clear();
            ucTooth.ChildTooth = p.IsChild;
            ////all visit option
            //Visit allVisit = new Visit();
            //allVisit.Comment = "همه ویزیت ها";
            //allVisit.FromTime = DateTime.Now;
            //allVisit.Id = -1;
            //_visits.Add(allVisit);
            ////
            foreach (Visit v in p.Visits)
            {

                _visits.Add(v);

                foreach (VisitDrug vd in v.VisitDrugs)
                    _drugs.Add(vd);

                foreach (VisitService vssrv in v.VisitServices)
                {
                    _Srvs.Add(new PatientHistory(vssrv));
                }

            }
            ucTooth.SelectedTooths = toothValue(p.Visits.ToArray());
            grdVisits.DataSource = _visits;
            linkLabel1_LinkClicked(null,null);

            grdSrvs.DataSource = _Srvs;
            grdSrvs.CurrentRow = null;

            grdDrugs.DataSource = _drugs;
            grdDrugs.CurrentRow = null;

            ucTooth.SelectedTooths = allTeeth;
        }
Exemple #5
0
        public static void LoadPatientDocuments(Patient patient, DirectoryInfo patientDirectory, PatientDocument[] documents)
        {
            EntityModelContainer context = patient.Context;

            for (int i = 0; i < documents.Length; i++)
            {
                try
                {
                    string path = Path.Combine(patientDirectory.FullName, documents[i].FileName);
                    int documentId = documents[i].DocumentId;
                    Deserialize(path, context.Documents.First(d => d.Id == documentId));
                    File.SetLastWriteTime(path, documents[i].LastModifiedDate);
                }
                catch
                {

                }
            }
        }
Exemple #6
0
        public static bool HasSameEntity(Patient entity)
        {
            EntityModelContainer context = entity.Context;

            if (context.ObjectStateManager.GetObjectStateEntries
                ((EntityState.Added | EntityState.Modified | EntityState.Unchanged))
                .Select(e => e.Entity).OfType<Patient>()
                .Any(x => x.FirstName == entity.FirstName && x.LastName == entity.LastName
                && (x != entity)))
                return true;

            return false;
        }
Exemple #7
0
        public static VisitService[] GetPatientPastServices(Patient patient)
        {
            EntityModelContainer context = GetContext();

            if (patient == null)
                return null;

            Visit[] visits = context.Visits.Include("VisitServices").Execute(MergeOption.NoTracking)
                .Where(v => v.PatientId == patient.Id && v.Date < DateTime.Now).ToArray();

            List<VisitService> lstResult = new List<VisitService>();
            for (int i = 0; i < visits.Length; i++)
            {
                lstResult.AddRange(visits[i].VisitServices.ToArray());
            }

            return lstResult.ToArray();
        }
Exemple #8
0
        public static PatientDocument[] GetPatientFileDetails(Patient patient)
        {
            EntityModelContainer context = new EntityModelContainer(GetEntityConnection());

            PatientDocument[] result = context.PatientDocuments.Execute(MergeOption.NoTracking).Where(pd => pd.PatientId == patient.Id).ToArray();

            for (int i = 0; i < result.Length; i++)
            {
                int id = result[i].Id;
                DocumentStickyNote[] documentStickyNotes =
                    context.DocumentStickyNotes.Execute(MergeOption.NoTracking).Where(sn => sn.PatientDocumentId == id).ToArray();

                if (documentStickyNotes.Length!=0)
                    result[i].DocumentStickyNotes.AddRange(documentStickyNotes);
            }

            context.Dispose();
            return result;
        }
Exemple #9
0
        public static InsuranceDef[] GetInsuranceDefs(Patient patient, Service service)
        {
            EntityModelContainer context = GetContext();
            List<InsuranceDef> lstResult = new List<InsuranceDef>();

            InsPtn[] patientInsurances =
                context.InsPtns.Execute(MergeOption.NoTracking)
                .Where(ip => ip.PatientId == patient.Id).ToArray();

            foreach (var patientInsurance in patientInsurances)
            {
                lstResult.AddRange
                    (
                        context.InsuranceDefs.Include("Insurance").Include("Service").Execute(MergeOption.OverwriteChanges)
                        .Where(id => id.InsuranceId==patientInsurance.InsuranceId && id.ServiceId == service.Id && id.Fee>0).ToArray()
                    );
            }

            return lstResult.ToArray();
        }
 /// <summary>
 /// Create a new Patient object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="pregnancy">Initial value of the Pregnancy property.</param>
 /// <param name="hepatit">Initial value of the Hepatit property.</param>
 /// <param name="isCodeAutoGenerated">Initial value of the IsCodeAutoGenerated property.</param>
 /// <param name="heartDesease">Initial value of the HeartDesease property.</param>
 /// <param name="breathDesease">Initial value of the BreathDesease property.</param>
 /// <param name="bloodDesease">Initial value of the BloodDesease property.</param>
 /// <param name="tiroeedDesease">Initial value of the TiroeedDesease property.</param>
 /// <param name="radioTeraphy">Initial value of the RadioTeraphy property.</param>
 /// <param name="chemicalCure">Initial value of the ChemicalCure property.</param>
 /// <param name="bloodPresure">Initial value of the BloodPresure property.</param>
 /// <param name="diabetic">Initial value of the Diabetic property.</param>
 /// <param name="alergy">Initial value of the Alergy property.</param>
 /// <param name="kidneyDesease">Initial value of the KidneyDesease property.</param>
 /// <param name="neuroticDesease">Initial value of the NeuroticDesease property.</param>
 /// <param name="asthmaAfterInjection">Initial value of the AsthmaAfterInjection property.</param>
 /// <param name="singcobAfterInjection">Initial value of the SingcobAfterInjection property.</param>
 /// <param name="isChild">Initial value of the IsChild property.</param>
 public static Patient CreatePatient(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.Boolean pregnancy, global::System.Boolean hepatit, global::System.Boolean isCodeAutoGenerated, global::System.Boolean heartDesease, global::System.Boolean breathDesease, global::System.Boolean bloodDesease, global::System.Boolean tiroeedDesease, global::System.Boolean radioTeraphy, global::System.Boolean chemicalCure, global::System.Boolean bloodPresure, global::System.Boolean diabetic, global::System.Boolean alergy, global::System.Boolean kidneyDesease, global::System.Boolean neuroticDesease, global::System.Boolean asthmaAfterInjection, global::System.Boolean singcobAfterInjection, global::System.Boolean isChild)
 {
     Patient patient = new Patient();
     patient.Id = id;
     patient.FirstName = firstName;
     patient.LastName = lastName;
     patient.Pregnancy = pregnancy;
     patient.Hepatit = hepatit;
     patient.IsCodeAutoGenerated = isCodeAutoGenerated;
     patient.HeartDesease = heartDesease;
     patient.BreathDesease = breathDesease;
     patient.BloodDesease = bloodDesease;
     patient.TiroeedDesease = tiroeedDesease;
     patient.RadioTeraphy = radioTeraphy;
     patient.ChemicalCure = chemicalCure;
     patient.BloodPresure = bloodPresure;
     patient.Diabetic = diabetic;
     patient.Alergy = alergy;
     patient.KidneyDesease = kidneyDesease;
     patient.NeuroticDesease = neuroticDesease;
     patient.AsthmaAfterInjection = asthmaAfterInjection;
     patient.SingcobAfterInjection = singcobAfterInjection;
     patient.IsChild = isChild;
     return patient;
 }
        /// <summary>
        /// Use this method for before doing any file oriented task on patient profile.
        /// this methods start monitoring RVG folder, and serves document and file related tasks
        /// for a patient.
        /// </summary>
        /// <param name="patient"></param>
        public void BeginMonitor(Patient patient)
        {
            _patient = patient;

            CheckError();

            if (_rvgWatcher != null)
                _rvgWatcher.Dispose();

            if (!string.IsNullOrEmpty(_rvgPath.Trim()))
            {
                if(!Directory.Exists(_rvgPath))
                    Directory.CreateDirectory(_rvgPath);
                SetRvgWatcher();
            }

            _patientDirectory = new DirectoryInfo(GetPatientDirectoryName(patient));

            if (!_patientDirectory.Exists)
                _patientDirectory.Create();

            LoadFromDatabase();

            SetpatientDirectoryWatcher();
        }
Exemple #12
0
        public static void SavePatientDocumentsStickyNotes(Patient patient, PatientDocument[] documents)
        {
            EntityModelContainer context = patient.Context;

            for (int i = 0; i < documents.Length; i++)
            {
                int id = documents[i].Id;
                DocumentStickyNote[] delNotes =
                            context.DocumentStickyNotes.Execute(MergeOption.OverwriteChanges).Where(dn => dn.PatientDocumentId == id).ToArray();
                for (int j = 0; j < delNotes.Length; j++)
                    context.DocumentStickyNotes.DeleteObject(delNotes[j]);

                context.SaveChanges();

                for (int k = 0; k < documents[i].DocumentStickyNotes.Count; k++)
                {
                    documents[i].DocumentStickyNotes[k].PatientDocumentId = documents[i].Id;
                    context.PatientDocuments.Attach(documents[i]);
                    context.DocumentStickyNotes.AddObject(documents[i].DocumentStickyNotes[k]);
                }

                context.SaveChanges();

                for (int k = 0; k < documents[i].DocumentStickyNotes.Count; k++)
                    context.DocumentStickyNotes.Detach(documents[i].DocumentStickyNotes[k]);

                if(documents[i].EntityState!=EntityState.Detached)
                    context.PatientDocuments.Detach(documents[i]);
            }
        }
        private bool validateForm(Patient patient)
        {
            if (string.IsNullOrWhiteSpace(patient.ToString()))
            {
                Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "نام بیمار را وارد نمایید");
                return false;
            }

            string ph1 = patient.HomeNumber;
            if (!string.IsNullOrEmpty(ph1))
            {
                if (!Regex.IsMatch(ph1, @"[\d]+"))
                {
                    Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "شماره تلفن صحیح وارد نمایید.");
                    return false;
                }

            }
            string ph2 = patient.CellNumber;
            if (!string.IsNullOrEmpty(ph2))
            {
                if (ph2.Count() != 11 || !Regex.IsMatch(ph2, @"[\d]+"))
                {
                    Methods.ShowStandardMsgBox(FormMessageType.Error, "خطا", "شماره تلفن همراه صحیح وارد نمایید. مانند 09121112233");
                    return false;
                }
            }

            return true;
        }
 private void setPatientInfo(Patient pt)
 {
     btnHistory.Enabled = btnDocs.Enabled = (pt.EntityState == EntityState.Unchanged || pt.EntityState == EntityState.Modified);
     dpBirthDate.SelectedDateTime = (pt.BirthDate.HasValue) ? pt.BirthDate.Value : DateTime.Now;
     pt.Context = DataLayer.GetContext();
     patientBindingSource.DataSource = pt;
     selectListItems(pt.InsPtns.ToArray());
     patientBindingSource.ResetBindings(false);
 }
 private void setPatientInfo(Patient pt)
 {
     dpBirthDate.SelectedDateTime = (pt.BirthDate.HasValue) ? pt.BirthDate.Value : DateTime.Now;
     pt.Context = DataLayer.GetContext();
     patientBindingSource.DataSource = pt;
     selectListItems(pt.InsPtns.ToArray());
     patientBindingSource.ResetBindings(false);
 }
 private string GetPatientDirectoryName(Patient patient)
 {
     return _shayanRootDirectory + patient.AccountantCode + " " + patient;
 }
        public void EndMonitor()
        {
            CheckError();
            _patient = null;

            _patientDirectoryWatcher.EnableRaisingEvents = false;
            _patientDirectoryWatcher.Dispose();
        }
Exemple #18
0
        public static void SavePatientDocumentsContents(Patient patient, PatientDocument[] documents)
        {
            EntityModelContainer context = patient.Context;

            for (int i = 0; i < documents.Length; i++)
            {
                int documentId = documents[i].DocumentId;
                documents[i].Document = new Document();

                if (documents[i].Id != 0)
                {
                    documents[i].Document.Id = documentId;
                    documents[i].DocumentId = documentId;
                    context.Documents.Attach(documents[i].Document);
                    context.PatientDocuments.Attach(documents[i]);
                }
                else
                {
                    documents[i].FileName = documents[i].FileInfo.Name;
                    documents[i].PatientId = patient.Id;
                    context.PatientDocuments.AddObject(documents[i]);
                }

                documents[i].Document.Content = SerializeFile(documents[i].FileInfo);
                documents[i].LastModifiedDate = documents[i].FileInfo.LastWriteTime;
            }

            context.SaveChanges();

            for (int i = 0; i < documents.Length; i++)
            {
                context.Documents.Detach(documents[i].Document);
                context.PatientDocuments.Detach(documents[i]);
            }
        }
Exemple #19
0
        public static void SavePatientDocumentsDescription(Patient patient, PatientDocument[] documents)
        {
            EntityModelContainer context = patient.Context;

            for (int i = 0; i < documents.Length; i++)
            {
                context.PatientDocuments.Attach(documents[i]);
                context.ObjectStateManager.ChangeObjectState(documents[i], EntityState.Modified);
                context.SaveChanges();
            }

            for (int i = 0; i < documents.Length; i++)
                context.PatientDocuments.Detach(documents[i]);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Patients EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPatients(Patient patient)
 {
     base.AddObject("Patients", patient);
 }
Exemple #21
0
 public UCPatientHistory(Patient p)
 {
     InitializeComponent();
     DataLayer.BeginTransaction();
     setPatientHistory(p);
 }
Exemple #22
0
 public static Visit[] GetPatientVisits(Patient patient)
 {
     EntityModelContainer context = GetContext();
     return context.Visits.Where(v => v.PatientId == patient.Id).ToArray();
 }
 private void InititializeDate(int patientId)
 {
     DataLayer.BeginTransaction();
     _patient = DataLayer.GetPatientById(patientId);
     LoadPatientHistory();
 }
Exemple #24
0
 public static void DeletePatientFile(Patient patient, FileInfo file)
 {
     EntityModelContainer context = patient.Context;
     PatientDocument document = context.PatientDocuments.FirstOrDefault(pd => pd.FileName == file.Name);
     if (document != null)
     {
         context.Documents.DeleteObject(document.Document);
     }
 }