private void xmlExport(string fileName, Patient patient, bool deIdentify) { patient.LoadFullObject(); FamilyHistory theFH = patient.owningFHx; if (!deIdentify) { //legacy code chunk; written before caring about de-identifying DataContractSerializer ds = new DataContractSerializer(typeof(FamilyHistory)); FileStream stm = new FileStream(fileName, FileMode.Create); ds.WriteObject(stm, theFH); stm.Flush(); stm.Position = 0; stm.Close(); return; } // De-Identify the XML data by using a transform, then save the file string fhAsString = TransformUtils.DataContractSerializeObject<FamilyHistory>(theFH); //transform it XmlDocument inDOM = new XmlDocument(); inDOM.LoadXml(fhAsString); string toolsPath = Configurator.AssemblyDirectory; //since project is built with xsl file as linked project member, xsl s/b in the executing folder, whereever that is XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, toolsPath, @"hraDeIdentifySerialized.xsl"); //following actually removes all indentation and extra whitespace; prefer to save the file with indentations, so leave this commented //hl7FHData.PreserveWhitespace = true; resultXmlDoc.Save(fileName); }
private void ExportWorker1_DoWork(object sender, DoWorkEventArgs e) { ExportWorkerArgs ewa = (ExportWorkerArgs)(e.Argument); SqlDataReader reader = BCDB2.Instance.ExecuteReader(ewa.sql); while (reader.Read()) { int apptid = reader.GetInt32(1); string unit = reader.GetString(0); RiskApps3.Model.PatientRecord.Patient thePatient = new RiskApps3.Model.PatientRecord.Patient(unit); thePatient.apptid = apptid; thePatient.LoadFullObject(); string fhAsString = TransformUtils.DataContractSerializeObject<RiskApps3.Model.PatientRecord.FHx.FamilyHistory>(thePatient.FHx); if (ewa.mode == 1) { System.IO.File.WriteAllText(Path.Combine(ewa.outputPath, unit + ".xml"), fhAsString); } else if (ewa.mode == 2) { //transform it XmlDocument inDOM = new XmlDocument(); inDOM.LoadXml(fhAsString); string toolsPath = RiskApps3.Utilities.Configurator.getNodeValue("Globals", "ToolsPath"); // @"C:\Program Files\riskappsv2\tools\"; XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, toolsPath, @"hra_to_ccd_remove_namespaces.xsl"); XmlDocument hl7FHData = TransformUtils.performTransformWithParam(resultXmlDoc, toolsPath, @"hra_serialized_to_hl7.xsl", "deIdentify", "0"); hl7FHData.Save(Path.Combine(ewa.outputPath, unit + ".xml")); } else { //transform it XmlDocument inDOM = new XmlDocument(); inDOM.LoadXml(fhAsString); string toolsPath = RiskApps3.Utilities.Configurator.getNodeValue("Globals", "ToolsPath"); // @"C:\Program Files\riskappsv2\tools\"; XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, toolsPath, @"hra_to_ccd_remove_namespaces.xsl"); XmlDocument hl7FHData = TransformUtils.performTransformWithParam(resultXmlDoc, toolsPath, @"hra_serialized_to_hl7.xsl", "deIdentify", "1"); hl7FHData.Save(Path.Combine(ewa.outputPath, unit + ".xml")); } } }
private void migrantWorker_DoWork(object sender, DoWorkEventArgs e) { work_papers wp = (work_papers)e.Argument; e.Result = -1; if (wp.mode == 1) { string orig_con_string = BCDB2.Instance.getConnectionString(); string new_con_string = GetConnectionStringLeft(); BCDB2.Instance.setConnectionString(new_con_string); SqlDataReader reader = BCDB2.Instance.ExecuteReader("select apptid,patientname,unitnum,apptdatetime,dob from tblappointments " + textBox41.Text); BCDB2.Instance.setConnectionString(orig_con_string); if (reader != null) { while (reader.Read()) { Appointment a = new Appointment(); a.apptID = reader.GetInt32(0); a.patientname = reader.GetString(1); a.unitnum = reader.GetString(2); a.apptdatetime = reader.GetDateTime(3); a.dob = reader.GetString(4); ListViewItem lvi = new ListViewItem(); lvi.Text = a.apptID.ToString(); lvi.SubItems.Add(a.patientname); lvi.SubItems.Add(a.unitnum); lvi.SubItems.Add(a.apptdatetime.ToShortDateString()); lvi.SubItems.Add(a.dob); lvi.Tag = a; migrantWorker.ReportProgress(1, lvi); } } } else if (wp.mode == 2) { string orig_con_string = BCDB2.Instance.getConnectionString(); string new_con_string = GetConnectionStringRight(); BCDB2.Instance.setConnectionString(new_con_string); SqlDataReader reader = BCDB2.Instance.ExecuteReader("select apptid,patientname,unitnum,apptdatetime,dob from tblappointments " + textBox42.Text); BCDB2.Instance.setConnectionString(orig_con_string); if (reader != null) { while (reader.Read()) { Appointment a = new Appointment(); a.apptID = reader.GetInt32(0); a.patientname = reader.GetString(1); a.unitnum = reader.GetString(2); a.apptdatetime = reader.GetDateTime(3); a.dob = reader.GetString(4); ListViewItem lvi = new ListViewItem(); lvi.Text = a.apptID.ToString(); //lvi.SubItems.Add(a.apptID); lvi.SubItems.Add(a.patientname); lvi.SubItems.Add(a.unitnum); lvi.SubItems.Add(a.apptdatetime.ToShortDateString()); lvi.SubItems.Add(a.dob); lvi.Tag = a; migrantWorker.ReportProgress(2, lvi); } } } else if (wp.mode == 3) { string orig_con_string = BCDB2.Instance.getConnectionString(); try { foreach (Appointment a in wp.appts) { BCDB2.Instance.setConnectionString(GetConnectionStringLeft()); RiskApps3.Model.PatientRecord.Patient thePatient = new RiskApps3.Model.PatientRecord.Patient(a.unitnum); thePatient.apptid = a.apptID; thePatient.LoadFullObject(); BCDB2.Instance.setConnectionString(GetConnectionStringRight()); DataContractSerializer ds = new DataContractSerializer(typeof(Patient)); MemoryStream stm = new MemoryStream(); ds.WriteObject(stm, thePatient); stm.Flush(); stm.Position = 0; RiskApps3.Utilities.ParameterCollection pc = new RiskApps3.Utilities.ParameterCollection(); pc.Add("unitnum", thePatient.unitnum); pc.Add("apptdate", thePatient.apptdatetime.ToString("MM/dd/yyyy")); pc.Add("appttime", thePatient.apptdatetime.ToShortTimeString()); pc.Add("patientname", thePatient.name); pc.Add("dob", thePatient.dob); object o = BCDB2.Instance.ExecuteSpWithRetValAndParams("sp_createMasteryAppointment", SqlDbType.Int, pc); Patient p2 = (Patient)ds.ReadObject(stm); p2.apptid = (int)o; p2.FHx.proband = p2; p2.PersistFullObject(new RiskApps3.Model.HraModelChangedEventArgs(null)); BCDB2.Instance.setConnectionString(orig_con_string); e.Result = 1; } } catch (Exception ee) { BCDB2.Instance.setConnectionString(orig_con_string); MessageBox.Show(ee.ToString()); } migrantWorker.ReportProgress(3); } }
private void button12_Click(object sender, EventArgs e) { int apptid = 0; int.TryParse(textBox24.Text, out apptid); if (apptid > 0) { SqlDataReader reader = BCDB2.Instance.ExecuteReader("select unitnum from tblappointments where apptid = " + apptid); if (reader.Read()) { string unit = reader.GetString(0); RiskApps3.Model.PatientRecord.Patient thePatient = new RiskApps3.Model.PatientRecord.Patient(unit); thePatient.apptid = apptid; thePatient.LoadFullObject(); //object o = BCDB2.Instance.ExecuteSpWithRetVal("sp_createMasteryAppointment",SqlDbType.Int); //DataContractSerializer ds = new DataContractSerializer(typeof(Patient)); //using (Stream s = File.Create("temp.xml")) //{ // ds.WriteObject(s, thePatient); // s.Position = 0; // Patient p2 = (Patient)ds.ReadObject(s); // p2.apptid = (int)o; // p2.FHx.proband = p2; // p2.BackgroundPersistWork(new RiskApps3.Model.HraModelChangedEventArgs(null)); // foreach (Person rel in p2.FHx) // { // rel.BackgroundPersistWork(new RiskApps3.Model.HraModelChangedEventArgs(null)); // } //} } } }