static void Main(string[] args) { // We can speed up initial serialization by loading a cached formatter assembly MARC.Everest.Formatters.XML.ITS1.Formatter fmtr = new MARC.Everest.Formatters.XML.ITS1.Formatter(); // If you want to experiment and see the difference in serialization times, try commenting these lines out // and seeing the effect. fmtr.GraphAides.Add(new DatatypeFormatter()); fmtr.ValidateConformance = false; // Create the CDA ClinicalDocument cda = new ClinicalDocument( new II("2.16.840.1.113883.19.4", "c266"), // Create an identifier for the document new CE <String>("33049-3", "2.16.840.1.113883.6.1", "LOINC", null, "Consultation note", null), // Specify the type of document DateTime.Now, // Effective time of the document (now) x_BasicConfidentialityKind.Normal, // Confidentiality code of N = Normal CreateRecordTarget(), // Create a record target, this is good for code reuse CreateAuthor(), // Create the author node CreateCustodian(), // Create custodian node CreateComponent() // Create component Node ) { Title = UserPrompt <ST>("Document Title:") }; Console.Clear(); Console.WriteLine("Here is your CDA:"); // Prepare the output XmlStateWriter xsw = new XmlStateWriter(XmlWriter.Create(Console.OpenStandardOutput(), new XmlWriterSettings() { Indent = true })); DateTime start = DateTime.Now; var result = fmtr.Graph(xsw, cda); xsw.Flush(); Console.WriteLine("Took {0} ms to render", DateTime.Now.Subtract(start).TotalMilliseconds); // We can serialize again to see the learning pattern of Everest for (int i = 2; i < 20; i++) { xsw = new XmlStateWriter(XmlWriter.Create(new MemoryStream(), new XmlWriterSettings() { Indent = true })); start = DateTime.Now; result = fmtr.Graph(xsw, cda); xsw.Flush(); Console.WriteLine("Render #{1} Took {0} ms to render", DateTime.Now.Subtract(start).TotalMilliseconds, i); } Console.ReadKey(); }
static void Main(string[] args) { try { // Ask the user what directory they want to listen to Console.Write("Enter directory to listen on (example: C:\\temp):"); var directory = Console.ReadLine(); // Create the directory if it doesn't exist if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } // Setup the listener FileListenConnector flc = new FileListenConnector(String.Format("Directory={0};Pattern=*.xml", directory)); // Create the formatter that will interpret CDAr2 (XML ITS 1.0 and Datatypes R1) MARC.Everest.Formatters.XML.ITS1.Formatter fmtr = new MARC.Everest.Formatters.XML.ITS1.Formatter(); fmtr.ValidateConformance = true; fmtr.GraphAides.Add(new DatatypeFormatter()); flc.Formatter = fmtr; // Subscribe to the message available event flc.MessageAvailable += new EventHandler <MARC.Everest.Connectors.UnsolicitedDataEventArgs>(flc_MessageAvailable); // Start the connector try { flc.Open(); flc.Start(); Console.WriteLine("Waiting for messages in {0}, press any key to stop listening...", directory); Console.ReadKey(); } finally { flc.Stop(); } } catch (Exception e) { Console.WriteLine("There was an error in the execution of the example {0}", e); } }
static void Main(string[] args) { try { // Ask the user what directory they want to listen to Console.Write("Enter directory to listen on (example: C:\\temp):"); var directory = Console.ReadLine(); // Create the directory if it doesn't exist if (!Directory.Exists(directory)) Directory.CreateDirectory(directory); // Setup the listener FileListenConnector flc = new FileListenConnector(String.Format("Directory={0};Pattern=*.xml", directory)); // Create the formatter that will interpret CDAr2 (XML ITS 1.0 and Datatypes R1) MARC.Everest.Formatters.XML.ITS1.Formatter fmtr = new MARC.Everest.Formatters.XML.ITS1.Formatter(); fmtr.ValidateConformance = true; fmtr.GraphAides.Add(new DatatypeFormatter()); flc.Formatter = fmtr; // Subscribe to the message available event flc.MessageAvailable += new EventHandler<MARC.Everest.Connectors.UnsolicitedDataEventArgs>(flc_MessageAvailable); // Start the connector try { flc.Open(); flc.Start(); Console.WriteLine("Waiting for messages in {0}, press any key to stop listening...", directory); Console.ReadKey(); } finally { flc.Stop(); } } catch (Exception e) { Console.WriteLine("There was an error in the execution of the example {0}", e); } }