source: cprs/trunk/CPRS-Chart/rLabs.pas@ 456

Last change on this file since 456 was 456, checked in by Kevin Toppenberg, 16 years ago

Initial Upload of Official WV CPRS 1.0.26.76

File size: 12.6 KB
Line 
1unit rLabs;
2
3interface
4
5uses SysUtils, Classes, ORNet, ORFn;
6
7function AtomicTests(const StartFrom: string; Direction: Integer): TStrings;
8function Specimens(const StartFrom: string; Direction: Integer): TStrings;
9function AllTests(const StartFrom: string; Direction: Integer): TStrings;
10function ChemTest(const StartFrom: string; Direction: Integer): TStrings;
11function Users(const StartFrom: string; Direction: Integer): TStrings;
12function TestGroups(user: int64): TStrings;
13function ATest(test: integer): TStrings;
14function ATestGroup(testgroup: Integer; user: int64): TStrings;
15procedure UTGAdd(tests: TStrings);
16procedure UTGReplace(tests: TStrings; testgroup: integer);
17procedure UTGDelete(testgroup: integer);
18procedure SpecimenDefaults(var blood, urine, serum, plasma: string);
19procedure Cumulative(Dest: TStrings; const PatientDFN: string;
20 daysback: integer; ADate1, ADate2: TFMDateTime; ARpc: string);
21procedure RemoteLabCumulative(Dest: TStrings; const PatientDFN: string;
22 daysback: integer; ADate1, ADate2: TFMDateTime; ASite, ARemoteRPC: String);
23procedure Interim(Dest: TStrings; const PatientDFN: string; ADate1, ADate2: TFMDateTime; ARpc: string); //*DFN*
24procedure RemoteLabInterim(Dest: TStrings; const PatientDFN: string; ADate1,
25 ADate2: TFMDateTime; ASite, ARemoteRPC: String);
26procedure Micro(Dest: TStrings; const PatientDFN: string; ADate1,
27 ADate2: TFMDateTime; ARpc: string); //*DFN*
28procedure RemoteLabMicro(Dest: TStrings; const PatientDFN: string; ADate1,
29 ADate2: TFMDateTime; ASite, ARemoteRPC: String);
30function InterimSelect(const PatientDFN: string; ADate1, ADate2: TFMDateTime;
31 tests: TStrings): TStrings; //*DFN*
32function InterimGrid(const PatientDFN: string; ADate1: TFMDateTime;
33 direction, format: integer): TStrings; //*DFN*
34function Worksheet(const PatientDFN: string; ADate1, ADate2: TFMDateTime;
35 spec: string; tests: TStrings): TStrings; //*DFN*
36procedure Reports(Dest: TStrings; const PatientDFN: string; reportid, hstype,
37 ADate, section: string; Adate1, Adate2: TFMDateTime; ARpc: string); //*DFN*
38procedure RemoteLabReports(Dest: TStrings; const PatientDFN: string; reportid, hstype,
39 ADate, section: string; Adate1, Adate2: TFMDateTime; ASite, ARemoteRPC: String);
40procedure RemoteLab(Dest: TStrings; const PatientDFN: string; reportid, hstype,
41 ADate, section: string; Adate1, Adate2: TFMDateTime; ASite, ARemoteRPC: String);
42procedure GetNewestOldest(const PatientDFN: string; var newest, oldest: string); //*DFN*
43function GetChart(const PatientDFN: string; ADate1, ADate2: TFMDateTime;
44 spec, test: string): TStrings; //*DFN*
45procedure PrintLabsToDevice(AReport, ADaysBack: Integer;
46 const PatientDFN, ADevice: string; ATests: TStrings;
47 var ErrMsg: string; ADate1, ADate2: TFMDateTime; ARemoteSiteID, ARemoteQuery: string);
48function GetFormattedLabReport(AReport, ADaysBack: Integer; const PatientDFN: string;
49 ATests: TStrings; ADate1, ADate2: TFMDateTime; ARemoteSiteID, ARemoteQuery: string): TStrings;
50function TestInfo(Test: String): TStrings;
51
52implementation
53
54uses rCore, uCore, graphics;
55
56function AtomicTests(const StartFrom: string; Direction: Integer): TStrings;
57begin
58 CallV('ORWLRR ATOMICS', [StartFrom, Direction]);
59 MixedCaseList(RPCBrokerV.Results);
60 Result := RPCBrokerV.Results;
61end;
62
63function Specimens(const StartFrom: string; Direction: Integer): TStrings;
64begin
65 CallV('ORWLRR SPEC', [StartFrom, Direction]);
66 MixedCaseList(RPCBrokerV.Results);
67 Result := RPCBrokerV.Results;
68end;
69
70function AllTests(const StartFrom: string; Direction: Integer): TStrings;
71begin
72 CallV('ORWLRR ALLTESTS', [StartFrom, Direction]);
73 MixedCaseList(RPCBrokerV.Results);
74 Result := RPCBrokerV.Results;
75end;
76
77function ChemTest(const StartFrom: string; Direction: Integer): TStrings;
78begin
79 CallV('ORWLRR CHEMTEST', [StartFrom, Direction]);
80 MixedCaseList(RPCBrokerV.Results);
81 Result := RPCBrokerV.Results;
82end;
83
84function Users(const StartFrom: string; Direction: Integer): TStrings;
85begin
86 CallV('ORWLRR USERS', [StartFrom, Direction]);
87 MixedCaseList(RPCBrokerV.Results);
88 Result := RPCBrokerV.Results;
89end;
90
91function TestGroups(user: int64): TStrings;
92begin
93 CallV('ORWLRR TG', [user]);
94 MixedCaseList(RPCBrokerV.Results);
95 Result := RPCBrokerV.Results;
96end;
97
98function ATest(test: integer): TStrings;
99begin
100 CallV('ORWLRR ATESTS', [test]);
101 MixedCaseList(RPCBrokerV.Results);
102 Result := RPCBrokerV.Results;
103end;
104
105function ATestGroup(testgroup: Integer; user: int64): TStrings;
106begin
107 CallV('ORWLRR ATG', [testgroup, user]);
108 MixedCaseList(RPCBrokerV.Results);
109 Result := RPCBrokerV.Results;
110end;
111
112procedure UTGAdd(tests: TStrings);
113begin
114 CallV('ORWLRR UTGA', [tests]);
115end;
116
117procedure UTGReplace(tests: TStrings; testgroup: integer);
118begin
119 CallV('ORWLRR UTGR', [tests, testgroup]);
120end;
121
122procedure UTGDelete(testgroup: integer);
123begin
124 CallV('ORWLRR UTGD', [testgroup]);
125end;
126
127procedure SpecimenDefaults(var blood, urine, serum, plasma: string);
128begin
129 CallV('ORWLRR PARAM', [nil]);
130 blood := Piece(RPCBrokerV.Results[0], '^', 1);
131 urine := Piece(RPCBrokerV.Results[0], '^', 2);
132 serum := Piece(RPCBrokerV.Results[0], '^', 3);
133 plasma := Piece(RPCBrokerV.Results[0], '^', 4);
134end;
135
136procedure Cumulative(Dest: TStrings; const PatientDFN: string; daysback: integer; ADate1, ADate2: TFMDateTime; ARpc: string); //*DFN*
137begin
138 if Length(ARpc) > 0 then
139 begin
140 CallV(ARpc, [PatientDFN, daysback, ADate1, ADate2]);
141 QuickCopy(RPCBrokerV.Results,Dest);
142 end
143 else
144 begin
145 Dest.Add('RPC is missing from report definition (file 101.24).');
146 Dest.Add('Please contact Technical Support.');
147 end;
148end;
149
150procedure RemoteLabCumulative(Dest: TStrings; const PatientDFN: string;
151 daysback: integer; ADate1, ADate2: TFMDateTime; ASite, ARemoteRPC: String);
152begin
153 CallV('XWB REMOTE RPC', [ASite, ARemoteRPC, 0, PatientDFN, daysback, Adate1, Adate2]);
154 QuickCopy(RPCBrokerV.Results,Dest);
155end;
156
157procedure Interim(Dest: TStrings; const PatientDFN: string; ADate1, ADate2: TFMDateTime; ARpc: string); //*DFN*
158begin
159 if Length(ARpc) > 0 then
160 begin
161 CallV(ARpc, [PatientDFN, ADate1, ADate2]);
162 QuickCopy(RPCBrokerV.Results,Dest);
163 end
164 else
165 begin
166 Dest.Add('RPC is missing from report definition (file 101.24).');
167 Dest.Add('Please contact Technical Support.');
168 end;
169end;
170
171procedure RemoteLabInterim(Dest: TStrings; const PatientDFN: string; ADate1,
172 ADate2: TFMDateTime; ASite, ARemoteRPC: String);
173begin
174 CallV('XWB REMOTE RPC',[ASite, ARemoteRPC, 0, PatientDFN, Adate1, Adate2]);
175 QuickCopy(RPCBrokerV.Results,Dest);
176end;
177
178procedure Micro(Dest: TStrings; const PatientDFN: string; ADate1, ADate2: TFMDateTime; ARpc: string); //*DFN*
179begin
180 if Length(ARpc) > 0 then
181 begin
182 CallV(ARpc, [PatientDFN, ADate1, ADate2]);
183 QuickCopy(RPCBrokerV.Results,Dest);
184 end
185 else
186 begin
187 Dest.Add('RPC is missing from report definition (file 101.24).');
188 Dest.Add('Please contact Technical Support.');
189 end;
190end;
191
192procedure RemoteLabMicro(Dest: TStrings; const PatientDFN: string; ADate1,
193 ADate2: TFMDateTime; ASite, ARemoteRPC: String);
194begin
195 CallV('XWB REMOTE RPC',[ASite, ARemoteRPC, 0, PatientDFN, Adate1, Adate2]);
196 QuickCopy(RPCBrokerV.Results,Dest);
197end;
198
199function InterimSelect(const PatientDFN: string; ADate1, ADate2: TFMDateTime; tests: TStrings): TStrings; //*DFN*
200begin
201 CallV('ORWLRR INTERIMS', [PatientDFN, ADate1, ADate2, tests]);
202 Result := RPCBrokerV.Results;
203end;
204
205function InterimGrid(const PatientDFN: string; ADate1: TFMDateTime; direction, format: integer): TStrings; //*DFN*
206begin
207 CallV('ORWLRR INTERIMG', [PatientDFN, ADate1, direction, format]);
208 Result := RPCBrokerV.Results;
209end;
210
211function Worksheet(const PatientDFN: string; ADate1, ADate2: TFMDateTime; spec: string; tests: TStrings): TStrings; //*DFN*
212begin
213 CallV('ORWLRR GRID', [PatientDFN, ADate1, ADate2, spec, tests]);
214 Result := RPCBrokerV.Results;
215end;
216
217procedure Reports(Dest: TStrings; const PatientDFN: string; reportid, hstype, ADate, section: string; Adate1, Adate2: TFMDateTime; ARpc: string); //*DFN*
218begin
219 if Length(ARpc) > 0 then
220 begin
221 CallV(ARpc, [PatientDFN, reportid, hstype, ADate, section, Adate2, Adate1]);
222 QuickCopy(RPCBrokerV.Results,Dest);
223 end
224 else
225 begin
226 Dest.Add('RPC is missing from report definition (file 101.24).');
227 Dest.Add('Please contact Technical Support.');
228 end;
229end;
230
231procedure RemoteLabReports(Dest: TStrings; const PatientDFN: string; reportid, hstype,
232 ADate, section: string; Adate1, Adate2: TFMDateTime; ASite, ARemoteRPC: String);
233begin
234 CallV('XWB REMOTE RPC',[ASite, ARemoteRPC, 0, PatientDFN,
235 reportid + ';1', hstype, ADate, section, Adate2, Adate1]);
236 QuickCopy(RPCBrokerV.Results,Dest);
237end;
238
239procedure RemoteLab(Dest: TStrings; const PatientDFN: string; reportid, hstype,
240 ADate, section: string; Adate1, Adate2: TFMDateTime; ASite, ARemoteRPC: String);
241begin
242 CallV('XWB REMOTE RPC',[ASite, ARemoteRPC, 0, PatientDFN,
243 reportid + ';1', hstype, ADate, section, Adate2, Adate1]);
244 QuickCopy(RPCBrokerV.Results,Dest);
245end;
246
247procedure GetNewestOldest(const PatientDFN: string; var newest, oldest: string); //*DFN*
248begin
249 CallV('ORWLRR NEWOLD', [PatientDFN]);
250 newest := Piece(RPCBrokerV.Results[0], '^', 1);
251 oldest := Piece(RPCBrokerV.Results[0], '^', 2);
252end;
253
254function GetChart(const PatientDFN: string; ADate1, ADate2: TFMDateTime; spec, test: string): TStrings; //*DFN*
255begin
256 CallV('ORWLRR CHART', [PatientDFN, ADate1, ADate2, spec, test]);
257 Result := RPCBrokerV.Results;
258end;
259
260procedure PrintLabsToDevice(AReport, ADaysBack: Integer;
261 const PatientDFN, ADevice: string; ATests: TStrings; var ErrMsg: string;
262 ADate1, ADate2: TFMDateTime; ARemoteSiteID, ARemoteQuery: string);
263{ prints a report on the selected device }
264var
265 j: integer;
266 RemoteHandle,Report: string;
267 aHandles: TStringlist;
268begin
269 aHandles := TStringList.Create;
270 if Length(ARemoteSiteID) > 0 then
271 begin
272 RemoteHandle := '';
273 for j := 0 to RemoteReports.Count - 1 do
274 begin
275 Report := TRemoteReport(RemoteReports.ReportList.Items[j]).Report;
276 if Report = ARemoteQuery then
277 begin
278 RemoteHandle := TRemoteReport(RemoteReports.ReportList.Items[j]).Handle
279 + '^' + Pieces(Report,'^',9,10);
280 break;
281 end;
282 end;
283 if Length(RemoteHandle) > 1 then
284 with RemoteSites.SiteList do
285 aHandles.Add(ARemoteSiteID + '^' + RemoteHandle);
286 end;
287 if aHandles.Count > 0 then
288 begin
289 ErrMsg := sCallV('ORWRP PRINT LAB REMOTE',[ADevice, PatientDFN, AReport, aHandles]);
290 if Piece(ErrMsg, U, 1) = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2);
291 end
292 else
293 begin
294 ErrMsg := sCallV('ORWRP PRINT LAB REPORTS',[ADevice, PatientDFN, AReport,
295 ADaysBack, ATests, ADate2, ADate1]);
296 if Piece(ErrMsg, U, 1) = '0' then ErrMsg := '' else ErrMsg := Piece(ErrMsg, U, 2);
297 end;
298 aHandles.Clear;
299 aHandles.Free;
300end;
301
302function GetFormattedLabReport(AReport, ADaysBack: Integer;
303 const PatientDFN: string; ATests: TStrings; ADate1, ADate2: TFMDateTime;
304 ARemoteSiteID, ARemoteQuery: string): TStrings;
305{ prints a report on the selected Windows device }
306var
307 j: integer;
308 RemoteHandle,Report: string;
309 aHandles: TStringlist;
310begin
311 aHandles := TStringList.Create;
312 if Length(ARemoteSiteID) > 0 then
313 begin
314 RemoteHandle := '';
315 for j := 0 to RemoteReports.Count - 1 do
316 begin
317 Report := TRemoteReport(RemoteReports.ReportList.Items[j]).Report;
318 if Report = ARemoteQuery then
319 begin
320 RemoteHandle := TRemoteReport(RemoteReports.ReportList.Items[j]).Handle
321 + '^' + Pieces(Report,'^',9,10);
322 break;
323 end;
324 end;
325 if Length(RemoteHandle) > 1 then
326 with RemoteSites.SiteList do
327 aHandles.Add(ARemoteSiteID + '^' + RemoteHandle);
328 end;
329 if aHandles.Count > 0 then
330 begin
331 CallV('ORWRP PRINT WINDOWS LAB REMOTE',[PatientDFN, AReport, aHandles]);
332 Result := RPCBrokerV.Results;
333 end
334 else
335 begin
336 CallV('ORWRP WINPRINT LAB REPORTS',[PatientDFN, AReport, ADaysBack, ATests,
337 ADate2, ADate1]);
338 Result := RPCBrokerV.Results;
339 end;
340 aHandles.Clear;
341 aHandles.Free;
342end;
343
344function TestInfo(Test: String): TStrings;
345begin
346 CallV('ORWLRR INFO',[Test]);
347 Result := RPCBrokerV.Results;
348end;
349
350end.
Note: See TracBrowser for help on using the repository browser.