Ejemplo n.º 1
0
        public void TestAllergyClass()
        {
            Allergy a = new Allergy();
            a.allergyId = 1;
            a.name = "abc";
            a.category = "cde";

            Assert.IsNotNull(a);
            Assert.AreEqual(1, a.allergyId);
            Assert.AreEqual("abc", a.name);
            Assert.AreEqual("cde", a.category);
           
        }
Ejemplo n.º 2
0
        private static void insertAllergy(Allergy allergy)
        {
            myConnection.Open();

            SqlCommand cmd = new SqlCommand("insert into Allergy(name, category) values(@name, @category);");
            cmd.Connection = myConnection;

            cmd.Parameters.AddWithValue("@name", allergy.name);
            cmd.Parameters.AddWithValue("@category", allergy.category);
            
            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();


            myConnection.Close();
        }
Ejemplo n.º 3
0
        private static void insertAllergy(Allergy allergy)
        {
            myConnection.Open();

            SqlCommand cmd = new SqlCommand("insert into Allergy(name, category) values(@name, @category);");

            cmd.Connection = myConnection;

            cmd.Parameters.AddWithValue("@name", allergy.name);
            cmd.Parameters.AddWithValue("@category", allergy.category);

            cmd.CommandType = CommandType.Text;
            cmd.ExecuteNonQuery();


            myConnection.Close();
        }
Ejemplo n.º 4
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            bool DOB_valid;
            bool exp_valid;
            bool pass=false;

            //check whether Insurance numer exits
            dictionary = new Dictionary<string, string>();
            dictionary.Add("@insuranceNumber", txtInsuranceNumber.Text);
            dc = new DatabaseConnector();
            dtInsurance = dc.getData("CheckInsuranceExists", dictionary);
            int ins_exist = int.Parse(dtInsurance.Rows[0][0].ToString());

            //create new patient
            Patient patient = new Patient();
            patient.firstName = txtFirstName.Text;
            patient.lastName = txtLastName.Text;
            patient.dob = txtDOB.Text;
            patient.gender = cmbxGender.GetItemText(cmbxGender.SelectedItem);

            //create new insurance
            Insurance insurance = new Insurance();
            insurance.timestamp = System.DateTime.Today.ToShortDateString();
            insurance.insNumber = txtInsuranceNumber.Text;
            insurance.versionCode = txtVersionCode.Text;
            insurance.expDate = txtInsuranceExpDate.Text;

            //create new allergy
            Allergy allergy = new Allergy();
            allergy.name = txtAllergyName.Text;
            allergy.category = txtAllergyCatergory.Text;

            //create new allergy-patient
            PatientAllergy ptAllgergy = new PatientAllergy();

            //
            Doctor doctor = new Doctor();
            doctor.billingCode = txtDoctorBillingCode.Text;
            doctor.name = txtReferralDoctor.Text;

            //
            ReferralDoctor refDoctor = new ReferralDoctor();

                    
            //ins number : number only
            //ins vc : character only
            //no blank: name, dob

            Phone phone = new Phone();
            phone.type = cmbxPhoneType.GetItemText(cmbxPhoneType.SelectedItem);
            phone.phoneNumber = txtPhoneNumber.Text;

            Email email = new Email();
            email.type = cmbxEmailType.GetItemText(cmbxEmailType.SelectedItem);
            email.email = txtEmail.Text;

            Address address = new Address();
            address.type = cmbxAddressType.GetItemText(cmbxAddressType.SelectedItem);
            address.address = txtAddress.Text;
            address.city = txtCity.Text;
            address.province = txtProvince.Text;
            address.postalCode = txtPostalCode.Text;

            DOB_valid = DOB_validation();
            exp_valid = exp_validation();

            if (DOB_valid == true && exp_valid == true && ins_exist == 0 && txtInsuranceNumber.TextLength == 10)
            {
                pass = true;
            }

              if (pass == true )
              {
                  insertPatient(patient);

                  patient.patientID = getPtIdfromPatienTbl();
                  insurance.patientID = patient.patientID;
                  phone.patientID = patient.patientID;
                  email.patientID = patient.patientID;
                  address.patientID = patient.patientID;
                  

                  insertInsurance(insurance);

                  if (txtAllergyCatergory.Text != "" && txtAllergyName.Text != "")
                  {

                      if (getAllergyIdfromAllergyTbl1() != 0)
                      {
                          ptAllgergy.patientId = patient.patientID;
                          ptAllgergy.allergyId = getAllergyIdfromAllergyTbl1();
                          insertPatientAllergy(ptAllgergy);
                      }
                      else
                      {
                          insertAllergy(allergy);
                          ptAllgergy.patientId = patient.patientID;
                          ptAllgergy.allergyId = getAllergyIdfromAllergyTbl2();
                          insertPatientAllergy(ptAllgergy);
                      }
                  }
                    
                  if (txtPhoneNumber.Text != "")
                  insertPhone(phone);
                  if (txtAddress.Text != "")
                  insertAdress(address);
                  if (txtEmail.Text != "")
                  insertEmail(email);

                  if (txtReferralDoctor.Text != "")
                  {
                      refDoctor.patientID = patient.patientID;
                      refDoctor.doctorID = getDoctorIdfromDoctorTbl1();
                      insertReferralDoctor(refDoctor);
                  }

               /*   if (txtDoctorBillingCode.Text != "" && txtReferralDoctor.Text != "")
                  {

                      if (getDoctorIdfromDoctorTbl1() != 0)
                      {
                          refDoctor.patientID = patient.patientID;
                          refDoctor.doctorID = getDoctorIdfromDoctorTbl1();
                          insertReferralDoctor(refDoctor);
                      }
                      else
                      {
                          insertDoctor(doctor);
                          refDoctor.patientID = patient.patientID;
                          refDoctor.doctorID = getDoctorIdfromDoctorTbl2();
                          insertReferralDoctor(refDoctor);
                      }
                  }*/


                

                    clearText();
                    MessageBox.Show("Patient was registed");
                    DialogResult result = MessageBox.Show("Go to patient demography?", "Patient registed", MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Question);

                   if (result == DialogResult.OK)
                   {
                         this.Hide();
                        ViewDemography viewDemo = new ViewDemography();
                        viewDemo.patientId = patient.patientID;
                       viewDemo.Show();        
                      
                                         
                      
                       
                   }
                   else if (result == DialogResult.Cancel)
                       this.Close();
              }

              else if (txtInsuranceNumber.TextLength != 10) //number incorrect of left blank
              {
                  MessageBox.Show("Please insert correct insurance number");
              }
              else if (ins_exist != 0)
              {
                  MessageBox.Show("Insurance Number already exists");
              }
              else if (DOB_valid == false)
              {
                  MessageBox.Show("D.O.B not valid");
              }

              else if (exp_valid == false)
              {
                  MessageBox.Show("Insurance Expiry Date not valid");
              }
              
 
       

            

            

           
        }
