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

Last change on this file since 611 was 541, checked in by Kevin Toppenberg, 15 years ago

TMG Ver 1.1 Added HTML Support, better demographics editing

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