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