source: cprs/branches/tmg-cprs/CPRS-Chart/Consults/fConsult513Prt.pas@ 809

Last change on this file since 809 was 793, checked in by Kevin Toppenberg, 14 years ago

update

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