public static List<Patient> getPatientList() { if (patients == null) { patients = new List<Patient>(); // TODO: replace with SQL fetching Patient a = new Patient(); Patient b = new Patient(); Patient c = new Patient(); patients.Add(a); patients.Add(b); patients.Add(c); } return patients; }
public override Patient getPatient() { Patient myPatient = new Patient(); return myPatient; }
public static void updatePatient(Patient patient) { //TODO: SQL update this patient info }
public static Patient buildPatient(string patientID) { Patient x = new Patient(); string getDirInfo = "SELECT * from Patient where patientID = " + patientID; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd = new SqlCommand(getDirInfo, cnn); SqlDataReader datardr; datardr = cmd.ExecuteReader(); // Build directory section while (datardr.Read()) { if (datardr.GetValue(0) != System.DBNull.Value) x.directory.patientID = (String)datardr.GetValue(0); if (datardr.GetValue(1) != System.DBNull.Value) x.directory.fName = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.lName = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.mName = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.DOB = (DateTime)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) { string g = (String)datardr.GetValue(5); if (g == "m") x.directory.gender = true; else x.directory.gender = false; } if (datardr.GetValue(6) != System.DBNull.Value) x.directory.strAddress = (String)datardr.GetValue(6); if (datardr.GetValue(7) != System.DBNull.Value) x.directory.zip = (String)datardr.GetValue(7); if (datardr.GetValue(8) != System.DBNull.Value) x.directory.state = (String)datardr.GetValue(8); if (datardr.GetValue(10) != System.DBNull.Value) x.directory.phoneNum1 = datardr.GetValue(10).ToString(); if (datardr.GetValue(9) != System.DBNull.Value) x.directory.city = (String)datardr.GetValue(9); if (datardr.GetValue(11) != System.DBNull.Value) x.directory.phoneNum2 = datardr.GetValue(11).ToString(); if (datardr.GetValue(12) != System.DBNull.Value) x.directory.emerContact1.name = (String)datardr.GetValue(12); if (datardr.GetValue(13) != System.DBNull.Value) x.directory.emerContact1.phoneNum = datardr.GetValue(13).ToString(); if (datardr.GetValue(14) != System.DBNull.Value) x.directory.emerContact2.name = (String)datardr.GetValue(14); if (datardr.GetValue(15) != System.DBNull.Value) x.directory.emerContact2.phoneNum = datardr.GetValue(15).ToString(); if (datardr.GetValue(16) != System.DBNull.Value) { Visitor v = new Visitor(); v.name = (String)datardr.GetValue(16); x.directory.visitors.Add(v); } if (!(datardr.GetValue(17).Equals(System.DBNull.Value))) x.directory.location.bedNum = (String)datardr.GetValue(17); } /* Visitor v= new Visitor(); DateTime min = (DateTime)System.Data.SqlTypes.SqlDateTime.MinValue; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) { cnn.Close(); } cnn.Open(); SqlCommand cmd= new SqlCommand("createPatient", cnn); SqlDataReader datardr; //Add all the parameters required by the procedure in SQL cmd.CommandType = System.Data.CommandType.StoredProcedure; //The input parameter patientID cmd.Parameters.Add(new SqlParameter("@patientID", patientID)); //all the output parameters cmd.Parameters.Add(new SqlParameter("@fname", x.directory.fName)); cmd.Parameters.Add(new SqlParameter( "@lname", x.directory.lName)); cmd.Parameters.Add(new SqlParameter("@mname", x.directory.mName)); cmd.Parameters.Add(new SqlParameter("@DOB", min)); x.directory.DOB = min; cmd.Parameters.Add(new SqlParameter("@gender", x.directory.gender)); cmd.Parameters.Add(new SqlParameter("@pStreet", x.directory.strAddress)); cmd.Parameters.Add(new SqlParameter("@pCity", x.directory.city)); cmd.Parameters.Add(new SqlParameter( "@pState", x.directory.state)); cmd.Parameters.Add(new SqlParameter( "@pZip", x.directory.zip)); cmd.Parameters.Add(new SqlParameter( "@phone1", x.directory.phoneNum1)); cmd.Parameters.Add(new SqlParameter( "@phone2", x.directory.phoneNum2)); cmd.Parameters.Add(new SqlParameter( "@emName1", x.directory.emerContact1.name)); cmd.Parameters.Add(new SqlParameter( "@emNum1", x.directory.emerContact1.phoneNum)); cmd.Parameters.Add(new SqlParameter("@emName2", x.directory.emerContact2.name)); cmd.Parameters.Add(new SqlParameter( "@emNum2", x.directory.emerContact2.phoneNum)); cmd.Parameters.Add(new SqlParameter("@visitor", v.name)); cmd.Parameters.Add(new SqlParameter( "@bedNum", x.directory.location.bedNum)); datardr = cmd.ExecuteReader(); datardr.Read(); */ cnn.Close(); datardr.Close(); string getLocInfo = "SELECT * from Location where bedNo = " + x.directory.location.bedNum; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) { cnn.Close(); } cnn.Open(); cmd = new SqlCommand(getLocInfo, cnn); cmd.CommandType = System.Data.CommandType.Text; datardr = cmd.ExecuteReader(); datardr.Read(); if (datardr.GetValue(1) != System.DBNull.Value) x.directory.location.unit = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.location.floor = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.location.roomNum = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.location.occupancy = (int)datardr.GetValue(4); cnn.Close(); datardr.Close(); // If current user is a volunteer, this is all the info we need if (PimsMain.Program.currentUser is Volunteer) { return x; } if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); String getBillingInfo = "SELECT * from Charges where patientID = " + patientID; cmd = new SqlCommand(getBillingInfo, cnn); datardr = cmd.ExecuteReader(); // build billing info here while (datardr.Read()) { BillingLineItem item = new BillingLineItem(); if (datardr.GetValue(1) != System.DBNull.Value) item.item = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) item.cost = (int)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) item.paid = (int)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) item.insPaid = (int)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) item.dueDate = (DateTime)datardr.GetValue(5); x.billing.items.Add(item); } datardr.Close(); String getInsInfo = "SELECT * from Insurance where patientID = " + patientID; cmd = new SqlCommand(getInsInfo, cnn); datardr = cmd.ExecuteReader(); datardr.Read(); if (datardr.GetValue(1) != System.DBNull.Value) x.billing.insurance.provider = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.billing.insurance.bin = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.billing.insurance.id = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.billing.insurance.pcn = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) x.billing.insurance.groupNum = (String)datardr.GetValue(5); datardr.Close(); // if user is office staff, this is all the info we need if (PimsMain.Program.currentUser is OfficeStaff) { return x; } if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); String getTreatmentInfo = "SELECT * from Treatment where patientID = " + patientID; cmd = new SqlCommand(getTreatmentInfo, cnn); datardr = cmd.ExecuteReader(); datardr.Read(); if (datardr.GetValue(1) != System.DBNull.Value) x.treatment.dateAdmitted = (DateTime)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.treatment.reasonAdmitted = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.treatment.dateDischarged = (DateTime)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.treatment.primaryDoc = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) x.treatment.docNotes = (String)datardr.GetValue(5); if (datardr.GetValue(6) != System.DBNull.Value) x.treatment.medStaffNotes.allergies = (String)datardr.GetValue(6); if (datardr.GetValue(9) != System.DBNull.Value) x.treatment.medStaffNotes.nurseNotes = (String)datardr.GetValue(9); datardr.Close(); String getStatList = "SELECT * from patientStats where patientID = " + patientID; cmd = new SqlCommand(getStatList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { MedStaffNotes.patientStats stats = new MedStaffNotes.patientStats(); if (datardr.GetValue(1) != System.DBNull.Value) stats.patientHeight = (int)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) stats.patientWeight = (int)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) stats.bloodPressureSys = (int)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) stats.bloodPressureDia = (int)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) stats.heartrate = (int)datardr.GetValue(5); /*if (datardr.GetValue(7) != System.DBNull.Value) { DateTime date1; DateTime.TryParse((String)datardr.GetValue(7),out date1); stats.time = date1; }*/ x.treatment.medStaffNotes.statList.Add(stats); } datardr.Close(); String getDrugList = "SELECT * from Prescriptions where patientID = " + patientID; cmd = new SqlCommand(getDrugList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { PrescDrug drug = new PrescDrug(); if (datardr.GetValue(1) != System.DBNull.Value) drug.name = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) drug.ndc = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) drug.SIG = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) drug.prescribingPhysician = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) drug.dateFilled = (DateTime)datardr.GetValue(5); if (datardr.GetValue(6) != System.DBNull.Value) drug.cost = (int)datardr.GetValue(6); x.treatment.prescriptions.prescriptions.Add(drug); } datardr.Close(); String getProcList = "SELECT * from ScheduledProcedures where patientID = " + patientID; cmd = new SqlCommand(getProcList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { MedProcedure proc = new MedProcedure(); if (datardr.GetValue(1) != System.DBNull.Value) proc.what = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) proc.when = (DateTime)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) proc.who = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) proc.where = (String)datardr.GetValue(4); x.treatment.procedures.Add(proc); } datardr.Close(); return x; }
public static List<Patient> getPatientList() { string getPatList = "SELECT * from Patient"; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd = new SqlCommand(getPatList, cnn); SqlDataReader datardr; datardr = cmd.ExecuteReader(); patients = new List<Patient>(); while (datardr.Read()) { Patient x = new Patient(); if (datardr.GetValue(0) != System.DBNull.Value) x.directory.patientID = (String)datardr.GetValue(0); if (datardr.GetValue(1) != System.DBNull.Value) x.directory.fName = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.lName = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.mName = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.DOB = (DateTime)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) { string g = (String)datardr.GetValue(5); if (g == "m") x.directory.gender = true; else x.directory.gender = false; } if (datardr.GetValue(6) != System.DBNull.Value) x.directory.strAddress = (String)datardr.GetValue(6); if (datardr.GetValue(7) != System.DBNull.Value) x.directory.zip = (String)datardr.GetValue(7); if (datardr.GetValue(8) != System.DBNull.Value) x.directory.state = (String)datardr.GetValue(8); if (datardr.GetValue(10) != System.DBNull.Value) x.directory.phoneNum1 = datardr.GetValue(10).ToString(); if (datardr.GetValue(9) != System.DBNull.Value) x.directory.city = (String)datardr.GetValue(9); if (datardr.GetValue(11) != System.DBNull.Value) x.directory.phoneNum2 = datardr.GetValue(11).ToString(); if (datardr.GetValue(12) != System.DBNull.Value) x.directory.emerContact1.name = (String)datardr.GetValue(12); if (datardr.GetValue(13) != System.DBNull.Value) x.directory.emerContact1.phoneNum = datardr.GetValue(13).ToString(); if (datardr.GetValue(14) != System.DBNull.Value) x.directory.emerContact2.name = (String)datardr.GetValue(14); if (datardr.GetValue(15) != System.DBNull.Value) x.directory.emerContact2.phoneNum = datardr.GetValue(15).ToString(); if (datardr.GetValue(16) != System.DBNull.Value) { Visitor v = new Visitor(); v.name = (String)datardr.GetValue(16); x.directory.visitors.Add(v); } if (!(datardr.GetValue(17).Equals(System.DBNull.Value))) x.directory.location.bedNum = (String)datardr.GetValue(17); patients.Add(x); } return patients; }
public static void updatePatient(Patient patient) { Patient x = PimsMain.Program.currentPatient; PatientDirInfo dir = x.directory; // Volunteers can't update info, so exit if current user is a volunteer if(PimsMain.Program.currentUser is Volunteer) { return; } // only office staff can update billing and directory info if (PimsMain.Program.currentUser is OfficeStaff) { // Start with directory updates updatePatientDirInfo(); updateBillingInfo(); } // nurse/med staff updates here if (PimsMain.Program.currentUser is MedStaff) { } // Doctor updates hereTreatment updates here if (PimsMain.Program.currentUser is Doctor) { } //TODO: SQL update this patient info }
public override Patient getPatient() { Patient myPatient = new Patient(); // do SQL stuff return myPatient; }
// This function builds the patient list from the db to allow the search to happen public static List<Patient> getPatientList() { string getPatList = "SELECT * from Patient"; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd = new SqlCommand(getPatList, cnn); SqlDataReader datardr; patients = new List<Patient>(); datardr = cmd.ExecuteReader(); while (datardr.Read()) { Patient x = new Patient(); if (datardr.GetValue(0) != System.DBNull.Value) x.directory.patientID = datardr.GetValue(0).ToString(); if (datardr.GetValue(1) != System.DBNull.Value) x.directory.fName = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.lName = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.mName = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.DOB = (DateTime)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) { string g = (String)datardr.GetValue(5); if (g.Equals("m") || g.Equals("M")) x.directory.gender = true; else x.directory.gender = false; } if (datardr.GetValue(6) != System.DBNull.Value) x.directory.strAddress = (String)datardr.GetValue(6); if (datardr.GetValue(7) != System.DBNull.Value) x.directory.zip = (String)datardr.GetValue(7); if (datardr.GetValue(8) != System.DBNull.Value) x.directory.state = (String)datardr.GetValue(8); if (datardr.GetValue(10) != System.DBNull.Value) x.directory.phoneNum1 = datardr.GetValue(10).ToString(); if (datardr.GetValue(9) != System.DBNull.Value) x.directory.city = (String)datardr.GetValue(9); if (datardr.GetValue(11) != System.DBNull.Value) x.directory.phoneNum2 = datardr.GetValue(11).ToString(); if (datardr.GetValue(12) != System.DBNull.Value) x.directory.emerContact1.name = (String)datardr.GetValue(12); if (datardr.GetValue(13) != System.DBNull.Value) x.directory.emerContact1.phoneNum = datardr.GetValue(13).ToString(); if (datardr.GetValue(14) != System.DBNull.Value) x.directory.emerContact2.name = (String)datardr.GetValue(14); if (datardr.GetValue(15) != System.DBNull.Value) x.directory.emerContact2.phoneNum = datardr.GetValue(15).ToString(); if (datardr.GetValue(18) != System.DBNull.Value) x.directory.workphone = datardr.GetValue(18).ToString(); if (datardr.GetValue(16) != System.DBNull.Value) { string unparsedNames = (String)datardr.GetValue(16); string[] visitors = unparsedNames.Split('$'); foreach (string vis in visitors) { Visitor v = new Visitor(); v.name = vis; if (!v.name.Equals("")) x.directory.visitors.Add(v); } } if (!(datardr.GetValue(17).Equals(System.DBNull.Value))) x.directory.location.bedNum = (int)datardr.GetValue(17); patients.Add(x); } foreach (PIMSController.Patient x in patients) { if (x.directory.location.bedNum != null) { string getLocInfo = "SELECT * from Location where bedNo = " + x.directory.location.bedNum; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); cmd = new SqlCommand(getLocInfo, cnn); datardr = cmd.ExecuteReader(); while (datardr.Read()) { if (datardr.GetValue(1) != System.DBNull.Value) x.directory.location.unit = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.location.floor = (int)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.location.roomNum = (int)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.location.occupancy = (int)datardr.GetValue(4); } } } return patients; }
}//end discharge patient // This function queries the SQL server and builds the patient requested by the // PatientID according to the type of user currently logged in public static Patient buildPatient(string patientID) { //try //{ Patient x = new Patient(); string getDirInfo = "SELECT * from Patient where patientID = " + patientID; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd = new SqlCommand(getDirInfo, cnn); SqlDataReader datardr; datardr = cmd.ExecuteReader(); // Build directory section while (datardr.Read()) { if (datardr.GetValue(0) != System.DBNull.Value) x.directory.patientID = datardr.GetValue(0).ToString(); if (datardr.GetValue(1) != System.DBNull.Value) x.directory.fName = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.lName = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.mName = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.DOB = (DateTime)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) { string g = (String)datardr.GetValue(5); if (g.Equals("m") || g.Equals("M")) x.directory.gender = true; else x.directory.gender = false; } if (datardr.GetValue(6) != System.DBNull.Value) x.directory.strAddress = (String)datardr.GetValue(6); if (datardr.GetValue(7) != System.DBNull.Value) x.directory.zip = (String)datardr.GetValue(7); if (datardr.GetValue(8) != System.DBNull.Value) x.directory.state = (String)datardr.GetValue(8); if (datardr.GetValue(10) != System.DBNull.Value) x.directory.phoneNum1 = datardr.GetValue(10).ToString(); if (datardr.GetValue(9) != System.DBNull.Value) x.directory.city = (String)datardr.GetValue(9); if (datardr.GetValue(11) != System.DBNull.Value) x.directory.phoneNum2 = datardr.GetValue(11).ToString(); if (datardr.GetValue(12) != System.DBNull.Value) x.directory.emerContact1.name = (String)datardr.GetValue(12); if (datardr.GetValue(13) != System.DBNull.Value) x.directory.emerContact1.phoneNum = datardr.GetValue(13).ToString(); if (datardr.GetValue(14) != System.DBNull.Value) x.directory.emerContact2.name = (String)datardr.GetValue(14); if (datardr.GetValue(15) != System.DBNull.Value) x.directory.emerContact2.phoneNum = datardr.GetValue(15).ToString(); if (datardr.GetValue(15) != System.DBNull.Value) x.directory.workphone = datardr.GetValue(18).ToString(); if (datardr.GetValue(18) != System.DBNull.Value) { string unparsedNames = (String)datardr.GetValue(16); string[] visitors = unparsedNames.Split('$'); foreach (string vis in visitors) { Visitor v = new Visitor(); v.name = vis; if (!v.name.Equals("")) x.directory.visitors.Add(v); } } if (!(datardr.GetValue(17) == (System.DBNull.Value))) x.directory.location.bedNum = (int)datardr.GetValue(17); } cnn.Close(); if (x.directory.location.bedNum != null) { string getLocInfo = "SELECT * from Location where bedNo = " + x.directory.location.bedNum; if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); cmd = new SqlCommand(getLocInfo, cnn); datardr = cmd.ExecuteReader(); while (datardr.Read()) { if (datardr.GetValue(1) != System.DBNull.Value) x.directory.location.unit = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.directory.location.floor = (int)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.directory.location.roomNum = (int)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.directory.location.occupancy = (int)datardr.GetValue(4); } datardr.Close(); } // If current user is a volunteer, this is all the info we need if (PIMS.Program.currentUser is Volunteer) { return x; } if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); String getBillingInfo = "SELECT * from Charges where patientID = " + patientID; cmd = new SqlCommand(getBillingInfo, cnn); datardr = cmd.ExecuteReader(); // build billing info here while (datardr.Read()) { BillingLineItem item = new BillingLineItem(); if (datardr.GetValue(1) != System.DBNull.Value) item.item = (String)datardr.GetValue(2); if (datardr.GetValue(2) != System.DBNull.Value) item.cost = (int)datardr.GetValue(3); if (datardr.GetValue(3) != System.DBNull.Value) item.paid = (int)datardr.GetValue(4); if (datardr.GetValue(4) != System.DBNull.Value) item.insPaid = (int)datardr.GetValue(5); if (datardr.GetValue(5) != System.DBNull.Value) item.dueDate = (DateTime)datardr.GetValue(6); if (datardr.GetValue(6) != System.DBNull.Value) item.itemId = (int)datardr.GetValue(1); x.billing.items.Add(item); } datardr.Close(); String getInsInfo = "SELECT * from Insurance where patientID = " + patientID; cmd = new SqlCommand(getInsInfo, cnn); datardr = cmd.ExecuteReader(); if (datardr.Read()) { if (datardr.GetValue(1) != System.DBNull.Value) x.billing.insurance.provider = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.billing.insurance.bin = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.billing.insurance.id = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.billing.insurance.pcn = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) x.billing.insurance.groupNum = (String)datardr.GetValue(5); if (datardr.GetValue(6) != System.DBNull.Value) x.billing.insurance.insuranceType = (String)datardr.GetValue(6); } datardr.Close(); // if user is office staff, this is all the info we need if (PIMS.Program.currentUser is OfficeStaff) { return x; } // fill the treatment data since the user at this point is a doc or nurse if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); String getTreatmentInfo = "SELECT * from Treatment where patientID = " + patientID; cmd = new SqlCommand(getTreatmentInfo, cnn); datardr = cmd.ExecuteReader(); while (datardr.Read()) { if (datardr.GetValue(1) != System.DBNull.Value) x.treatment.dateAdmitted = (DateTime)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) x.treatment.reasonAdmitted = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) x.treatment.dateDischarged = (DateTime)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) x.treatment.primaryDoc = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) x.treatment.docNotes = (String)datardr.GetValue(5); if (datardr.GetValue(6) != System.DBNull.Value) x.treatment.medStaffNotes.allergies = (String)datardr.GetValue(6); if (datardr.GetValue(9) != System.DBNull.Value) x.treatment.medStaffNotes.nurseNotes = (String)datardr.GetValue(9); if (datardr.GetValue(10) != System.DBNull.Value) x.treatment.reasonDischarged = (String)datardr.GetValue(10); if (datardr.GetValue(11) != System.DBNull.Value) x.treatment.diagnosis = (String)datardr.GetValue(11); } datardr.Close(); String getStatList = "SELECT * from patientStats where patientID = " + patientID; cmd = new SqlCommand(getStatList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { MedStaffNotes.patientStats stats = new MedStaffNotes.patientStats(); if (datardr.GetValue(1) != System.DBNull.Value) stats.patientHeight = (int)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) stats.patientWeight = (int)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) stats.bloodPressureSys = (int)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) stats.bloodPressureDia = (int)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) stats.heartrate = (int)datardr.GetValue(5); if (datardr.GetValue(7) != System.DBNull.Value) stats.idNum = (int)datardr.GetValue(7); if (datardr.GetValue(6) != System.DBNull.Value) { stats.time = (DateTime)datardr.GetValue(6); } if (datardr.GetValue(8) != System.DBNull.Value) stats.nurse = (string)datardr.GetValue(8); else stats.nurse = ""; x.treatment.medStaffNotes.statList.Add(stats); } datardr.Close(); String getDrugList = "SELECT * from Prescriptions where patientID = " + patientID; cmd = new SqlCommand(getDrugList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { PrescDrug drug = new PrescDrug(); if (datardr.GetValue(0) != System.DBNull.Value) drug.id = (int)datardr.GetValue(0); if (datardr.GetValue(1) != System.DBNull.Value) drug.drug.name = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) drug.ndc = (String)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) drug.SIG = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) drug.prescribingPhysician = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) drug.dateFilled = (DateTime)datardr.GetValue(5); if (datardr.GetValue(6) != System.DBNull.Value) drug.drug.cost = (int)datardr.GetValue(6); x.treatment.prescriptions.prescriptions.Add(drug); } datardr.Close(); String getProcList = "SELECT * from ScheduledProcedures where patientID = " + patientID; cmd = new SqlCommand(getProcList, cnn); datardr = cmd.ExecuteReader(); // build stats info here while (datardr.Read()) { MedProcedure proc = new MedProcedure(); if (datardr.GetValue(1) != System.DBNull.Value) proc.what = (String)datardr.GetValue(1); if (datardr.GetValue(2) != System.DBNull.Value) proc.when = (DateTime)datardr.GetValue(2); if (datardr.GetValue(3) != System.DBNull.Value) proc.who = (String)datardr.GetValue(3); if (datardr.GetValue(4) != System.DBNull.Value) proc.where = (String)datardr.GetValue(4); if (datardr.GetValue(5) != System.DBNull.Value) proc.id = (int)datardr.GetValue(5); x.treatment.procedures.Add(proc); } return x; //} //catch (Exception ex) //{ // MessageBox.Show("Error retrieving patient information.\nPlease try again"); // return null; //} }
}//end update location /* * Takes a patient object and uses that patient's location information * sents the current patients room information into the database * */ public static void dischargePatientLocation(Patient A) { Console.WriteLine("UPDATING LOCATION"); //create patientid if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd; cmd = new SqlCommand("UpdateLocation", cnn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@bed", A.directory.location.bedNum); cmd.Parameters.AddWithValue("@patientID", A.directory.patientID); cmd.ExecuteReader(); cmd.Parameters.Clear(); cnn.Close(); }//end discharge patient
//Takes Patient object and creates a new patient using the patient object //Returns database generated patientID as a string public static String insertNewPatient(Patient P) { Console.WriteLine("CREATING PATIENT"); //create patientid if (cnn != null && cnn.State == System.Data.ConnectionState.Open) cnn.Close(); cnn.Open(); SqlCommand cmd; cmd = new SqlCommand("CreatePatient", cnn); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@fname", P.directory.fName); cmd.Parameters.AddWithValue("@mname", P.directory.lName); cmd.Parameters.AddWithValue("@lname", P.directory.mName); cmd.Parameters.AddWithValue("@DOB", Convert.ToDateTime(P.directory.DOB.Date.ToShortDateString())); cmd.Parameters.AddWithValue("@gender", P.directory.gender ? "M" : "F"); cmd.Parameters.AddWithValue("@patientAddress", P.directory.strAddress); cmd.Parameters.AddWithValue("@patientZip", P.directory.zip); cmd.Parameters.AddWithValue("@patientState", P.directory.state); cmd.Parameters.AddWithValue("@patientCity", P.directory.city); cmd.Parameters.AddWithValue("@phone1", P.directory.phoneNum1); cmd.Parameters.AddWithValue("@phone2", P.directory.phoneNum2); cmd.Parameters.AddWithValue("@work", P.directory.workphone); cmd.Parameters.AddWithValue("@emergencyName", P.directory.emerContact1.name); cmd.Parameters.AddWithValue("@emergencyNum", P.directory.emerContact1.phoneNum); cmd.Parameters.AddWithValue("@emergencyName2", P.directory.emerContact2.name); cmd.Parameters.AddWithValue("@emergencyNum2", P.directory.emerContact2.phoneNum); cmd.Parameters.AddWithValue("@visitorList", P.directory.fName); cmd.Parameters.AddWithValue("@patientID", P.directory.patientID); cmd.ExecuteReader(); cmd.Parameters.Clear(); cnn.Close(); return P.directory.patientID.ToString(); // return id.ToString(); }//end create patient