Ejemplo n.º 5
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            bool DOB_valid;
            bool exp_valid;
            bool pass = false;

            //check whether Insurance numer exits
            dictionary = new Dictionary <string, string>();
            dictionary.Add("@insuranceNumber", txtInsuranceNumber.Text);
            dc          = new DatabaseConnector();
            dtInsurance = dc.getData("CheckInsuranceExists", dictionary);
            int ins_exist = int.Parse(dtInsurance.Rows[0][0].ToString());

            //create new patient
            Patient patient = new Patient();

            patient.firstName = txtFirstName.Text;
            patient.lastName  = txtLastName.Text;
            patient.dob       = txtDOB.Text;
            patient.gender    = cmbxGender.GetItemText(cmbxGender.SelectedItem);

            //create new insurance
            Insurance insurance = new Insurance();

            insurance.timestamp   = System.DateTime.Today.ToShortDateString();
            insurance.insNumber   = txtInsuranceNumber.Text;
            insurance.versionCode = txtVersionCode.Text;
            insurance.expDate     = txtInsuranceExpDate.Text;

            //create new allergy
            Allergy allergy = new Allergy();

            allergy.name     = txtAllergyName.Text;
            allergy.category = txtAllergyCatergory.Text;

            //create new allergy-patient
            PatientAllergy ptAllgergy = new PatientAllergy();

            //
            Doctor doctor = new Doctor();

            doctor.billingCode = txtDoctorBillingCode.Text;
            doctor.name        = txtReferralDoctor.Text;

            //
            ReferralDoctor refDoctor = new ReferralDoctor();


            //ins number : number only
            //ins vc : character only
            //no blank: name, dob

            Phone phone = new Phone();

            phone.type        = cmbxPhoneType.GetItemText(cmbxPhoneType.SelectedItem);
            phone.phoneNumber = txtPhoneNumber.Text;

            Email email = new Email();

            email.type  = cmbxEmailType.GetItemText(cmbxEmailType.SelectedItem);
            email.email = txtEmail.Text;

            Address address = new Address();

            address.type       = cmbxAddressType.GetItemText(cmbxAddressType.SelectedItem);
            address.address    = txtAddress.Text;
            address.city       = txtCity.Text;
            address.province   = txtProvince.Text;
            address.postalCode = txtPostalCode.Text;

            DOB_valid = DOB_validation();
            exp_valid = exp_validation();

            if (DOB_valid == true && exp_valid == true && ins_exist == 0 && txtInsuranceNumber.TextLength == 10)
            {
                pass = true;
            }

            if (pass == true)
            {
                insertPatient(patient);

                patient.patientID   = getPtIdfromPatienTbl();
                insurance.patientID = patient.patientID;
                phone.patientID     = patient.patientID;
                email.patientID     = patient.patientID;
                address.patientID   = patient.patientID;


                insertInsurance(insurance);

                if (txtAllergyCatergory.Text != "" && txtAllergyName.Text != "")
                {
                    if (getAllergyIdfromAllergyTbl1() != 0)
                    {
                        ptAllgergy.patientId = patient.patientID;
                        ptAllgergy.allergyId = getAllergyIdfromAllergyTbl1();
                        insertPatientAllergy(ptAllgergy);
                    }
                    else
                    {
                        insertAllergy(allergy);
                        ptAllgergy.patientId = patient.patientID;
                        ptAllgergy.allergyId = getAllergyIdfromAllergyTbl2();
                        insertPatientAllergy(ptAllgergy);
                    }
                }

                if (txtPhoneNumber.Text != "")
                {
                    insertPhone(phone);
                }
                if (txtAddress.Text != "")
                {
                    insertAdress(address);
                }
                if (txtEmail.Text != "")
                {
                    insertEmail(email);
                }

                if (txtReferralDoctor.Text != "")
                {
                    refDoctor.patientID = patient.patientID;
                    refDoctor.doctorID  = getDoctorIdfromDoctorTbl1();
                    insertReferralDoctor(refDoctor);
                }

                /*   if (txtDoctorBillingCode.Text != "" && txtReferralDoctor.Text != "")
                 * {
                 *
                 *     if (getDoctorIdfromDoctorTbl1() != 0)
                 *     {
                 *         refDoctor.patientID = patient.patientID;
                 *         refDoctor.doctorID = getDoctorIdfromDoctorTbl1();
                 *         insertReferralDoctor(refDoctor);
                 *     }
                 *     else
                 *     {
                 *         insertDoctor(doctor);
                 *         refDoctor.patientID = patient.patientID;
                 *         refDoctor.doctorID = getDoctorIdfromDoctorTbl2();
                 *         insertReferralDoctor(refDoctor);
                 *     }
                 * }*/



                clearText();
                MessageBox.Show("Patient was registed");
                DialogResult result = MessageBox.Show("Go to patient demography?", "Patient registed", MessageBoxButtons.OKCancel,
                                                      MessageBoxIcon.Question);

                if (result == DialogResult.OK)
                {
                    this.Hide();
                    ViewDemography viewDemo = new ViewDemography();
                    viewDemo.patientId = patient.patientID;
                    viewDemo.Show();
                }
                else if (result == DialogResult.Cancel)
                {
                    this.Close();
                }
            }

            else if (txtInsuranceNumber.TextLength != 10)   //number incorrect of left blank
            {
                MessageBox.Show("Please insert correct insurance number");
            }
            else if (ins_exist != 0)
            {
                MessageBox.Show("Insurance Number already exists");
            }
            else if (DOB_valid == false)
            {
                MessageBox.Show("D.O.B not valid");
            }

            else if (exp_valid == false)
            {
                MessageBox.Show("Insurance Expiry Date not valid");
            }
        }