1 | unit fReportsPrint;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | StdCtrls, fAutoSz, ORCtrls, ORNet, Mask, ComCtrls, rECS;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmReportPrt = class(TfrmAutoSz)
|
---|
11 | lblReportsTitle: TMemo;
|
---|
12 | lblPrintTo: TLabel;
|
---|
13 | grpDevice: TGroupBox;
|
---|
14 | lblMargin: TLabel;
|
---|
15 | lblLength: TLabel;
|
---|
16 | txtRightMargin: TMaskEdit;
|
---|
17 | txtPageLength: TMaskEdit;
|
---|
18 | cboDevice: TORComboBox;
|
---|
19 | cmdOK: TButton;
|
---|
20 | cmdCancel: TButton;
|
---|
21 | dlgWinPrinter: TPrintDialog;
|
---|
22 | chkDefault: TCheckBox;
|
---|
23 | procedure FormCreate(Sender: TObject);
|
---|
24 | procedure cboDeviceChange(Sender: TObject);
|
---|
25 | procedure cmdOKClick(Sender: TObject);
|
---|
26 | procedure cmdCancelClick(Sender: TObject);
|
---|
27 | procedure cboDeviceNeedData(Sender: TObject; const StartFrom: String;
|
---|
28 | Direction, InsertAt: Integer);
|
---|
29 | procedure FormDestroy(Sender: TObject);
|
---|
30 | procedure FindVType;
|
---|
31 |
|
---|
32 | private
|
---|
33 | { Private declarations }
|
---|
34 | FReports: string;
|
---|
35 | FReportText: TRichEdit;
|
---|
36 | procedure DisplaySelectDevice;
|
---|
37 |
|
---|
38 | public
|
---|
39 | { Public declarations }
|
---|
40 | end;
|
---|
41 |
|
---|
42 | var
|
---|
43 | frmReportPrt: TfrmReportPrt;
|
---|
44 |
|
---|
45 | procedure PrintReports(AReports: string; const AReportsTitle: string);
|
---|
46 | function StringPad(aString: string; aStringCount, aPadCount: integer): String;
|
---|
47 |
|
---|
48 | implementation
|
---|
49 |
|
---|
50 | {$R *.DFM}
|
---|
51 |
|
---|
52 | uses ORFn, rCore, uCore, fReports, rReports, uReports, Printers, fFrame;
|
---|
53 |
|
---|
54 | const
|
---|
55 | TX_NODEVICE = 'A device must be selected to print, or press ''Cancel'' to not print.';
|
---|
56 | TX_NODEVICE_CAP = 'Device Not Selected';
|
---|
57 | TX_ERR_CAP = 'Print Error';
|
---|
58 | PAGE_BREAK = '**PAGE BREAK**';
|
---|
59 | QT_OTHER = 0;
|
---|
60 | QT_HSTYPE = 1;
|
---|
61 | QT_DATERANGE = 2;
|
---|
62 | QT_IMAGING = 3;
|
---|
63 | QT_NUTR = 4;
|
---|
64 | QT_PROCEDURES = 19;
|
---|
65 | QT_SURGERY = 28;
|
---|
66 | QT_HSCOMPONENT = 5;
|
---|
67 | QT_HSWPCOMPONENT = 6;
|
---|
68 |
|
---|
69 | procedure PrintReports(AReports: string; const AReportsTitle: string);
|
---|
70 | { displays a form that prompts for a device and then prints the report }
|
---|
71 | var
|
---|
72 | frmReportPrt: TfrmReportPrt;
|
---|
73 | DefPrt: string;
|
---|
74 | begin
|
---|
75 | frmReportPrt := TfrmReportPrt.Create(Application);
|
---|
76 | try
|
---|
77 | ResizeFormToFont(TForm(frmReportPrt));
|
---|
78 | with frmReportPrt do
|
---|
79 | begin
|
---|
80 | lblReportsTitle.Text := AReportsTitle;
|
---|
81 | FReports := AReports;
|
---|
82 | DefPrt := GetDefaultPrinter(User.Duz, Encounter.Location);
|
---|
83 | if User.CurrentPrinter = '' then User.CurrentPrinter := DefPrt;
|
---|
84 | with cboDevice do
|
---|
85 | begin
|
---|
86 | if Printer.Printers.Count > 0 then
|
---|
87 | begin
|
---|
88 | Items.Add('WIN;Windows Printer^Windows Printer');
|
---|
89 | Items.Add('^--------------------VistA Printers----------------------');
|
---|
90 | end;
|
---|
91 | if User.CurrentPrinter <> '' then
|
---|
92 | begin
|
---|
93 | InitLongList(Piece(User.CurrentPrinter, ';', 2));
|
---|
94 | SelectByID(User.CurrentPrinter);
|
---|
95 | end
|
---|
96 | else
|
---|
97 | InitLongList('');
|
---|
98 | end;
|
---|
99 | if (DefPrt = 'WIN;Windows Printer') and
|
---|
100 | (User.CurrentPrinter = DefPrt) then
|
---|
101 | cmdOKClick(frmReportPrt)
|
---|
102 | else
|
---|
103 | ShowModal;
|
---|
104 | end;
|
---|
105 | finally
|
---|
106 | frmReportPrt.Release;
|
---|
107 | end;
|
---|
108 | end;
|
---|
109 |
|
---|
110 | procedure TfrmReportPrt.FindVType;
|
---|
111 | var
|
---|
112 | i,j,k,L,cnt: integer;
|
---|
113 | aBasket: TStringList;
|
---|
114 | aID, aHead, aData, aCol, x: string;
|
---|
115 | ListItem: TListItem;
|
---|
116 | aWPFlag: Boolean;
|
---|
117 | begin
|
---|
118 | aBasket := TStringList.Create;
|
---|
119 | aBasket.Clear;
|
---|
120 | //frmReports.MemText.Clear;
|
---|
121 | aHead := '';
|
---|
122 | cnt := 2;
|
---|
123 | //aWPFlag := false;
|
---|
124 | for i := 0 to uColumns.Count - 1 do
|
---|
125 | begin
|
---|
126 | if (piece(uColumns[i],'^',7) = '1') and (not(piece(uColumns[i],'^',4) = '1')) then
|
---|
127 | begin
|
---|
128 | L := StrToIntDef(piece(uColumns[i],'^',6),15);
|
---|
129 | if length(piece(uColumns[i],'^',8)) > 0 then
|
---|
130 | x := piece(uColumns[i],'^',8)
|
---|
131 | else
|
---|
132 | x := piece(uColumns[i],'^',1);
|
---|
133 | x := StringPad(x, L, L+1);
|
---|
134 | if frmReports.TabControl1.Tabs.Count > 1 then
|
---|
135 | aHead := aHead + x
|
---|
136 | else
|
---|
137 | if i = 0 then
|
---|
138 | continue
|
---|
139 | else
|
---|
140 | aHead := aHead + x;
|
---|
141 | end;
|
---|
142 | end;
|
---|
143 | if length(aHead) > 0 then
|
---|
144 | begin
|
---|
145 | FReportText.Lines.Add(aHead);
|
---|
146 | FReportText.Lines.Add('-------------------------------------------------------------------------------');
|
---|
147 | //frmReports.memText.Lines.Add(aHead);
|
---|
148 | //frmReports.MemText.Lines.Add('-------------------------------------------------------------------------------');
|
---|
149 | end;
|
---|
150 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
151 | if frmReports.lvReports.Items[i].Selected then
|
---|
152 | begin
|
---|
153 | aData := '';
|
---|
154 | aWPFlag := false;
|
---|
155 | ListItem := frmReports.lvReports.Items[i];
|
---|
156 | aID := ListItem.SubItems[0];
|
---|
157 | if frmReports.TabControl1.Tabs.Count > 1 then
|
---|
158 | begin
|
---|
159 | L := StrToIntDef(piece(uColumns[0],'^',6),10);
|
---|
160 | x := StringPad(ListItem.Caption, L, L+1);
|
---|
161 | aData := x;
|
---|
162 | end;
|
---|
163 | for j := 0 to RowObjects.ColumnList.Count - 1 do
|
---|
164 | begin
|
---|
165 | aCol := TCellObject(RowObjects.ColumnList[j]).Handle;
|
---|
166 | if piece(aID,':',1) = piece(TCellObject(RowObjects.ColumnList[j]).Handle,':',1) then
|
---|
167 | if ListItem.Caption = (piece(TCellObject(RowObjects.ColumnList[j]).Site,';',1)) then
|
---|
168 | begin
|
---|
169 | if (piece(uColumns[StrToInt(piece(aCol,':',2))],'^',7) = '1') and
|
---|
170 | (not (piece(uColumns[StrToInt(piece(aCol,':',2))],'^',4) = '1')) then
|
---|
171 | begin
|
---|
172 | aBasket.Assign(TCellObject(RowObjects.ColumnList[j]).Data);
|
---|
173 | for k := 0 to aBasket.Count - 1 do
|
---|
174 | begin
|
---|
175 | L := StrToIntDef(piece(uColumns[StrToInt(piece(aCol,':',2))],'^',6),15);
|
---|
176 | x := StringPad(aBasket[k], L, L+1);
|
---|
177 | aData := aData + x;
|
---|
178 | end;
|
---|
179 | end;
|
---|
180 | end;
|
---|
181 | end;
|
---|
182 | //frmReports.memText.Lines.Add(aData);
|
---|
183 | FReportText.Lines.Add(aData);
|
---|
184 | cnt := cnt + 1;
|
---|
185 | if cnt > 40 then
|
---|
186 | begin
|
---|
187 | cnt := 0;
|
---|
188 | //frmReports.memText.Lines.Add('**PAGE BREAK**');
|
---|
189 | FReportText.Lines.Add('**PAGE BREAK**');
|
---|
190 | end;
|
---|
191 | for j := 0 to RowObjects.ColumnList.Count - 1 do
|
---|
192 | begin
|
---|
193 | aCol := TCellObject(RowObjects.ColumnList[j]).Handle;
|
---|
194 | if piece(aID,':',1) = piece(TCellObject(RowObjects.ColumnList[j]).Handle,':',1) then
|
---|
195 | if ListItem.Caption = (piece(TCellObject(RowObjects.ColumnList[j]).Site,';',1)) then
|
---|
196 | begin
|
---|
197 | if (piece(uColumns[StrToInt(piece(aCol,':',2))],'^',7) = '1') and
|
---|
198 | (piece(uColumns[StrToInt(piece(aCol,':',2))],'^',4) = '1') then
|
---|
199 | begin
|
---|
200 | aWPFlag := true;
|
---|
201 | aBasket.Assign(TCellObject(RowObjects.ColumnList[j]).Data);
|
---|
202 | //frmReports.MemText.Lines.Add(TCellObject(RowObjects.ColumnList[j]).Name);
|
---|
203 | FReportText.Lines.Add(TCellObject(RowObjects.ColumnList[j]).Name);
|
---|
204 | cnt := cnt + 1;
|
---|
205 | for k := 0 to aBasket.Count - 1 do
|
---|
206 | begin
|
---|
207 | //frmReports.memText.Lines.Add(' ' + aBasket[k]);
|
---|
208 | FReportText.Lines.Add(' ' + aBasket[k]);
|
---|
209 | cnt := cnt + 1;
|
---|
210 | if cnt > 40 then
|
---|
211 | begin
|
---|
212 | cnt := 0;
|
---|
213 | //frmReports.memText.Lines.Add('**PAGE BREAK**');
|
---|
214 | FReportText.Lines.Add('**PAGE BREAK**');
|
---|
215 | end;
|
---|
216 | end;
|
---|
217 | end;
|
---|
218 | end;
|
---|
219 | end;
|
---|
220 | if aWPFlag = true then
|
---|
221 | begin
|
---|
222 | //frmReports.MemText.Lines.Add('===============================================================================');
|
---|
223 | FReportText.Lines.Add('===============================================================================');
|
---|
224 | end;
|
---|
225 | end;
|
---|
226 | aBasket.Free;
|
---|
227 | end;
|
---|
228 |
|
---|
229 | function StringPad(aString: string; aStringCount, aPadCount: integer): String;
|
---|
230 | var
|
---|
231 | s: integer;
|
---|
232 | begin
|
---|
233 | if aStringCount >= aPadCount then
|
---|
234 | aStringCount := aPadCount - 1;
|
---|
235 | Result := copy(aString, 1, aStringCount);
|
---|
236 | s := aPadCount - length(Result);
|
---|
237 | if s < 0 then s := 0;
|
---|
238 | Result := Result + StringOfChar(' ', s);
|
---|
239 | end;
|
---|
240 |
|
---|
241 | procedure TfrmReportPrt.DisplaySelectDevice;
|
---|
242 | begin
|
---|
243 | with cboDevice, lblPrintTo do
|
---|
244 | begin
|
---|
245 | Caption := 'Print Report on: ' + Piece(ItemID, ';', 2);
|
---|
246 | end;
|
---|
247 | end;
|
---|
248 |
|
---|
249 | procedure TfrmReportPrt.FormCreate(Sender: TObject);
|
---|
250 | begin
|
---|
251 | inherited;
|
---|
252 | FReportText := TRichEdit.Create(Self);
|
---|
253 | with FReportText do
|
---|
254 | begin
|
---|
255 | Parent := Self;
|
---|
256 | Visible := False;
|
---|
257 | Width := 600;
|
---|
258 | end;
|
---|
259 | end;
|
---|
260 |
|
---|
261 | procedure TfrmReportPrt.cboDeviceChange(Sender: TObject);
|
---|
262 | begin
|
---|
263 | inherited;
|
---|
264 | with cboDevice do if ItemIndex > -1 then
|
---|
265 | begin
|
---|
266 | txtRightMargin.Text := Piece(Items[ItemIndex], '^', 4);
|
---|
267 | txtPageLength.Text := Piece(Items[ItemIndex], '^', 5);
|
---|
268 | DisplaySelectDevice;
|
---|
269 | end;
|
---|
270 | end;
|
---|
271 |
|
---|
272 | procedure TfrmReportPrt.cmdOKClick(Sender: TObject);
|
---|
273 | var
|
---|
274 | ADevice, ErrMsg: string;
|
---|
275 | RemoteSiteID: string;
|
---|
276 | RemoteQuery: string;
|
---|
277 | aQualifier: string;
|
---|
278 | aReport: TStringList;
|
---|
279 | aCaption: string;
|
---|
280 | i: integer;
|
---|
281 | ListItem: TListItem;
|
---|
282 | MoreID: String; //Restores MaxOcc value
|
---|
283 | begin
|
---|
284 | inherited;
|
---|
285 | RemoteSiteID := '';
|
---|
286 | RemoteQuery := '';
|
---|
287 | MoreID := '';
|
---|
288 | aReport := TStringList.Create;
|
---|
289 | if uQualifier = '' then
|
---|
290 | aQualifier := piece(uRemoteType,'^',5) //Health Summary Type Report
|
---|
291 | else
|
---|
292 | begin
|
---|
293 | MoreID := ';' + Piece(uQualifier,';',3);
|
---|
294 | aQualifier := piece(uRemoteType,'^',5);
|
---|
295 | end;
|
---|
296 | with frmReports.TabControl1 do
|
---|
297 | if TabIndex > 0 then
|
---|
298 | begin
|
---|
299 | RemoteSiteID := TRemoteSite(Tabs.Objects[TabIndex]).SiteID;
|
---|
300 | RemoteQuery := TRemoteSite(Tabs.Objects[TabIndex]).CurrentReportQuery;
|
---|
301 | end;
|
---|
302 | if cboDevice.ItemID = '' then
|
---|
303 | begin
|
---|
304 | InfoBox(TX_NODEVICE, TX_NODEVICE_CAP, MB_OK);
|
---|
305 | Exit;
|
---|
306 | end;
|
---|
307 | if Piece(cboDevice.ItemID, ';', 1) = 'WIN' then
|
---|
308 | begin
|
---|
309 | if dlgWinPrinter.Execute then with FReportText do
|
---|
310 | begin
|
---|
311 | if uReportType = 'V' then
|
---|
312 | begin
|
---|
313 | case uQualifierType of
|
---|
314 | QT_IMAGING:
|
---|
315 | begin
|
---|
316 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
317 | if frmReports.lvReports.Items[i].Selected then
|
---|
318 | begin
|
---|
319 | ListItem := frmReports.lvReports.Items[i];
|
---|
320 | aQualifier := ListItem.SubItems[0];
|
---|
321 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
322 | Lines.Assign(GetFormattedReport(FReports, aQualifier,
|
---|
323 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
324 | aCaption := piece(uRemoteType,'^',4);
|
---|
325 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
326 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
327 | end;
|
---|
328 | end;
|
---|
329 | QT_NUTR:
|
---|
330 | begin
|
---|
331 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
332 | if frmReports.lvReports.Items[i].Selected then
|
---|
333 | begin
|
---|
334 | ListItem := frmReports.lvReports.Items[i];
|
---|
335 | aQualifier := ListItem.SubItems[0];
|
---|
336 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
337 | Lines.Assign(GetFormattedReport(FReports, aQualifier + MoreID,
|
---|
338 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
339 | aCaption := piece(uRemoteType,'^',4);
|
---|
340 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
341 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
342 | end;
|
---|
343 | end;
|
---|
344 | QT_HSCOMPONENT:
|
---|
345 | begin
|
---|
346 | if (length(piece(uHState,';',2)) > 0) then
|
---|
347 | begin
|
---|
348 | FReportText.Clear;
|
---|
349 | aReport.Clear;
|
---|
350 | CreatePatientHeader(aReport,piece(uRemoteType,'^',4));
|
---|
351 | FReportText.Lines.Assign(aReport);
|
---|
352 | FindVType;
|
---|
353 | aCaption := piece(uRemoteType,'^',4) + ';1';
|
---|
354 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
355 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
356 | end
|
---|
357 | else
|
---|
358 | begin
|
---|
359 | Lines.Assign(GetFormattedReport(FReports, aQualifier + MoreID,
|
---|
360 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
361 | aCaption := piece(uRemoteType,'^',4);
|
---|
362 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
363 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
364 | end;
|
---|
365 | end;
|
---|
366 | QT_HSWPCOMPONENT:
|
---|
367 | begin
|
---|
368 | if (length(piece(uHState,';',2)) > 0) then
|
---|
369 | begin
|
---|
370 | FReportText.Clear;
|
---|
371 | aReport.Clear;
|
---|
372 | CreatePatientHeader(aReport,piece(uRemoteType,'^',4));
|
---|
373 | FReportText.Lines.Assign(aReport);
|
---|
374 | FindVType;
|
---|
375 | aCaption := piece(uRemoteType,'^',4) + ';1';
|
---|
376 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
377 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
378 | end
|
---|
379 | else
|
---|
380 | begin
|
---|
381 | Lines.Assign(GetFormattedReport(FReports, aQualifier + MoreID,
|
---|
382 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
383 | aCaption := piece(uRemoteType,'^',4);
|
---|
384 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
385 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
386 | end;
|
---|
387 | end;
|
---|
388 | QT_PROCEDURES:
|
---|
389 | begin
|
---|
390 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
391 | if frmReports.lvReports.Items[i].Selected then
|
---|
392 | begin
|
---|
393 | ListItem := frmReports.lvReports.Items[i];
|
---|
394 | aQualifier := ListItem.SubItems[0];
|
---|
395 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
396 | Lines.Assign(GetFormattedReport(FReports, aQualifier,
|
---|
397 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
398 | aCaption := piece(uRemoteType,'^',4);
|
---|
399 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
400 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
401 | end;
|
---|
402 | end;
|
---|
403 | QT_SURGERY:
|
---|
404 | begin
|
---|
405 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
406 | if frmReports.lvReports.Items[i].Selected then
|
---|
407 | begin
|
---|
408 | ListItem := frmReports.lvReports.Items[i];
|
---|
409 | aQualifier := ListItem.SubItems[0];
|
---|
410 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
411 | Lines.Assign(GetFormattedReport(FReports, aQualifier,
|
---|
412 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
413 | aCaption := piece(uRemoteType,'^',4);
|
---|
414 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
415 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
416 | end;
|
---|
417 | end;
|
---|
418 | end;
|
---|
419 | end
|
---|
420 | else
|
---|
421 | begin
|
---|
422 | if (Pos('OR_ECS1',FReports)>0) or (Pos('OR_ECS2',FReports)>0) then
|
---|
423 | begin
|
---|
424 | ShowMessage('The Event Capture report can only be printed by Vista printer.');
|
---|
425 | Exit;
|
---|
426 | end;
|
---|
427 | aQualifier := Piece(uRemoteType,'^',5);
|
---|
428 | Lines.Assign(GetFormattedReport(FReports, aQualifier,
|
---|
429 | Patient.DFN, uHSComponents, RemoteSiteID, RemoteQuery, uHState));
|
---|
430 | aCaption := piece(uRemoteType,'^',4);
|
---|
431 | PrintWindowsReport(FReportText, PAGE_BREAK, aCaption, ErrMsg);
|
---|
432 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
433 | end;
|
---|
434 | end;
|
---|
435 | end
|
---|
436 | else // if it's not a Win printer
|
---|
437 | begin
|
---|
438 | if uReportType = 'V' then
|
---|
439 | begin
|
---|
440 | case uQualifierType of
|
---|
441 | QT_IMAGING:
|
---|
442 | begin
|
---|
443 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
444 | if frmReports.lvReports.Items[i].Selected then
|
---|
445 | begin
|
---|
446 | ListItem := frmReports.lvReports.Items[i];
|
---|
447 | aQualifier := ListItem.SubItems[0];
|
---|
448 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
449 | PrintReportsToDevice(piece(FReports,':',1), aQualifier + MoreID,
|
---|
450 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
451 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
452 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
453 | end;
|
---|
454 | end;
|
---|
455 | QT_NUTR:
|
---|
456 | begin
|
---|
457 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
458 | if frmReports.lvReports.Items[i].Selected then
|
---|
459 | begin
|
---|
460 | ListItem := frmReports.lvReports.Items[i];
|
---|
461 | aQualifier := ListItem.SubItems[0];
|
---|
462 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
463 | PrintReportsToDevice(piece(FReports,':',1), aQualifier + MoreID,
|
---|
464 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
465 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
466 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
467 | end;
|
---|
468 | end;
|
---|
469 | QT_HSCOMPONENT:
|
---|
470 | begin
|
---|
471 | if (length(piece(uHState,';',2)) > 0) then
|
---|
472 | begin
|
---|
473 | FindVType;
|
---|
474 | aReport.Clear;
|
---|
475 | aReport.Assign(FReportText.Lines);
|
---|
476 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
477 | PrintVReports(ErrMsg, ADevice, piece(uRemoteType,'^',4),aReport);
|
---|
478 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
479 | end
|
---|
480 | else
|
---|
481 | begin
|
---|
482 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
483 | PrintReportsToDevice(FReports, aQualifier + MoreID,
|
---|
484 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
485 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
486 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
487 | end;
|
---|
488 | end;
|
---|
489 | QT_HSWPCOMPONENT:
|
---|
490 | begin
|
---|
491 | if (length(piece(uHState,';',2)) > 0) then
|
---|
492 | begin
|
---|
493 | FindVType;
|
---|
494 | aReport.Clear;
|
---|
495 | aReport.Assign(FReportText.Lines);
|
---|
496 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
497 | PrintVReports(ErrMsg, ADevice, piece(uRemoteType,'^',4),aReport);
|
---|
498 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
499 | end
|
---|
500 | else
|
---|
501 | begin
|
---|
502 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
503 | PrintReportsToDevice(FReports, aQualifier + MoreID,
|
---|
504 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
505 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
506 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
507 | end;
|
---|
508 | end;
|
---|
509 | QT_PROCEDURES:
|
---|
510 | begin
|
---|
511 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
512 | if frmReports.lvReports.Items[i].Selected then
|
---|
513 | begin
|
---|
514 | ListItem := frmReports.lvReports.Items[i];
|
---|
515 | aQualifier := ListItem.SubItems[0];
|
---|
516 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
517 | PrintReportsToDevice(piece(FReports,':',1), aQualifier,
|
---|
518 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
519 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
520 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
521 | end;
|
---|
522 | end;
|
---|
523 | QT_SURGERY:
|
---|
524 | begin
|
---|
525 | for i := 0 to frmReports.lvReports.Items.Count - 1 do
|
---|
526 | if frmReports.lvReports.Items[i].Selected then
|
---|
527 | begin
|
---|
528 | ListItem := frmReports.lvReports.Items[i];
|
---|
529 | aQualifier := ListItem.SubItems[0];
|
---|
530 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
531 | PrintReportsToDevice(piece(FReports,':',1), aQualifier + MoreID,
|
---|
532 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
533 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
534 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
535 | end;
|
---|
536 | end;
|
---|
537 | end;
|
---|
538 | end
|
---|
539 | else
|
---|
540 | begin
|
---|
541 | ADevice := Piece(cboDevice.ItemID, ';', 2);
|
---|
542 | aQualifier := Piece(uRemoteType,'^',5);
|
---|
543 | if (Pos('OR_ECS1',FReports)>0) or (Pos('OR_ECS2',FReports)>0) then
|
---|
544 | begin
|
---|
545 | uECSReport.ReportType := 'P';
|
---|
546 | uECSReport.PrintDEV := Piece(cboDevice.ItemID,';',1);
|
---|
547 | PrintECSReportToDevice(uECSReport);
|
---|
548 | end
|
---|
549 | else
|
---|
550 | begin
|
---|
551 | PrintReportsToDevice(FReports, aQualifier + MoreID,
|
---|
552 | Patient.DFN, ADevice, ErrMsg, uHSComponents, RemoteSiteID, RemoteQuery, uHState);
|
---|
553 | ErrMsg := Piece(FReportText.Lines[0], U, 2);
|
---|
554 | if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
|
---|
555 | end;
|
---|
556 | end;
|
---|
557 | end;
|
---|
558 | if chkDefault.Checked then SaveDefaultPrinter(Piece(cboDevice.ItemID, ';', 1));
|
---|
559 | User.CurrentPrinter := cboDevice.ItemID;
|
---|
560 | aReport.Free;
|
---|
561 | Close;
|
---|
562 | end;
|
---|
563 |
|
---|
564 | procedure TfrmReportPrt.cmdCancelClick(Sender: TObject);
|
---|
565 | begin
|
---|
566 | inherited;
|
---|
567 | Close;
|
---|
568 | end;
|
---|
569 |
|
---|
570 | procedure TfrmReportPrt.cboDeviceNeedData(Sender: TObject;
|
---|
571 | const StartFrom: String; Direction, InsertAt: Integer);
|
---|
572 | begin
|
---|
573 | inherited;
|
---|
574 | cboDevice.ForDataUse(SubsetOfDevices(StartFrom, Direction));
|
---|
575 | end;
|
---|
576 |
|
---|
577 | procedure TfrmReportPrt.FormDestroy(Sender: TObject);
|
---|
578 | begin
|
---|
579 | FReportText.Free;
|
---|
580 | inherited;
|
---|
581 | end;
|
---|
582 |
|
---|
583 | end.
|
---|
584 |
|
---|
585 |
|
---|
586 |
|
---|