source: cprs/branches/tmg-cprs/CPRS-Chart/fNotePrt.pas@ 462

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 8.3 KB
Line 
1//kt -- Modified with SourceScanner on 8/25/2007
2unit fNotePrt;
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 TfrmNotePrint = 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 lblNoteTitle: 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 private
36 //kt Begin Mod (change Consts to Vars) 8/25/2007
37 TX_NODEVICE : string; //kt
38 TX_NODEVICE_CAP : string; //kt
39 TX_ERR_CAP : string; //kt
40 //kt End Mod -------------------
41 { Private declarations }
42 FNote: Integer;
43 FReportText: TRichEdit;
44 procedure DisplaySelectDevice;
45 procedure SetupVars; //kt
46 public
47 { Public declarations }
48 end;
49
50procedure PrintNote(ANote: Longint; const ANoteTitle: string; MultiNotes: boolean = False);
51
52implementation
53
54{$R *.DFM}
55
56uses rCore, rTIU, rReports, uCore, Printers;
57
58const
59//TX_NODEVICE = 'A device must be selected to print, or press ''Cancel'' to not print.'; <-- original line. //kt 8/25/2007
60//TX_NODEVICE_CAP = 'Device Not Selected'; <-- original line. //kt 8/25/2007
61//TX_ERR_CAP = 'Print Error'; <-- original line. //kt 8/25/2007
62 PAGE_BREAK = '**PAGE BREAK**';
63
64
65
66procedure TfrmNotePrint.SetupVars;
67//kt Added entire function to replace constant declarations 8/25/2007
68begin
69 TX_NODEVICE := DKLangConstW('fNotePrt_A_device_must_be_selected_to_printx_or_press_xxCancelxx_to_not_printx');
70 TX_NODEVICE_CAP := DKLangConstW('fNotePrt_Device_Not_Selected');
71 TX_ERR_CAP := DKLangConstW('fNotePrt_Print_Error');
72end;
73
74procedure PrintNote(ANote: Longint; const ANoteTitle: string; MultiNotes: boolean = False);
75{ displays a form that prompts for a device and then prints the progress note }
76var
77 frmNotePrint: TfrmNotePrint;
78 DefPrt: string;
79begin
80 frmNotePrint := TfrmNotePrint.Create(Application);
81 try
82 ResizeFormToFont(TForm(frmNotePrint));
83 with frmNotePrint do
84 begin
85 { check to see of Chart Print allowed outside of MAS }
86 if AllowChartPrintForNote(ANote) then
87 begin
88 {This next code begs the question: Why are we even bothering to check
89 radWorkCopy if we immediately check the other button?
90 Short answer: it seems to wokr better
91 Long answer: The checkboxes have to in some way register with the group
92 they are in. If this doesn't happen, both will be initially included
93 the tab order. This means that the first time tabbing through the
94 controls, the work copy button would be tabbed to and selected after the
95 chart copy. Tabbing through controls should not change the group
96 selection.
97 }
98 radWorkCopy.Checked := True;
99 radChartCopy.Checked := True;
100 end
101 else
102 begin
103 radChartCopy.Enabled := False;
104 radWorkCopy.Checked := True;
105 end;
106
107 lblNoteTitle.Text := ANoteTitle;
108// frmNotePrint.Caption := 'Print ' + Piece(Piece(ANoteTitle, #9, 2), ',', 1); <-- original line. //kt 8/25/2007
109 frmNotePrint.Caption := DKLangConstW('fNotePrt_Print') + Piece(Piece(ANoteTitle, #9, 2), ',', 1); //kt added 8/25/2007
110 FNote := ANote;
111 DefPrt := GetDefaultPrinter(User.Duz, Encounter.Location);
112
113 if User.CurrentPrinter = '' then User.CurrentPrinter := DefPrt;
114
115 with cboDevice do
116 begin
117 if Printer.Printers.Count > 0 then
118 begin
119// Items.Add('WIN;Windows Printer^Windows Printer'); <-- original line. //kt 8/25/2007
120 Items.Add('WIN;'+DKLangConstW('fNotePrt_Windows_Printer')+'^'+DKLangConstW('fNotePrt_Windows_Printer')); //kt added 8/25/2007
121// Items.Add('^--------------------VistA Printers----------------------'); <-- original line. //kt 8/25/2007
122 Items.Add('^'+DKLangConstW('fNotePrt_xxxxxxxxxxxxxxxxxxxxxVistA_Printersxxxxxxxxxxxxxxxxxxxxxx')); //kt added 8/25/2007
123 end;
124 if User.CurrentPrinter <> '' then
125 begin
126 InitLongList(Piece(User.CurrentPrinter, ';', 2));
127 SelectByID(User.CurrentPrinter);
128 end
129 else
130 InitLongList('');
131 end;
132
133 if ((DefPrt = 'WIN;Windows Printer') and (User.CurrentPrinter = DefPrt)) then
134 cmdOKClick(frmNotePrint) //CQ6660
135 //Commented out for CQ6660
136 //or
137 //((User.CurrentPrinter <> '') and
138 //(MultiNotes = True)) then
139 //frmNotePrint.cmdOKClick(frmNotePrint)
140 //end CQ6660
141 else
142 frmNotePrint.ShowModal;
143 end;
144 finally
145 frmNotePrint.Release;
146 end;
147end;
148
149procedure TfrmNotePrint.FormCreate(Sender: TObject);
150begin
151 inherited;
152 FReportText := TRichEdit.Create(Self);
153 with FReportText do
154 begin
155 Parent := Self;
156 Visible := False;
157 Width := 600;
158 end;
159end;
160
161procedure TfrmNotePrint.DisplaySelectDevice;
162begin
163 with cboDevice, lblPrintTo do
164 begin
165// if radChartCopy.Checked then Caption := 'Print Chart Copy on: ' + Piece(ItemID, ';', 2); <-- original line. //kt 8/25/2007
166 if radChartCopy.Checked then Caption := DKLangConstW('fNotePrt_Print_Chart_Copy_onx') + Piece(ItemID, ';', 2); //kt added 8/25/2007
167// if radWorkCopy.Checked then Caption := 'Print Work Copy on: ' + Piece(ItemID, ';', 2); <-- original line. //kt 8/25/2007
168 if radWorkCopy.Checked then Caption := DKLangConstW('fNotePrt_Print_Work_Copy_onx') + Piece(ItemID, ';', 2); //kt added 8/25/2007
169 end;
170end;
171
172procedure TfrmNotePrint.cboDeviceNeedData(Sender: TObject; const StartFrom: string;
173 Direction, InsertAt: Integer);
174begin
175 inherited;
176 cboDevice.ForDataUse(SubsetOfDevices(StartFrom, Direction));
177end;
178
179procedure TfrmNotePrint.cboDeviceChange(Sender: TObject);
180begin
181 inherited;
182 with cboDevice do if ItemIndex > -1 then
183 begin
184 txtRightMargin.Text := Piece(Items[ItemIndex], '^', 4);
185 txtPageLength.Text := Piece(Items[ItemIndex], '^', 5);
186 DisplaySelectDevice;
187 end;
188end;
189
190procedure TfrmNotePrint.radChartCopyClick(Sender: TObject);
191begin
192 inherited;
193 DisplaySelectDevice;
194end;
195
196procedure TfrmNotePrint.radWorkCopyClick(Sender: TObject);
197begin
198 inherited;
199 DisplaySelectDevice;
200end;
201
202procedure TfrmNotePrint.cmdOKClick(Sender: TObject);
203var
204 ADevice, ErrMsg: string;
205 ChartCopy: Boolean;
206 RemoteSiteID: string; //for Remote site printing
207 RemoteQuery: string; //for Remote site printing
208begin
209 SetupVars; //kt added 8/25/2007 to replace constants with vars.
210 inherited;
211 RemoteSiteID := '';
212 RemoteQuery := '';
213
214 if cboDevice.ItemID = '' then
215 begin
216 InfoBox(TX_NODEVICE, TX_NODEVICE_CAP, MB_OK);
217 Exit;
218 end;
219
220 if radChartCopy.Checked then
221 ChartCopy := True
222 else ChartCopy := False;
223
224
225 if Piece(cboDevice.ItemID, ';', 1) = 'WIN' then
226 begin
227 if dlgWinPrinter.Execute then
228 begin
229 FReportText.Lines.Assign(GetFormattedNote(FNote, ChartCopy));
230 PrintWindowsReport(FReportText, PAGE_BREAK, Self.Caption, ErrMsg);
231 if Length(ErrMsg) > 0 then InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
232 end
233 end
234 else
235 begin
236 ADevice := Piece(cboDevice.ItemID, ';', 2);
237 PrintNoteToDevice(FNote, ADevice, ChartCopy, ErrMsg);
238
239 if Length(ErrMsg) > 0 then
240 InfoBox(ErrMsg, TX_ERR_CAP, MB_OK);
241 end;
242
243 if chkDefault.Checked then
244 SaveDefaultPrinter(Piece(cboDevice.ItemID, ';', 1));
245
246 User.CurrentPrinter := cboDevice.ItemID;
247 Close;
248end;
249
250procedure TfrmNotePrint.cmdCancelClick(Sender: TObject);
251begin
252 inherited;
253 Close;
254end;
255
256end.
Note: See TracBrowser for help on using the repository browser.