-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
159 lines (149 loc) · 3.85 KB
/
Program.cs
File metadata and controls
159 lines (149 loc) · 3.85 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Displaying stratuseeg.com patient information from .keegz or StaticInfo.xml
* @jussivirkkala
* 2024-05-07 .NET8 Trimmed.
* 2023-11-19 v.1.08 .NET8 and AOT.
* 2023-03-16 v1.0.7 .NET7 added stratuseeg.com
* 2022-04-19 v1.0.4 .NET6 removed namespace, class, main
* 2021-09-02 v1.0.3 Exclude file list, visit
* 2021-08-30 v1.0.2 Try, catch
* 2021-08-29 v1.0.1 Group by Patient,Exam, Visit
* 2021-08-28 v1.0.0 First version
*
** dotnet publish -p:IncludeAllContentForSelfExtract=true
*
*/
using System;
using System.Xml;
using System.IO.Compression;
using System.IO;
using System.Diagnostics;
using System.Reflection;
// Main function
string r = "";
r += Line("Displaying stratus.eeg patient information from .keegz or StaticInfo.xml " +
FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion +
"\ngithub.com/jussivirkkala/Stratus-keegz");
if (args.Length!=1)
{
Console.WriteLine(@"Drag .keegz or StaticInfo.xml over exe or shortcut. Or use SendTo with %APPDATA%\Microsoft\Windows\SendTo");
End();
return;
}
// Filename as parameter
string f = args[0];
r += Line(f);
if (!f.EndsWith("StaticInfo.xml") & !f.EndsWith(".keegz"))
{
Console.WriteLine("File should be .keegz or StaticInfo.xml");
End();
return;
}
string s ="";
if (f.EndsWith("StaticInfo.xml"))
{
s=File.ReadAllText(f);
} else
using (ZipArchive archive = ZipFile.OpenRead(f))
{
foreach (ZipArchiveEntry entry in archive.Entries)
{
// r += Line(entry.FullName);
if (entry.FullName.Equals("StaticInfo.xml"))
{
var sr=new StreamReader(entry.Open());
s=sr.ReadToEnd();
}
}
}
if (s.Length==0)
{
Console.WriteLine("No StaticInfo.xml");
End();
return;
}
XmlDocument doc=null;
try
{
doc = new XmlDocument();
doc.LoadXml(s);
}
catch
{
Console.WriteLine("Error reading XLM");
End();
return;
}
r += Line("\nPatient:");
r += Entry(doc, "Id","Patient");
r += Entry(doc, "LastName", "Patient");
r += Entry(doc, "FirstName", "Patient");
r += Entry(doc, "MiddleNames", "Patient");
r += Entry(doc, "DateOfBirth", "Patient");
r += Entry(doc, "GestationalAge", "Patient");
r += Entry(doc, "GenderMale", "Patient");
r += Entry(doc, "Notes", "Patient");
r += Entry(doc, "PatientHistory", "Patient");
r += Entry(doc, "SocialSecurityNumber", "Patient");
r += Line("\nExam:");
r += Entry(doc, "RecordedDate", "Exam");
r += Entry(doc, "Id", "Exam");
r += Entry(doc, "Anesthesiologist", "Exam");
r += Entry(doc, "ClinicalReason", "Exam");
r += Entry(doc, "Diagnosis", "Exam");
r += Entry(doc, "Medication", "Exam");
r += Entry(doc, "Notes", "Exam");
r += Entry(doc, "PatientState", "Exam");
r += Entry(doc, "Neurophysiologist", "Exam");
r += Entry(doc, "Physician", "Exam");
r += Entry(doc, "RequestedBy", "Exam");
r += Entry(doc, "Secretary", "Exam");
r += Entry(doc, "Surgeon", "Exam");
/*
r += Line("\nVisit");
r += Entry(doc, "Height", "Visit");
r += Entry(doc, "Weight", "Visit");
*/
Console.WriteLine("");
f += ".txt";
if (File.Exists(f))
{
Console.WriteLine("File " + f + " already exist!");
}
else
{
try
{
File.WriteAllText(f, r);
Console.WriteLine("File " + f + " created.");
}
catch
{
Console.WriteLine("Error creating " + f);
}
}
End();
// Find certain element
static string Entry(XmlDocument doc, string header, string group)
{
string r = "";
XmlNodeList elemList = doc.GetElementsByTagName("a:" + header);
for (int i = 0; i < elemList.Count; i++)
{
if (elemList[i].ParentNode.Name.Equals(group))
r += Line(header + ": " + elemList[i].InnerXml);
}
return r;
}
// Display line
static string Line(string s)
{
Console.WriteLine(s);
return s + "\n";
}
// Close info
static void End()
{
Console.Write("Press any key or close window...");
Console.ReadKey();
}
// End