source: cprs/branches/foia-cprs/CPRS-Chart/Consults/fConsult513Prt.pas@ 1382

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

Adding foia-cprs branch

File size: 5.6 KB
Line 
1unit fConsult513Prt;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 fAutoSz, ORCtrls, StdCtrls, Mask, ORNet, ORFn, ComCtrls;
8
9type
10 Tfrm513Print = class(TfrmAutoSz)
11 grpChooseCopy: TGroupBox;
12 radChartCopy: TRadioButton;
13 radWorkCopy: TRadioButton;
14 grpDevice: TGroupBox;
15 lblMargin: TLabel;
16 lblLength: TLabel;
17 txtRightMargin: TMaskEdit;
18 txtPageLength: TMaskEdit;
19 cmdOK: TButton;
20 cmdCancel: TButton;
21 lblConsultTitle: TMemo;
22 cboDevice: TORComboBox;
23 lblPrintTo: TLabel;
24 dlgWinPrinter: TPrintDialog;
25 chkDefault: TCheckBox;
26 procedure cboDeviceNeedData(Sender: TObject; const StartFrom: String;
27 Direction, InsertAt: Integer);
28 procedure FormCreate(Sender: TObject);
29 procedure cboDeviceChange(Sender: TObject);
30 procedure radChartCopyClick(Sender: TObject);
31 procedure radWorkCopyClick(Sender: TObject);
32 procedure cmdOKClick(Sender: TObject);
33 procedure cmdCancelClick(Sender: TObject);
34 procedure FormDestroy(Sender: TObject);
35 private
36 { Private declarations }
37 FConsult: Integer;
38 FReportText: TRichEdit;
39 procedure DisplaySelectDevice;
40 public
41 { Public declarations }
42 end;
43
44procedure PrintSF513(AConsult: Longint; AConsultTitle: string);
45
46implementation
47
48{$R *.DFM}
49
50uses rCore, rConsults, Printers, rReports, uCore;
51
52const
53 TX_NODEVICE = 'A device must be selected to print, or press ''Cancel'' to not print.';
54 TX_NODEVICE_CAP = 'Device Not Selected';
55 TX_ERR_CAP = 'Print Error';
56 TX_QUEUED_CAP = 'Printing Report' ;
57 PAGE_BREAK = '**PAGE BREAK**';
58
59procedure PrintSF513(AConsult: Longint; AConsultTitle: string);
60{ displays a form that prompts for a device and then prints the SF513 }
61var
62 frm513Print: Tfrm513Print;
63 DefPrt: string;
64begin
65 frm513Print := Tfrm513Print.Create(Application);
66 try
67 ResizeFormToFont(TForm(frm513Print));
68 with frm513Print do
69 begin
70 lblConsultTitle.Text := AConsultTitle;
71 FConsult := AConsult;
72 DefPrt := GetDefaultPrinter(User.Duz, Encounter.Location);
73 if User.CurrentPrinter = '' then User.CurrentPrinter := DefPrt;
74 with cboDevice do
75 begin
76 if Printer.Printers.Count > 0 then
77 begin
78 Items.Add('WIN;Windows Printer^Windows Printer');
79 Items.Add('^--------------------VistA Printers----------------------');
80 end;
81 if User.CurrentPrinter <> '' then
82 begin
83 InitLongList(Piece(User.CurrentPrinter, ';', 2));
84 SelectByID(User.CurrentPrinter);
85 end
86 else
87 InitLongList('');
88 end;
89 if (DefPrt = 'WIN;Windows Printer') and
90 (User.CurrentPrinter = DefPrt) then
91 cmdOKClick(frm513Print)
92 else
93 ShowModal;
94 end;
95 finally
96 frm513Print.Release;
97 end;
98end;
99
100procedure Tfrm513Print.FormCreate(Sender: TObject);
101begin
102 inherited;
103 FReportText := TRichEdit.Create(Self);
104 with FReportText do
105 begin
106 Parent := Self;
107 Visible := False;
108 Width := 600;
109 end;
110end;
111
112procedure Tfrm513Print.DisplaySelectDevice;
113begin
114 with cboDevice, lblPrintTo do
115 begin
116 if radChartCopy.Checked then Caption := 'Print Chart Copy on: ' + Piece(ItemID, ';', 2);
117 if radWorkCopy.Checked then Caption := 'Print Work Copy on: ' + Piece(ItemID, ';', 2);
118 end;
119end;
120
121procedure Tfrm513Print.cboDeviceNeedData(Sender: TObject; const StartFrom: string;
122 Direction, InsertAt: Integer);
123begin
124 inherited;
125 cboDevice.ForDataUse(SubsetOfDevices(StartFrom, Direction));
126end;
127
128procedure Tfrm513Print.cboDeviceChange(Sender: TObject);
129begin
130 inherited;
131 with cboDevice do if ItemIndex > -1 then
132 begin
133 txtRightMargin.Text := Piece(Items[ItemIndex], '^', 4);
134 txtPageLength.Text := Piece(Items[ItemIndex], '^', 5);
135 DisplaySelectDevice;
136 end;
137end;
138
139procedure Tfrm513Print.radChartCopyClick(Sender: TObject);
140begin
141 inherited;
142 DisplaySelectDevice;
143end;
144
145procedure Tfrm513Print.radWorkCopyClick(Sender: TObject);
146begin
147 inherited;
148 DisplaySelectDevice;
149end;
150
151procedure Tfrm513Print.cmdOKClick(Sender: TObject);
152var
153 ADevice, ErrMsg: string;
154 ChartCopy: string;
155 RemoteSiteID: string; //for Remote site printing
156 RemoteQuery: string; //for Remote site printing
157begin
158 inherited;
159 RemoteSiteID := '';
160 RemoteQuery := '';
161 if cboDevice.ItemID = '' then
162 begin
163 InfoBox(TX_NODEVICE, TX_NODEVICE_CAP, MB_OK);
164 Exit;
165 end;
166 if radChartCopy.Checked then ChartCopy := 'C' else ChartCopy := 'W';
167 if Piece(cboDevice.ItemID, ';', 1) = 'WIN' then
168 begin
169 if dlgWinPrinter.Execute then with FReportText do
170 begin
171 FReportText.Lines.Assign(GetFormattedSF513(FConsult, ChartCopy));
172 PrintWindowsReport(FReportText, PAGE_BREAK, Self.Caption, ErrMsg);
173 if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
174 end;
175 end
176 else
177 begin
178 ADevice := Piece(cboDevice.ItemID, ';', 2);
179 PrintSF513ToDevice(FConsult, ADevice, ChartCopy, ErrMsg);
180 ErrMsg := Piece(FReportText.Lines[0], U, 2);
181 if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
182 end;
183 if chkDefault.Checked then SaveDefaultPrinter(Piece(cboDevice.ItemID, ';', 1));
184 User.CurrentPrinter := cboDevice.ItemID;
185 Close;
186end;
187
188procedure Tfrm513Print.cmdCancelClick(Sender: TObject);
189begin
190 inherited;
191 Close;
192end;
193
194procedure Tfrm513Print.FormDestroy(Sender: TObject);
195begin
196 FReportText.Free;
197 inherited;
198end;
199
200end.
Note: See TracBrowser for help on using the repository browser.