コード例 #1
0
        public VM.HraXmlFile ExportAsXml(string mrn, int apptId, bool Identified)
        {
            string rootPath = HttpContext.Current.Server.MapPath(Constants.RAFilePath);

            _hraSessionManager.SetActivePatient(mrn, apptId);
            Patient _patient = SessionManager.Instance.GetActivePatient();

            _patient.LoadFullObject();
            FamilyHistory theFH    = _patient.owningFHx;
            string        fileName = SessionManager.Instance.GetActivePatient().name + " " +
                                     SessionManager.Instance.GetActivePatient().unitnum +
                                     " Serialization " +
                                     DateTime.Now.ToString("yyyy-MM-dd-HHmm");

            if (!Directory.Exists(System.IO.Path.Combine(rootPath, "Download")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(rootPath, "Download"));
            }
            string filePath = System.IO.Path.Combine(rootPath, "Download", fileName);

            if (!Identified)
            {
                //legacy code chunk; written before caring about de-identifying
                DataContractSerializer ds  = new DataContractSerializer(typeof(FamilyHistory));
                FileStream             stm = new FileStream(filePath, FileMode.Create);
                ds.WriteObject(stm, theFH);
                stm.Flush();
                stm.Position = 0;
                stm.Close();
            }
            else
            {
                string fhAsString = TransformUtils.DataContractSerializeObject <FamilyHistory>(theFH);

                //transform it
                XmlDocument inDOM = new XmlDocument();
                inDOM.LoadXml(fhAsString);

                XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, rootPath, @"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(filePath);
            }
            VM.HraXmlFile xmlFile = new VM.HraXmlFile()
            {
                FileName  = fileName,
                FilePath  = filePath,
                Estension = ".xml"
            };
            return(xmlFile);
        }
コード例 #2
0
        /// <summary>
        /// Export patient details as xml.
        /// </summary>
        /// <param name="mrn">MRN for a patient</param>
        /// <param name="apptId">Appointment Id of the selected appointment</param>
        /// <param name="Identified">True for DeIdentified and false for Identitify</param>
        /// <returns>Returns xml file for download.</returns>
        public VM.HraXmlFile ExportAsHL7(string mrn, int apptId, bool Identified)
        {
            string rootPath = HttpContext.Current.Server.MapPath(Constants.RAFilePath);

            _hraSessionManager.SetActivePatient(mrn, apptId);
            Patient _patient = SessionManager.Instance.GetActivePatient();

            _patient.LoadFullObject();
            FamilyHistory theFH      = _patient.owningFHx;
            string        fhAsString = TransformUtils.DataContractSerializeObject <FamilyHistory>(theFH);
            XmlDocument   inDOM      = new XmlDocument();

            inDOM.LoadXml(fhAsString);


            XmlDocument resultXmlDoc = TransformUtils.performTransform(inDOM, rootPath, @"hra_to_ccd_remove_namespaces.xsl");
            XmlDocument hl7FHData    = TransformUtils.performTransformWithParam(resultXmlDoc, rootPath, @"hra_serialized_to_hl7.xsl", "deIdentify", Identified ? "1" : "0");


            string filename = SessionManager.Instance.GetActivePatient().name + " " +
                              SessionManager.Instance.GetActivePatient().unitnum +
                              " HL7 " +
                              DateTime.Now.ToString("yyyy-MM-dd-HHmm");

            if (!Directory.Exists(System.IO.Path.Combine(rootPath, "Download")))
            {
                Directory.CreateDirectory(System.IO.Path.Combine(rootPath, "Download"));
            }

            string filePath = System.IO.Path.Combine(rootPath, "Download", filename);

            hl7FHData.Save(filePath);

            VM.HraXmlFile xmlFile = new VM.HraXmlFile();
            xmlFile.FileName  = filename;
            xmlFile.FilePath  = filePath;
            xmlFile.Estension = ".xml";
            return(xmlFile);
        }