-
Notifications
You must be signed in to change notification settings - Fork 0
/
Translator.cs
executable file
·88 lines (72 loc) · 3.99 KB
/
Translator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace Sirona.Utilities
{
public class Translator
{
public static string TranslateCDAToMobileHTML(string sCDAData)
{
try
{
System.Xml.Xsl.XslCompiledTransform xslttransform = new System.Xml.Xsl.XslCompiledTransform();
System.IO.StreamReader oxsltstream = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileCDA.xslt"));
System.Xml.XmlTextReader xtextreader = new System.Xml.XmlTextReader(oxsltstream);
xslttransform.Load(xtextreader);
System.Xml.XPath.XPathDocument xDoc = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(sCDAData));
System.Xml.XmlWriterSettings xWriterSettings = new System.Xml.XmlWriterSettings();
xWriterSettings.ConformanceLevel = System.Xml.ConformanceLevel.Auto;
StringBuilder sb = new StringBuilder();
xslttransform.Transform(xDoc, System.Xml.XmlWriter.Create(sb, xWriterSettings));
return sb.ToString();
}
catch (Exception ex)
{
throw new Exception("Exception in Sirona.Utilities.Translator.TranslateCDAToMobileHTML:\n" + ex.Message);
}
}
//'/primepractice/clinical/stylesheets/labresult.xsl 'Regular Result
//'/primepractice/clinical/stylesheets/labdocument.xsl 'Microbiology
//'/primepractice/clinical/stylesheets/document.xsl 'Transcription
public static string TranslateLabResultXMLToMobileHTML(string sXML, string sStyleSheetType)
{
try
{
System.Xml.Xsl.XslCompiledTransform xsltTransform = new System.Xml.Xsl.XslCompiledTransform();
System.IO.StreamReader xsltStream;
switch (sStyleSheetType.ToLower())
{
case "document":
xsltStream = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileDocument.xslt"));
break;
case "labdocument":
xsltStream = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileLabDocument.xslt"));
break;
case "labresult":
xsltStream = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MobileLabResult.xslt"));
break;
default:
xsltStream = null;
break;
}
System.Xml.XmlTextReader xtextreader = new System.Xml.XmlTextReader(xsltStream);
xsltTransform.Load(xtextreader);
System.Xml.XmlDocument xLabResultDom = new System.Xml.XmlDocument();
xLabResultDom.LoadXml(sXML);
System.Xml.XmlWriterSettings xWriterSettings = new System.Xml.XmlWriterSettings();
xWriterSettings.ConformanceLevel = System.Xml.ConformanceLevel.Auto;
StringBuilder sb = new StringBuilder();
//Dim xDoc As New System.Xml.XPath.XPathDocument(New System.IO.StringReader(sXML))
//'xsltTransform.Transform(xDoc, System.Xml.XmlWriter.Create(sb, xWriterSettings))
xsltTransform.Transform(new System.Xml.XmlNodeReader(xLabResultDom), System.Xml.XmlWriter.Create(sb, xWriterSettings));
return sb.ToString();
}
catch (Exception ex)
{
throw new Exception("Exception in Sirona.Utilities.Translator.TranslateLabResultXMLToMobileHTML: \n" + ex.Message);
}
}
}
}