Beispiel #1
0
        public Form3(Database aDatabase, ref Note aNote, ref Patient aPatient)
        {
            InitializeComponent();

            database = aDatabase;

            note = aNote;
            patient = aPatient;

            dgDiagnosis.SetDataBinding(database.DsMaster, "Diagnosis");

            SetupPatientChargeComboBox();
            SetupVisitTypeComboBox();
            SetupTreeView();
            SetupDataGridDiagnosis();
        }
Beispiel #2
0
        public Form2(Database aDatabase, ref Patient aPatient)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            patient = aPatient;
            database = aDatabase;

            //Investige if the patient is a new patient or a already existing one

            regExpDate = new System.Text.RegularExpressions.Regex(@"(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])");

            UpdateForm();
        }
        public PreviousNotes(Database aDatabase, Patient aPatient)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            database = aDatabase;

            CurrencyManager cm = (CurrencyManager) this.BindingContext[database.DsMaster, "Patients"];
            System.Data.DataView dv = (System.Data.DataView) cm.List;
            dv.Sort = "patientid";
            int position = dv.Find(aPatient.Id);
            this.BindingContext[database.DsMaster, "Patients"].Position = position;
            dgNotes.SetDataBinding(database.DsMaster, "Patients.PatientNotes");

            SetupDataGridNotes();
        }
        public void SetContent(Patient patient, System.Data.DataView dv)
        {
            StringBuilder s = new StringBuilder();

            for (int i = 0; i < dv.Count; i++)
            {
                s.Append(((string)dv[i]["visitdatetime"]).Substring(0,10));
                if ((bool)dv[i]["signed"] == true)
                    s.Append("\t" + (string)dv[i]["note"] + "   [Sign/DR]" + "\n\n");
                else
                s.Append("\t" + (string)dv[i]["note"] + "\n\n");
            }

            contentString = s.ToString();

            name = patient.Firstname + " " + patient.Surname;
            personnumber = patient.Personnumber;
            address = patient.Street;
            postAddress = patient.Zipcode + " " + patient.City;
        }
        public PrintReceiptDlg(Database aDatabase, System.Data.DataSet aDsPatientNotes, Patient aPatient)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            database = aDatabase;
            dsPatientNotes = aDsPatientNotes;
            patient = aPatient;

            months = new ArrayList();
            year = System.DateTime.Now.Year;

            SetupPrinting(Settings.ReceiptLogoFilename);

            selectedRows = new ArrayList();

            lblPatient.Text = lblPatient.Text + " " + patient.Surname + " " + patient.Firstname + ", " + patient.Personnumber;

            dgReceipt.SetDataBinding(database.DsMaster, "Joined");
            SetupDataGridReceipt();

            SetupComboBoxPickYear();
            cmbPickMonth.SelectedIndexChanged +=new EventHandler(cmbPickMonth_SelectedIndexChanged);
            SetupComboBoxPickMonth();

            /*System.Windows.Forms.CurrencyManager cm = (CurrencyManager)BindingContext[dgReceipt.DataSource,dgReceipt.DataMember];
            System.Data.DataView dv = (System.Data.DataView) cm.List;

            int selectedMonth = System.DateTime.Now.Month;
            dv.RowFilter = "patientid=" + patient.Id + " AND SUBSTRING(visitdatetime,1,4)=" + year.ToString() + " AND SUBSTRING(visitdatetime,6,2)=" + selectedMonth;
            dv.Sort = "visitdatetime DESC";
            dgReceipt.CaptionText = "Besök under " + System.DateTime.Now.ToString("MMMM");
            */
        }
