public void InsertAppointmentRecord(Hashtable appointmentArgs, int patientId) { SqlTransaction trans = null; try { trans = DataAccessHelper.BeginTransaction(); InsertAppointmentRecord(appointmentArgs, patientId, trans); trans.Commit(); } catch (Exception e) { if (trans != null) { trans.Rollback(); } throw(e); } finally { if (trans != null) { SqlConnection conn = trans.Connection; trans.Dispose(); if (conn != null) { conn.Close(); } } } }
protected void MovePatientToCurrentDataset(object source, CommandEventArgs args) { PatientController pt = new PatientController(); SessionHandler s = new SessionHandler(Session); int patientId = -1; int datasetId = s.GetDatasetId(); SqlTransaction trans = null; DataTable dt = pt.GetPatientByMRN(this.PtMRN.Value); if (dt.Rows.Count == 1) { patientId = int.Parse(dt.Rows[0][Patient.PatientId].ToString()); // associate the current users dataset with this patient // if current users dataset has multiple dimensions if (DatasetDimensionsRptr.Items.Count > 0) { SaveDatasetDimensions(patientId); } // else, current users dataset has a single dimension else { trans = DataAccessHelper.BeginTransaction(); pt.InsertDatasetDimensions(patientId, datasetId, trans); } pt.PutPatientInSession(Page, patientId); } this.SetPageStateAfterInsert(); }
/* * public DataTable GetOrDimensions(int datasetId) * { * DataSetController dsCt = new DataSetController(); * XmlNode dataSet = dsCt.FindDatasetNode(datasetId); * * DataTable dt = this.GetDimensionTable(); * this.ProcessOrChildren(dataSet, dt, "or"); * return dt; * } */ public DataSet InsertNewPatientRecord(Patient patient, int datasetId) { SqlTransaction trans = null; DataSet ds = new DataSet(); try { trans = DataAccessHelper.BeginTransaction(); // v4 SAVING OF PATIENT IS NO LONGER PART OF THIS TRANSACTION // (but if insert of patient fails, the insert of the dimensions will fail since there will be no primary key) if (IsNewPatient(patient[Patient.PtMRN].ToString(), patient[Patient.PtLastName].ToString(), datasetId)) { patient.Save(); int patientId = (int)patient[Patient.PatientId]; DataTable dt = this.InsertDatasetDimensions(patientId, datasetId, trans); if (dt != null) { ds.Tables.Add(dt); } trans.Commit(); } } catch (Exception ex) { if (trans != null) { trans.Rollback(); } throw (ex); } finally { if (trans != null) { SqlConnection conn = trans.Connection; trans.Dispose(); if (conn != null) { conn.Close(); } } } return(ds); }
/// <summary> /// Allows us to encapsulate saving patient and appointment data within the same transaction /// </summary> /// <param name="args"></param> /// <param name="datasetId"></param> /// <returns></returns> public DataSet InsertPatientAndAppointmentRecord(DataSet args, int datasetId, Hashtable AppointmentArgs) { // much of this was stolen from PatientController.InsertRecord(..., ...) SqlTransaction trans = null; DataRow dr = args.Tables[0].Rows[0]; try { // removed temporarily until transactions tested -2/21 spy trans = DataAccessHelper.BeginTransaction(); int patientId = (int)this._InsertRecord(dr, trans); DataTable dt = this.InsertDatasetDimensions(patientId, datasetId, trans); if (dt != null) { args.Tables.Add(dt); } // now insert the appointment this.InsertAppointmentRecord(AppointmentArgs, patientId, trans); trans.Commit(); dr[Patient.PatientId] = patientId; } catch (Exception ex) { if (trans != null) { trans.Rollback(); } throw(ex); } finally { if (trans != null) { SqlConnection conn = trans.Connection; trans.Dispose(); if (conn != null) { conn.Close(); } } } return(args); }
public void InsertOrDatasetDimensions(DataTable dt, int patientId) { SqlTransaction trans = null; try { //must add trans logic here too -2/21 spy trans = DataAccessHelper.BeginTransaction(); foreach (DataRow dr in dt.Rows) { InsertDimension(dr, patientId, trans); } trans.Commit(); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } //PatientDa ptda = new PatientDa(); // v4 _pda.DeleteRecord(patientId); throw (ex); } finally { if (trans != null) { SqlConnection conn = trans.Connection; trans.Dispose(); if (conn != null) { conn.Close(); } } } }