Beispiel #6
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            //Do validation of personnumber here
            if (txtPersonnumber.ValidateControl() == false)
            {
                this.DialogResult = DialogResult.None;
                return;
            }
            else
            {
                try
                {
                    //Check if the personnumber is valid
                    if  (Settings.IsCheckPersonnumberEnabled)
                        Utils.CheckPersonNumber(txtPersonnumber.Text);
                }
                catch (Exception exception)
                {
                    //If e.g. the date is invalid an exception is thrown
                    this.errorProvider1.SetError(txtPersonnumber, exception.Message);
                    this.DialogResult = DialogResult.None;
                    return;
                }

                //The personnumber is valid but before saving, check if it already exists in the database
                patient.Personnumber = txtPersonnumber.Text;
            }

            patient.Firstname = txtFirstname.Text;
            patient.Surname = txtSurname.Text;

            patient.Street = txtStreet.Text;

            //Non-mandatory fields
            //TODO: modify regexp to allow an empty string?
            patient.Zipcode = txtZipcode.Text;
            /*if (txtZipcode.Text.Length != 0)
            {
                if (txtZipcode.ValidateControl() == false)
                    this.DialogResult = DialogResult.None;
                else
                    patient.Zipcode = txtZipcode.Text;
            }*/

            patient.City = txtCity.Text;
            patient.HomePhone = txtHomePhone.Text;
            patient.WorkPhone = txtWorkPhone.Text;
            patient.MobilePhone = txtMobilePhone.Text;
            patient.Info = txtMisc.Text;

            //Validation of date for expiry of freecard
            if (rbHasFreecard.Checked)
            {
                if (txtFreecardDate.ValidateControl() == false)
                {
                    this.DialogResult = DialogResult.None;
                }
                else
                {
                    //The try is not neccessary since the textbox validation checks that the date also is valid, not only the format
                    try
                    {
                        patient.FreecardDate = System.DateTime.Parse(txtFreecardDate.Text);
                    }
                    catch (FormatException exception)
                    {
                        this.errorProvider1.SetError(txtFreecardDate, "Det angivna datumet är ogiltigt.");
                        this.DialogResult = DialogResult.None;
                    }
                }
            }
            else
                patient.FreecardDate = new System.DateTime((long)0);

            //Last thing before saving the patient, check if it already exists int the database
            if ((originalPersonnumber != patient.Personnumber) && database.IsAlreadyExsisting(patient))
            {
                //The user is notified if there already exists a patient with the given personnumber
                DialogResult dialogResult = MessageBox.Show("Det finns redan en patient med det här personnumret.\nVill du öppna den redan existerande patienten med det angivna personnumret?\n\nOm du vill öppna den existerande patienten tryck Ja.\nTryck Nej för att mata in ett nytt personnummer.", "Meddelande", MessageBoxButtons.YesNo);
                switch (dialogResult)
                {
                    case DialogResult.Yes:
                        patient = database.ReturnAlreadyExsisting(patient);
                        UpdateForm();
                        this.DialogResult = DialogResult.None;
                        break;
                    case DialogResult.No:
                        txtPersonnumber.ResetText();
                        this.DialogResult = DialogResult.None;
                        break;
                }
            }
        }
Beispiel #7
0
 public PatientNote(Patient aPatient, Note aNote, Charge aCharge)
 {
     patient = aPatient;
     note = aNote;
     charge = aCharge;
 }
Beispiel #8
0
        private void btnNewPatient_Click(object sender, System.EventArgs e)
        {
            Patient newPatient = new Patient();
            Form2 dlgNewPatient = new Form2(database, ref newPatient);

            if (dlgNewPatient.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                database.Add(newPatient);
                //TODO: Select the new patient and sort the datagrid
                patient = null;
            }

            dlgNewPatient.Dispose();
        }
Beispiel #9
0
        private void UpdatePatient(DataGrid dataGrid)
        {
            System.Windows.Forms.CurrencyManager cm = (CurrencyManager)BindingContext[dataGrid.DataSource,dataGrid.DataMember];
            System.Data.DataView dv = (System.Data.DataView) cm.List;

            selectedPatientRow = dv[cm.Position];

            //Create the corresponding Patient object
            patient = database.CreatePatient(selectedPatientRow.Row, null);

            Debug.WriteLine("Current patient: id=" + patient.Id + ", " + patient.Firstname + " " + patient.Surname);

            Utils.AutoSizeDataGrid(new string[]{"note"}, dgNotes, this.BindingContext, 0);
        }
Beispiel #10
0
        public void Update(Patient patient)
        {
            System.Data.DataView dv = new System.Data.DataView();
            dv.Table = dsMaster.Tables["Patients"];
            dv.Sort = "patientid";

            if (patient != null)
            {
                int index = dv.Find(patient.Id);
                if (index == -1)
                {
                    //The patient could not be found in the database
                    Debug.WriteLine("" + this.GetType().Name + "(Update): En patient med detta ID kunde inte hittas i database, lägger till som ny data istället");
                    Add(patient);
                }

                System.Data.DataRow dr = dv[index].Row;

                dr.BeginEdit();

                dr["firstname"] = patient.Firstname;
                dr["surname"] = patient.Surname;
                dr["personnumber"] = patient.Personnumber;
                dr["street"] = patient.Street;
                dr["zipcode"] = patient.Zipcode;
                dr["city"] = patient.City;
                dr["homephone"] = patient.HomePhone;
                dr["workphone"] = patient.WorkPhone;
                dr["mobilephone"] = patient.MobilePhone;
                dr["info"] = patient.Info;
                dr["freecarddate"] = patient.FreecardDate;

                dr.EndEdit();

                if (dr.RowState != System.Data.DataRowState.Unchanged)
                    daPatients.Update(dsMaster, "Patients");
            }
        }
Beispiel #11
0
        public Patient ReturnAlreadyExsisting(Patient patient)
        {
            DataView dv = new DataView();
            dv.Table = dsMaster.Tables["Patients"];
            dv.RowFilter = "personnumber='" + patient.Personnumber + "'";

            if (dv.Count == 1)
            {
                return CreatePatient(dv[0].Row, patient);
            }
            else if (dv.Count < 1)
                return null;
            else
                throw new Exception("Allvarligt fel. Det finns redan två existerande patienter med samma personnummer.");
        }
Beispiel #12
0
 public bool IsAlreadyExsisting(Patient patient)
 {
     DataView dv = new DataView();
     dv.Table = dsMaster.Tables["Patients"];
     dv.Sort = "patientid";
     dv.RowFilter = "personnumber='" + patient.Personnumber + "'";
     if (dv.Count > 0)
         return true;
     else
         return false;
 }
Beispiel #13
0
        /// <summary>
        /// Creates a new patient object or updates an existing patient object.
        /// </summary>
        /// <param name="dr">A datarow with patient information.</param>
        /// <param name="aPatient">If the intention is to copy (i.e. update) an already existing patient object, then pass the object otherwise null</param>
        /// <returns></returns>
        public Patient CreatePatient(System.Data.DataRow dr, Patient aPatient)
        {
            Patient patient;

            if (aPatient == null)
                patient = new Patient();
            else
                patient = aPatient;

            if (!dr.HasErrors && dr != null)
            {

                if (dr["patientid"] != System.DBNull.Value)
                    patient.Id = (int) dr["patientid"];
                else
                    throw new Exception("Programmet försökte läsa in en patient som saknar id.");
                if (dr["surname"] != System.DBNull.Value)
                    patient.Surname = (string) dr["surname"];
                if (dr["firstname"] != System.DBNull.Value)
                    patient.Firstname = (string) dr["firstname"];
                if (dr["street"] != System.DBNull.Value)
                    patient.Street = (string) dr["street"];
                if (dr["zipcode"] != System.DBNull.Value)
                    patient.Zipcode = (string) dr["zipcode"];
                if (dr["city"] != System.DBNull.Value)
                    patient.City = (string) dr["city"];
                if (dr["homephone"] != System.DBNull.Value)
                    patient.HomePhone = (string) dr["homephone"];
                if (dr["workphone"] != System.DBNull.Value)
                    patient.WorkPhone = (string) dr["workphone"];
                if (dr["mobilephone"] != System.DBNull.Value)
                    patient.MobilePhone = (string) dr["mobilephone"];
                if (dr["personnumber"] != System.DBNull.Value)
                    patient.Personnumber = (string) dr["personnumber"];
                else
                    throw new Exception("Programmet försökte läsa in en patient som saknar personnummer.");
                if (dr["info"] != System.DBNull.Value)
                    patient.Info = (string) dr["info"];
                if (dr["freecarddate"] != System.DBNull.Value)
                    patient.FreecardDate = System.DateTime.Parse((string) dr["freecarddate"]);

            }

            return patient;
        }
Beispiel #14
0
        /// <summary>
        /// Adds a new patient to the database. If the new patients personnumber already exists in the database
        /// this indicates either lack of personnumber-check or that existing patientinformation is supposed to be updated.
        /// Since this function expects control of personnumber at a higher level, it will call the Update function
        /// with the patient if the personnumber already exists.
        /// </summary>
        /// <param name="patient"></param>
        public void Add(Patient patient)
        {
            // Search for id and personnumber in table Patients
            if (IsAlreadyExsisting(patient))
            {
                Debug.WriteLine("" + this.GetType().Name + "(Add): En patient med detta personnummer finns redan inlagd, uppdaterar existerande data istället");
                Update(patient);
                return;
            }

            System.Data.DataRow dr = dsMaster.Tables["Patients"].NewRow();
            dr["firstname"] = patient.Firstname;
            dr["surname"] = patient.Surname;
            dr["personnumber"] = patient.Personnumber;
            dr["street"] = patient.Street;
            dr["zipcode"] = patient.Zipcode;
            dr["city"] = patient.City;
            dr["homephone"] = patient.HomePhone;
            dr["workphone"] = patient.WorkPhone;
            dr["mobilephone"] = patient.MobilePhone;
            dr["info"] = patient.Info;
            dr["freecarddate"] = patient.FreecardDate;

            dsMaster.Tables["Patients"].Rows.Add(dr);
            daPatients.Update(dsMaster, "Patients");
        }