source: cprs/trunk/CPRS-Chart/Consults/fODConsult.pas@ 1087

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

Upgrade to version 27

File size: 48.8 KB
RevLine 
[456]1unit fODConsult;
2
3{$O-}
4
5interface
6
7uses
8 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
9 fODBase, StdCtrls, ORCtrls, ExtCtrls, ComCtrls, ORfn, uConst, Buttons,
[829]10 Menus, UBAGlobals, rOrders, fBALocalDiagnoses, UBAConst, UBACore, ORNet,
11 VA508AccessibilityManager ;
[456]12
13type
14 TfrmODCslt = class(TfrmODBase)
15 cboService: TORComboBox;
16 cboUrgency: TORComboBox;
17 cboPlace: TORComboBox;
18 txtProvDiag: TCaptionEdit;
19 txtAttn: TORComboBox;
20 lblService: TLabel;
[829]21 lblUrgency: TLabel;
22 lblPlace: TLabel;
23 lblAttn: TLabel;
24 lblProvDiag: TLabel;
[456]25 treService: TORTreeView;
26 cboCategory: TORComboBox;
27 pnlServiceTreeButton: TKeyClickPanel;
28 btnServiceTree: TSpeedButton;
29 mnuPopProvDx: TPopupMenu;
30 mnuPopProvDxDelete: TMenuItem;
31 cmdLexSearch: TButton;
32 popReason: TPopupMenu;
33 popReasonCut: TMenuItem;
34 popReasonCopy: TMenuItem;
35 popReasonPaste: TMenuItem;
36 popReasonPaste2: TMenuItem;
37 popReasonReformat: TMenuItem;
38 gbInptOpt: TGroupBox;
39 radInpatient: TRadioButton;
40 radOutpatient: TRadioButton;
41 pnlReason: TPanel;
42 lblReason: TLabel;
43 memReason: TRichEdit;
44 btnDiagnosis: TButton;
45 procedure FormCreate(Sender: TObject);
46 procedure txtAttnNeedData(Sender: TObject; const StartFrom: String;
47 Direction, InsertAt: Integer);
48 procedure radInpatientClick(Sender: TObject);
49 procedure radOutpatientClick(Sender: TObject);
50 procedure treServiceChange(Sender: TObject; Node: TTreeNode);
51 procedure ControlChange(Sender: TObject);
52 procedure treServiceExit(Sender: TObject);
53 procedure cmdAcceptClick(Sender: TObject);
54 procedure memReasonExit(Sender: TObject);
55 procedure cboServiceSelect(Sender: TObject);
56 procedure FormDestroy(Sender: TObject);
57 procedure btnServiceTreeClick(Sender: TObject);
58 procedure treServiceCollapsing(Sender: TObject; Node: TTreeNode;
59 var AllowCollapse: Boolean);
60 procedure treServiceMouseDown(Sender: TObject; Button: TMouseButton;
61 Shift: TShiftState; X, Y: Integer);
62 procedure cmdLexSearchClick(Sender: TObject);
63 procedure mnuPopProvDxDeleteClick(Sender: TObject);
64 procedure txtProvDiagChange(Sender: TObject);
65 procedure cboServiceExit(Sender: TObject);
66 procedure popReasonCutClick(Sender: TObject);
67 procedure popReasonCopyClick(Sender: TObject);
68 procedure popReasonPasteClick(Sender: TObject);
69 procedure popReasonPopup(Sender: TObject);
70 procedure popReasonReformatClick(Sender: TObject);
71 procedure pnlServiceTreeButtonEnter(Sender: TObject);
72 procedure pnlServiceTreeButtonExit(Sender: TObject);
73 procedure treServiceKeyDown(Sender: TObject; var Key: Word;
74 Shift: TShiftState);
75 procedure treServiceKeyUp(Sender: TObject; var Key: Word;
76 Shift: TShiftState);
77 procedure memReasonKeyUp(Sender: TObject; var Key: Word;
78 Shift: TShiftState);
79 procedure memReasonKeyDown(Sender: TObject; var Key: Word;
80 Shift: TShiftState);
81 procedure memReasonKeyPress(Sender: TObject; var Key: Char);
82 procedure cboServiceKeyDown(Sender: TObject; var Key: Word;
83 Shift: TShiftState);
84 procedure cboServiceKeyUp(Sender: TObject; var Key: Word;
85 Shift: TShiftState);
86 procedure btnDiagnosisClick(Sender: TObject);
87 procedure cmdQuitClick(Sender: TObject);
88 procedure FormClose(Sender: TObject; var Action: TCloseAction);
[829]89 procedure FormResize(Sender: TObject);
90 procedure treServiceEnter(Sender: TObject);
[456]91
92 private
93 FcboServiceKeyDownStopClick : boolean;
94 FKeyBoarding: boolean;
95 FLastServiceID: string;
96 FEditCtrl: TCustomEdit;
97 FNavigatingTab: boolean;
98 procedure BuildQuickTree(QuickList: TStrings; const Parent: string; Node: TTreeNode);
99 procedure ReadServerVariables;
100 procedure SetProvDiagPromptingMode;
101 procedure SetupReasonForRequest(OrderAction: integer);
102 procedure GetProvDxandValidateCode(AResponses: TResponses);
103 function ShowPrerequisites: boolean;
104 procedure DoSetFontSize(FontSize: integer);
105 procedure SetUpQuickOrderDX;
106 procedure SaveConsultDxForNurse(pDiagnosis: string); // save the dx entered by nurese if Master BA switch is ON
107 procedure SetUpCopyConsultDiagnoses(pOrderID:string);
[829]108 procedure AdjustMemReasonSize;
[456]109 protected
110 procedure InitDialog; override;
111 procedure Validate(var AnErrMsg: string); override;
112 function DefaultReasonForRequest(Service: string; Resolve: Boolean): TStrings;
113
114 public
115 procedure SetupDialog(OrderAction: Integer; const ID: string); override;
116 procedure SetFontSize(FontSize: integer); override;
117 end;
118
119var
120 LastNode: integer ;
121 displayDXCode: string;
122 consultQuickOrder: boolean;
123
124
125implementation
126
127{$R *.DFM}
128
129uses
130 rODBase, rConsults, uCore, uConsults, rCore, fConsults, fPCELex, rPCE, fPreReq,
[829]131 ORClasses, clipbrd, uTemplates, fFrame, uODBase, uVA508CPRSCompatibility;
[456]132
133var
134 SvcList, QuickList, Defaults: TStrings ;
135 ProvDx: TProvisionalDiagnosis;
136 GMRCREAF: string;
137 BADxUpdated: boolean;
138 quickCode: string;
139
140
141
142
143const
144 TX_NOTTHISSVC_TEXT = 'Consults cannot be ordered from this service' ;
145 TX_NO_SVC = 'A service must be specified.' ;
146 TX_NO_REASON = 'A reason for this consult must be entered.' ;
147 TX_SVC_ERROR = 'This service has not been defined in your Orderable Items file.' +
148 #13#10'Contact IRM for assistance.' ;
149 TX_NO_URGENCY = 'An urgency must be specified.';
150 TX_NO_PLACE = 'A place of consultation must be specified';
151 TX_NO_DIAG = 'A provisional diagnosis must be entered for consults to this service.';
152 TX_SELECT_DIAG = 'You must select a diagnosis for consults to this service.';
153 TX_GROUPER = 'This is not an orderable service. Please select a subspecialty';
154 TC_INACTIVE_CODE = 'Inactive ICD Code';
155 TX_INACTIVE_CODE1 = 'The provisional diagnosis code is not active as of today''s date.' + #13#10;
156 TX_INACTIVE_CODE_REQD = 'Another code must be selected before the order can be saved.';
157 TX_INACTIVE_CODE_OPTIONAL = 'If another code is not selected, no code will be saved.';
158
[829]159 TX_SVC_HRCHY = 'services/specialties hierarchy';
160 TX_VIEW_SVC_HRCHY = 'View services/specialties hierarchically';
161 TX_CLOSE_SVC_HRCHY = 'Close services/specialties hierarchy tree view';
162
[456]163procedure TfrmODCslt.FormCreate(Sender: TObject);
164begin
165 frmFrame.pnlVisit.Enabled := false;
166 AutoSizeDisabled := True;
167 inherited;
168 if BILLING_AWARE then
169 begin
170 btnDiagnosis.Visible := True;
171 cmdLexSearch.Visible := False;
172 end
173 else
174 begin
175 btnDiagnosis.Visible := False;
176 cmdLexSearch.Visible := True;
177 end;
178 Defaults := TStringList.Create ;
179 SvcList := TStringList.Create ;
180 QuickList := TStringList.Create ;
181 AllowQuickOrder := True;
182 LastNode := 0;
183 FLastServiceID := '' ;
184 GMRCREAF := '';
185 FillChar(ProvDx, SizeOf(ProvDx), 0);
186 FillerID := 'GMRC'; // does 'on Display' order check **KCM**
187 StatusText('Loading Dialog Definition');
188 Responses.Dialog := 'GMRCOR CONSULT'; // loads formatting info
189 StatusText('Loading Default Values');
[829]190 FastAssign(ODForConsults, Defaults); // ODForConsults returns TStrings with defaults
[456]191 CtrlInits.LoadDefaults(Defaults);
192 txtAttn.InitLongList('') ;
193 PreserveControl(txtAttn);
194 InitDialog;
195 //Calling virtual SetFontSize in constructor is a bad idea!
196 DoSetFontSize( MainFontSize);
197 FcboServiceKeyDownStopClick := false;
198 consultQuickOrder := false;
199
200
201end;
202
203procedure TfrmODCslt.InitDialog;
204begin
205 inherited;
206 Changing := True;
207 FLastServiceID := '';
208 QuickList.Clear;
209 with CtrlInits do
210 begin
211 ExtractItems(QuickList, Defaults, 'ShortList');
212 if OrderForInpatient then //INPATIENT CONSULT
213 begin
214 radInpatient.Checked := True;
215 cboCategory.Items.Clear;
216 cboCategory.Items.Add('I^Inpatient');
217 cboCategory.SelectById('I');
218 SetControl(cboPlace, 'Inpt Place');
219 SetControl(cboUrgency, 'Inpt Cslt Urgencies'); //S.GMRCT
220 end
221 else
222 begin
223 radOutpatient.Checked := True; //OUTPATIENT CONSULT
224 cboCategory.Items.Clear;
225 cboCategory.Items.Add('O^Outpatient');
226 cboCategory.SelectById('O');
227 SetControl(cboPlace, 'Outpt Place');
228 SetControl(cboUrgency, 'Outpt Urgencies'); //S.GMRCO
229 end ;
230 end ;
231 StatusText('Initializing Long List');
232 memOrder.Clear ;
233 memReason.Clear;
234 cboService.Enabled := True;
235 cboService.Font.Color := clWindowText;
236 cboService.Height := 25 + (7 * cboService.ItemHeight);
237 btnServiceTree.Enabled := True;
238 pnlServiceTreeButton.Enabled := True;
239 SetProvDiagPromptingMode;
[829]240 ActiveControl := cboService; // set after call to SetProvDiagPromptingMode
[456]241 Changing := False;
242 StatusText('');
243end;
244
245procedure TfrmODCslt.SetupDialog(OrderAction: Integer; const ID: string);
246const
247 TX_INACTIVE_SVC = 'This consult service is currently inactive and not receiving requests.' + CRLF +
248 'Please contact your Clinical Coordinator/IRM staff to fix this order.';
249 TX_INACTIVE_SVC_CAP = 'Inactive Service';
[829]250 TX_NO_SVC = 'The order or quick order you have selected does not specify a consult service.' + CRLF +
251 'Please contact your Clinical Coordinator/IRM staff to fix this order.';
252 TC_NO_SVC = 'No service specified';
[456]253var
254 i:integer;
255 AList: TStringList;
256 tmpResp: TResponse;
257 SvcIEN: string;
258begin
259 inherited;
260 ReadServerVariables;
261 AList := TStringList.Create;
262 try
263 if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses do
264 begin
265 Changing := True;
266 tmpResp := TResponse(FindResponseByName('ORDERABLE',1));
[829]267 if tmpResp <> nil then
268 SvcIEN := GetServiceIEN(tmpResp.IValue)
269 else
270 begin
271 InfoBox(TX_NO_SVC, TC_NO_SVC, MB_ICONERROR or MB_OK);
272 AbortOrder := True;
273 Close;
274 Exit;
275 end;
[456]276 if SvcIEN = '-1' then
277 begin
278 InfoBox(TX_INACTIVE_SVC, TX_INACTIVE_SVC_CAP, MB_OK);
279 AbortOrder := True;
280 Close;
281 Exit;
282 end;
283 cboService.Items.Add(SvcIEN + U + tmpResp.EValue + '^^^^' + tmpResp.IValue);
284 cboService.SelectByID(SvcIEN);
285 tmpResp := TResponse(FindResponseByName('CLASS',1));
286 cboCategory.SelectByID(tmpResp.IValue);
287 if tmpResp.IValue = 'I' then
288 radInpatient.Checked := True
289 else
290 radOutpatient.Checked := True ;
291 SetControl(cboUrgency, 'URGENCY', 1);
292 SetControl(cboPlace, 'PLACE', 1);
293 SetControl(txtAttn, 'PROVIDER', 1);
294 cboService.Enabled := False;
295 cboService.Font.Color := clGrayText;
296 btnServiceTree.Enabled := False;
297 pnlServiceTreeButton.Enabled := False;
298 if (OrderAction in [ORDER_COPY, ORDER_QUICK]) and (not ShowPrerequisites) then
299 begin
300 Close;
301 Exit;
302 end;
303 SetProvDiagPromptingMode;
304 GetProvDxandValidateCode(Responses);
[829]305 SetTemplateDialogCanceled(FALSE);
[456]306 SetControl(memReason, 'COMMENT', 1);
[829]307 if WasTemplateDialogCanceled then
308 begin
309 AbortOrder := True;
310 Close;
311 Exit;
312 end;
313 SetTemplateDialogCanceled(FALSE);
[456]314 SetupReasonForRequest(OrderAction);
[829]315 if WasTemplateDialogCanceled then
316 begin
317 AbortOrder := True;
318 Close;
319 Exit;
320 end;
[456]321 Changing := False;
322 ControlChange(Self);
323 end
324 else
325 begin
326 if QuickList.Count > 0 then BuildQuickTree(QuickList, '0', nil) ;
[829]327 FastAssign(LoadServiceListWithSynonyms(CN_SVC_LIST_ORD), SvcList); {RV}
328 FastAssign(SvcList, AList);
[456]329 SortByPiece(AList, U, 2);
330 BuildServiceTree(treService, SvcList, '0', nil) ;
331 with treService do
332 begin
333 for i:=0 to Items.Count-1 do
334 if Items[i].Level > 0 then Items[i].Expanded := False else Items[i].Expanded := True;
335 TopItem := Items[LastNode] ;
336 Changing := True;
337 Selected := Items[LastNode] ;
338 Changing := False;
339 SendMessage(Handle, WM_HSCROLL, SB_THUMBTRACK, 0);
340 end ;
341 if QuickList.Count > 0 then with cboService do
342 begin
[829]343 FastAssign(QuickList, cboService.Items);
[456]344 Items.Add(LLS_LINE);
345 Items.Add(LLS_SPACE);
346 end;
347 Changing := True;
348 for i := 0 to AList.Count - 1 do
349 if (cboService.Items.IndexOf(Trim(Piece(AList.Strings[i], U, 2))) = -1) and {RV}
350 //if (cboService.SelectByID(Piece(AList.Strings[i], U, 1)) = -1) and
351 (Piece(AList.Strings[i], U, 5) <> '1') then
352 cboService.Items.Add(AList.Strings[i]);
353 cboService.ItemIndex := 0;
354 Changing := False;
355 if treService.Selected <> nil then
356 begin
357 if (TORTreeNode(treService.Selected).StringData <> '') and
358 (Piece(TORTreeNode(treService.Selected).StringData, U, 5) <> '1') then
359 cboService.ItemIndex := cboService.Items.IndexOf(Trim(Piece(TORTreeNode(treService.Selected).StringData, U, 2)))
360 //cboService.SelectByID(Piece(string(treService.Selected.Data), U, 1))
361 else
362 cboService.ItemIndex := -1;
363 end
364 else
365 cboService.ItemIndex := -1;
366 if cboService.ItemIEN > 0 then
367 begin
368 if not ShowPrerequisites then
369 begin
370 Close;
371 Exit;
372 end;
[829]373 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]374 end;
375 PreserveControl(treService);
376 PreserveControl(cboService);
377 end;
378 finally
379 AList.Free;
380 end;
381end;
382
383procedure TfrmODCslt.Validate(var AnErrMsg: string);
384
385 procedure SetError(const x: string);
386 begin
387 if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
388 AnErrMsg := AnErrMsg + x;
389 end;
390
391begin
392 inherited;
393 if (not ContainsVisibleChar(memReason.Text)) then SetError(TX_NO_REASON);
394 if cboUrgency.ItemIEN = 0 then SetError(TX_NO_URGENCY);
395 if cboPlace.ItemID = '' then SetError(TX_NO_PLACE);
396 if cboService.ItemIEN = 0 then
397 SetError(TX_NO_SVC)
398 else
399 begin
400 if Piece(cboService.Items[cboService.ItemIndex],U,5) = '1' then SetError(TX_NOTTHISSVC_TEXT);
401 if (Piece(cboService.Items[cboService.ItemIndex],U,5) <> '1')
402 and (Piece(cboService.Items[cboService.ItemIndex],U,6) = '')
403 then SetError(TX_SVC_ERROR) ;
404 end;
405 if (ProvDx.Reqd = 'R') and (not ContainsVisibleChar(txtProvDiag.Text)) then
406 begin
407 if ProvDx.PromptMode = 'F' then
408 SetError(TX_NO_DIAG)
409 else
410 SetError(TX_SELECT_DIAG);
411 end;
412end;
413
414procedure TfrmODCslt.txtAttnNeedData(Sender: TObject;
415 const StartFrom: string; Direction, InsertAt: Integer);
416begin
417 inherited;
418 txtAttn.ForDataUse(SubSetOfPersons(StartFrom, Direction));
419end;
420
421procedure TfrmODCslt.radInpatientClick(Sender: TObject);
422begin
423 inherited;
424 with CtrlInits do
425 begin
426 SetControl(cboPlace, 'Inpt Place');
427 SetControl(cboUrgency, 'Inpt Cslt Urgencies');
428 cboCategory.Items.Clear;
429 cboCategory.Items.Add('I^Inpatient') ;
430 cboCategory.SelectById('I');
431 end ;
432 ControlChange(Self);
433end;
434
435procedure TfrmODCslt.radOutpatientClick(Sender: TObject);
436begin
437 inherited;
438 with CtrlInits do
439 begin
440 SetControl(cboPlace, 'Outpt Place');
441 SetControl(cboUrgency, 'Outpt Urgencies');
442 cboCategory.Items.Clear;
443 cboCategory.Items.Add('O^Outpatient');
444 cboCategory.SelectById('O');
445 end ;
446 ControlChange(Self);
447end;
448
449procedure TfrmODCslt.BuildQuickTree(QuickList: TStrings; const Parent: string; Node: TTreeNode);
450var
451 i: Integer;
452 QuickInfo, Name: string ;
453 ANode: TTreeNode;
454begin
455 with QuickList do
456 begin
457 Node := treService.Items.AddChildObject(Node, 'Quick Orders', nil);
458 for i := 0 to Count - 1 do
459 begin
460 Name := Piece(Strings[i], U, 2);
461 QuickInfo := Strings[i];
462 ANode := treService.Items.AddChildObject(Node, Name, Pointer(QuickInfo));
463 TORTreeNode(ANode).StringData := QuickInfo;
464 end;
465 end;
466end;
467
468procedure TfrmODCslt.treServiceChange(Sender: TObject; Node: TTreeNode);
469var
470 i: integer;
471 tmpSvc: string;
472begin
473 inherited;
474 pnlMessage.Visible := False;
475 if Changing or (treService.Selected = nil)
476 or FKeyBoarding or FcboServiceKeyDownStopClick then exit;
477 Changing := True;
478 with cboService do
479 begin
480 if treService.Selected <> nil then
481 begin
482 if (TORTreeNode(treService.Selected).StringData <> '') and
483 (Piece(TORTreeNode(treService.Selected).StringData, U, 5) <> '1') then
484 cboService.ItemIndex := cboService.Items.IndexOf(Trim(Piece(TORTreeNode(treService.Selected).StringData, U, 2)))
485 //cboService.SelectByID(Piece(string(treService.Selected.Data), U, 1))
486 else
487 begin
488 pnlMessage.TabOrder := treService.TabOrder + 1;
489 OrderMessage(TX_GROUPER);
490 cboService.ItemIndex := -1;
491 Changing := False;
492 Exit;
493 end;
494 end
495 else
496 ItemIndex := -1;
497(* if (treService.Selected.Data <> nil) then
498 SelectByID(Piece(string(treService.Selected.Data), U, 1))
499 else
500 ItemIndex := -1;*)
501 Changing := False;
502 if ItemIndex < 0 then exit;
503 if Piece(Items[ItemIndex],U,5) = '1' then
504 begin
505 Responses.Update('ORDERABLE', 1, '', '');
506 memOrder.Clear;
507 cboService.ItemIndex := -1;
508 FLastServiceID := '';
509 Changing := True;
510 treService.Selected := nil;
511 Changing := False;
512 pnlMessage.TabOrder := treService.TabOrder + 1;
513 OrderMessage(TX_GROUPER);
514 Exit;
515 end;
516 treService.Visible := False;
517 memReason.Clear;
518 if ItemID <> FLastServiceID then FLastServiceID := ItemID else Exit;
519 Changing := True;
520 if Sender <> Self then
521 Responses.Clear; // Sender=Self when called from SetupDialog
522 Changing := False;
523 if CharAt(ItemID, 1) = 'Q' then
524 begin
525 Changing := True;
526 consultQuickOrder := True;
527 Responses.QuickOrder := ExtractInteger(ItemID);
528 tmpSvc := TResponse(Responses.FindResponseByName('ORDERABLE',1)).IValue;
529 with treService do for i := 0 to Items.Count-1 do
530 begin
531 if Piece(TORTreeNode(Items[i]).StringData, U, 6) = tmpSvc then
532 begin
533 Selected := Items[i];
534 break;
535 end;
536 end;
537 if treService.Selected <> nil then
538 begin
539 if (TORTreeNode(treService.Selected).StringData <> '') and
540 (Piece(TORTreeNode(treService.Selected).StringData, U, 5) <> '1') then
541 cboService.ItemIndex := cboService.Items.IndexOf(Trim(Piece(TORTreeNode(treService.Selected).StringData, U, 2)))
542 //cboService.SelectByID(Piece(string(treService.Selected.Data), U, 1))
543 else
544 cboService.ItemIndex := -1;
545 end
546 else
547 cboService.ItemIndex := -1;
548 FLastServiceID := ItemID;
549 cboService.Enabled := False;
550 cboService.Font.Color := clGrayText;
551 btnServiceTree.Enabled := False;
552 pnlServiceTreeButton.Enabled := False;
553 Changing := False;
554 end;
555 end;
556 with Responses do if QuickOrder > 0 then
557 begin
558 tmpSvc := TResponse(Responses.FindResponseByName('ORDERABLE',1)).IValue;
559 with treService do for i := 0 to Items.Count-1 do
560 begin
561 if Piece(TORTreeNode(Items[i]).StringData, U, 6) = tmpSvc then
562 begin
563 Selected := Items[i];
564 break;
565 end;
566 end;
567 if treService.Selected <> nil then
568 begin
569 if (TORTreeNode(treService.Selected).StringData <> '') and
570 (Piece(TORTreeNode(treService.Selected).StringData, U, 5) <> '1') then
571 cboService.ItemIndex := cboService.Items.IndexOf(Trim(Piece(TORTreeNode(treService.Selected).StringData, U, 2)))
572 //cboService.SelectByID(Piece(string(treService.Selected.Data), U, 1))
573 else
574 cboService.ItemIndex := -1;
575 end
576 else
577 cboService.ItemIndex := -1;
578 Changing := True;
579 if not ShowPrerequisites then
580 begin
581 Close;
582 Exit;
583 end;
584 SetControl(cboCategory, 'CLASS', 1);
585 if cboCategory.ItemID = 'I' then radInpatient.Checked := True
586 else radOutpatient.Checked := True ;
587 SetControl(cboUrgency, 'URGENCY', 1);
588 SetControl(cboPlace, 'PLACE', 1);
589 SetControl(txtAttn, 'PROVIDER', 1);
[829]590 SetTemplateDialogCanceled(FALSE);
[456]591 SetControl(memReason, 'COMMENT', 1);
[829]592 if WasTemplateDialogCanceled and OrderContainsObjects then
593 begin
594 AbortOrder := TRUE;
595 Close;
596 Exit;
597 end;
[456]598 if ((cboService.ItemIEN > 0) and (Length(memReason.Text) = 0)) then
[829]599 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]600 SetupReasonForRequest(ORDER_QUICK);
601 GetProvDxandValidateCode(Responses);
602 Changing := False;
603 end
604 else
605 begin
606 if cboService.ItemIEN > 0 then
607 begin
608 if not ShowPrerequisites then
609 begin
610 Close;
611 Exit;
612 end;
[829]613 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]614 SetupReasonForRequest(ORDER_NEW);
615 end;
616 end;
617 SetProvDiagPromptingMode;
618 tmpSvc := Piece(cboService.Items[cboService.ItemIndex], U, 6);
619 pnlMessage.TabOrder := treService.TabOrder + 1;
620 OrderMessage(ConsultMessage(StrToIntDef(tmpSvc, 0)));
621 //OrderMessage(ConsultMessage(cboService.ItemIEN));
622 ControlChange(Self) ;
623end;
624
625procedure TfrmODCslt.ControlChange(Sender: TObject);
626var
627 x: string;
628 i: integer;
629begin
630 inherited;
631 if Changing or (cboService.ItemIEN = 0) then Exit;
632 with cboService do
633 begin
634 if (ItemIEN > 0) and (Piece(Items[ItemIndex], U, 5) <> '1') then
635 begin
636 i := Pos('<', Text);
637 if i > 0 then
638 begin
639 x := Piece(Copy(Text, i + 1, 99), '>', 1);
640 x := UpperCase(Copy(x, 1, 1)) + Copy(x, 2, 99);
641 end
642 else
643 x := Text;
644 Responses.Update('ORDERABLE', 1, Piece(Items[ItemIndex], U, 6), x);
645 end
646 else Responses.Update('ORDERABLE', 1, '', '');
647 end;
648 with memReason do if GetTextLen > 0 then Responses.Update('COMMENT', 1, TX_WPTYPE, Text);
649 with cboCategory do if ItemID <> '' then Responses.Update('CLASS', 1, ItemID, Text);
650 with cboUrgency do if ItemIEN > 0 then Responses.Update('URGENCY', 1, ItemID, Text);
651 with cboPlace do if ItemID <> '' then Responses.Update('PLACE', 1, ItemID, Text);
652 with txtAttn do if ItemIEN > 0 then Responses.Update('PROVIDER', 1, ItemID, Text);
653 //with txtProvDiag do if Length(Text) > 0 then Responses.Update('MISC', 1, Text, Text);
654 if Length(ProvDx.Text) > 0 then Responses.Update('MISC', 1, ProvDx.Text, ProvDx.Text)
655 else Responses.Update('MISC', 1, '', '');
656 if Length(ProvDx.Code) > 0 then Responses.Update('CODE', 1, ProvDx.Code, ProvDx.Code)
657 else Responses.Update('CODE', 1, '', '');
658
659 memOrder.Text := Responses.OrderText;
660end;
661
[829]662procedure TfrmODCslt.treServiceEnter(Sender: TObject);
663begin
664 inherited;
665 cmdQuit.Cancel := FALSE;
666end;
667
[456]668procedure TfrmODCslt.treServiceExit(Sender: TObject);
669begin
670 inherited;
[829]671 cmdQuit.Cancel := TRUE;
[456]672 with cboService do
673 begin
674 if ItemIEN > 0 then
675 begin
676 pnlMessage.TabOrder := treService.TabOrder + 1;
677 OrderMessage(ConsultMessage(StrToInt(Piece(Items[ItemIndex],U,6))));
678 end;
679 end;
680end;
681
682procedure TfrmODCslt.SetUpQuickOrderDX;
683// this procedure is called if the user selects a quick code from the list
684// and accepts the order without entering or selection the diagnoses button.
685begin
686 quickCode := ProvDx.Code;
687 if UBACore.IsICD9CodeActive(quickCode,'ICD',0) then
688 begin
689 uBAGlobals.BAConsultDxList.Clear;
690 uBAGlobals.BAConsultDxList.Add(UBAConst.PRIMARY_DX + U + ProvDx.Text + ':' + quickCode);
691 end;
692
693end;
694
695procedure TfrmODCslt.cmdAcceptClick(Sender: TObject);
696var
697 BADiagnosis: string;
698 begin
699 inherited;
700 if treService.Selected <> nil then
701 LastNode := treService.Selected.AbsoluteIndex;
702
703 if BILLING_AWARE and CIDCOkToSave then
704 begin
705 if btnDiagnosis.Enabled then
706 if consultQuickOrder then SetUpQuickOrderDX;
707 if UBAGlobals.BAConsultDxList.Count > 0 then
708 begin
709 uBACore.CompleteConsultOrderRec(uBAGlobals.BAOrderID,UBAGlobals.BAConsultDxList);
710 uBAGlobals.BAConsultDxList.Clear;
711 end;
712 BADiagnosis := ProvDx.Text + '^' + ProvDx.Code;
713 end;
714
715 if NOT BILLING_AWARE then
716 begin
717 // this will save a dx entered by a nurse to be reviewed by a provided.
718 // this is active if CIDC MASTER SWITCH is ON.
719 if rpcGetBAMasterSwStatus then // BA master sw is on.
720 if (uCore.User.OrderRole = OR_NURSE) then // user is a nurse
721 begin
722 if ProvDx.Text <> '' then // consult dx has been selected
723 begin
724 SaveConsultDxForNurse(ProvDx.Text + ProvDx.Code); // save selected dx, will be displayed to Provider
725 end;
726 end;
727 end;
728end;
729
730procedure TfrmODCslt.memReasonExit(Sender: TObject);
731var
732 AStringList: TStringList;
733begin
734 inherited;
735 AStringList := TStringList.Create;
736 try
[829]737 //QuickCopy(memReason, AStringList);
738 AStringList.Text := memReason.Text;
[456]739 LimitStringLength(AStringList, 74);
[829]740 //QuickCopy(AstringList, memReason);
741 memReason.Text := AStringList.Text;
[456]742 ControlChange(Self);
743 finally
744 AStringList.Free;
745 end;
746end;
747
748procedure TfrmODCslt.cboServiceSelect(Sender: TObject);
749var
750 tmpSvc: string;
751begin
752 if FcboServiceKeyDownStopClick then
753 begin
754 Exit; //This fixes clearquest: HDS00001418
755 FcboServiceKeyDownStopClick := false;
756 end;
757 memReason.Clear;
758 with cboService do
759 begin
760 if (ItemIndex < 0) or (ItemID = '') then
761 begin
762 Responses.Update('ORDERABLE', 1, '', '');
763 memOrder.Clear;
764 FLastServiceID := '';
765 exit;
766 end;
767 if Piece(Items[ItemIndex],U,5) = '1' then
768 begin
769 Responses.Update('ORDERABLE', 1, '', '');
770 memOrder.Clear;
771 FLastServiceID := '';
772 pnlMessage.TabOrder := cboService.TabOrder + 1;
773 OrderMessage(TX_GROUPER);
774 Exit;
775 end;
776 FLastServiceID := ItemID;
777 if CharAt(ItemID, 1) = 'Q' then
778 begin
779 Changing := True;
780 Responses.QuickOrder := ExtractInteger(ItemID);
781 consultQuickOrder := True;
782 tmpSvc := TResponse(Responses.FindResponseByName('ORDERABLE',1)).EValue;
783 ItemIndex := Items.IndexOf(Trim(tmpSvc));
784(* tmpSvc := TResponse(Responses.FindResponseByName('ORDERABLE',1)).IValue;
785 for i := 0 to Items.Count-1 do
786 begin
787 if Piece(Items[i],U,6) = tmpSvc then
788 begin
789 ItemIndex := i;
790 break;
791 end;
792 end;*)
793 FLastServiceID := ItemID;
794 Enabled := False;
795 Font.Color := clGrayText;
796 btnServiceTree.Enabled := False;
797 pnlServiceTreeButton.Enabled := False;
798 Changing := False;
799 with Responses do if QuickOrder > 0 then
800 begin
801 Changing := True;
802 if not ShowPrerequisites then
803 begin
804 Close;
805 Exit;
806 end;
807 SetControl(cboCategory, 'CLASS', 1);
808 if cboCategory.ItemID = 'I' then radInpatient.Checked := True
809 else radOutpatient.Checked := True ;
810 SetControl(cboUrgency, 'URGENCY', 1);
811 SetControl(cboPlace, 'PLACE', 1);
812 SetControl(txtAttn, 'PROVIDER', 1);
[829]813 SetTemplateDialogCanceled(FALSE);
[456]814 SetControl(memReason, 'COMMENT', 1);
[829]815 if WasTemplateDialogCanceled and OrderContainsObjects then
816 begin
817 AbortOrder := TRUE;
818 Close;
819 Exit;
820 end;
[456]821// if ((cboService.ItemIEN > 0) and (Length(memReason.Text) = 0)) then
[829]822// QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]823 SetupReasonForRequest(ORDER_QUICK);
824 GetProvDxandValidateCode(Responses);
825 Changing := False;
826 end
827 else
828 begin
829 if cboService.ItemIEN > 0 then
830 begin
831 Changing := True;
832 if not ShowPrerequisites then
833 begin
834 Close;
835 Exit;
836 end;
[829]837 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]838 SetupReasonForRequest(ORDER_NEW);
839 Changing := False;
840 end;
841 end;
842 end
843 else
844 begin
845 Changing := True;
846 if not ShowPrerequisites then
847 begin
848 Close;
849 Exit;
850 end;
851 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
852 SetupReasonForRequest(ORDER_NEW);
853 Changing := False;
854 end;
855 end;
856 treService.Visible := False;
857 SetProvDiagPromptingMode;
858 tmpSvc := Piece(cboService.Items[cboService.ItemIndex], U, 6);
859 pnlMessage.TabOrder := cboService.TabOrder + 1;
860 OrderMessage(ConsultMessage(StrToIntDef(tmpSvc, 0)));
861 //OrderMessage(ConsultMessage(cboService.ItemIEN));
862 ControlChange(Self) ;
863end;
864
865procedure TfrmODCslt.FormDestroy(Sender: TObject);
866begin
867 Defaults.Free;
868 SvcList.Free ;
869 QuickList.Free;
870 inherited;
871end;
872
873procedure TfrmODCslt.btnServiceTreeClick(Sender: TObject);
874var
875 i: integer;
876begin
877 inherited;
878 Changing := True;
879 treService.Visible := not treService.Visible;
880 if treService.Visible then
881 begin
[829]882 // for some reason screen reader is reading caption when tree view is not visible
883 treService.Caption := TX_SVC_HRCHY;
884 pnlServiceTreeButton.Caption := TX_CLOSE_SVC_HRCHY;
885 btnServiceTree.Hint := TX_CLOSE_SVC_HRCHY;
[456]886 treService.SetFocus;
887 with treService do for i := 0 to Items.Count-1 do
888 begin
889 if Piece(TORTreeNode(Items[i]).StringData, U, 1) = cboService.ItemID then
890 begin
891 Selected := Items[i];
892 if Piece(TORTreeNode(Items[i]).StringData, U, 5) = '1' then Selected.Expand(True);
893 break;
894 end;
895 end;
[829]896 end
897 else
898 begin
899 treService.Caption := '';
900 pnlServiceTreeButton.Caption := TX_VIEW_SVC_HRCHY;
901 btnServiceTree.Hint := TX_VIEW_SVC_HRCHY;
902 pnlServiceTreeButton.SetFocus;
[456]903 end;
904 Changing := False;
905end;
906
907procedure TfrmODCslt.ReadServerVariables;
908begin
909 if StrToIntDef(KeyVariable['GMRCNOAT'], 0) > 0 then
910 begin
911 txtAttn.Enabled := False;
912 txtAttn.Font.Color := clGrayText;
913 lblAttn.Enabled := False;
914 txtAttn.Color := clBtnFace;
915 end
916 else
917 begin
918 txtAttn.Enabled := True;
919 txtAttn.Font.Color := clWindowText;
920 lblAttn.Enabled := True;
921 txtAttn.Color := clWindow;
922 end;
923
924 if StrToIntDef(KeyVariable['GMRCNOPD'], 0) > 0 then
925 begin
926 if BILLING_AWARE then
927 btnDiagnosis.Enabled := False //1.4.18
928 else
929 cmdLexSearch.Enabled := False;
930 txtProvDiag.Enabled := False;
931 txtProvDiag.Font.Color := clGrayText;
932 txtProvDiag.ReadOnly := True;
933 txtProvDiag.Color := clBtnFace;
934 end
935 else SetProvDiagPromptingMode;
936
937 GMRCREAF := KeyVariable['GMRCREAF'];
938end;
939
940procedure TfrmODCslt.treServiceCollapsing(Sender: TObject; Node: TTreeNode;
941 var AllowCollapse: Boolean);
942begin
943 inherited;
944 Changing := True;
945 treService.Selected := nil;
946 Changing := False;
947 AllowCollapse := True;
948end;
949
950procedure TfrmODCslt.treServiceMouseDown(Sender: TObject;
951 Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
952var
953 tmpNode: TORTreeNode;
954 NodeRect: TRect;
955begin
956 inherited;
957 if Button <> mbLeft then exit;
958 tmpNode := TORTreeNode(treService.GetNodeAt(X, Y));
959 if tmpNode = nil then exit;
960 NodeRect := tmpNode.DisplayRect(True);
961 if treService.Selected <> nil then
962 if (X >= NodeRect.Left) then // user clicked in the text of the item, not on the bitmap
963 begin
964 if tmpNode.StringData <> '' then
965 if (Piece(tmpNode.StringData, U, 5) <> '1') then
966 treService.Visible := False;
967 end;
968end;
969
970procedure TfrmODCslt.cmdLexSearchClick(Sender: TObject);
971var
972 Match: string;
973 i: integer;
974begin
975 inherited;
976
977 if BILLING_AWARE then BADxUpdated := FALSE;
978
979 LexiconLookup(Match, LX_ICD);
980 if Match = '' then Exit;
981 ProvDx.Code := Piece(Match, U, 1);
982 ProvDx.Text := Piece(Match, U, 2);
983 i := Pos(' (ICD', ProvDx.Text);
984 if i = 0 then i := Length(ProvDx.Text) + 1;
985 if ProvDx.Text[i-1] = '*' then i := i - 2;
986 ProvDx.Text := Copy(ProvDx.Text, 1, i - 1);
987 txtProvDiag.Text := ProvDx.Text + ' (' + ProvDx.Code + ')';
988
989 ProvDx.CodeInactive := False;
990end;
991
992procedure TfrmODCslt.SetProvDiagPromptingMode;
993const
994 TX_USE_LEXICON = 'You must use the "Lexicon" button to select a provisional diagnosis for this service.';
995 TX_USE_DIAGNOSIS = 'You must use the "Diagnosis" button to select a diagnosis for this service.';
996
997 TX_PROVDX_OPT = 'Provisional Diagnosis';
998 TX_PROVDX_REQD = 'Provisional Dx (REQUIRED)';
999begin
1000 if BILLING_AWARE then
1001 btnDiagnosis.Enabled := False //1.4.18
1002 else
1003 cmdLexSearch.Enabled := False;
1004 txtProvDiag.Enabled := False;
1005 txtProvDiag.ReadOnly := True;
1006 txtProvDiag.Color := clBtnFace;
1007 txtProvDiag.Font.Color := clBtnText;
1008 txtProvDiag.Hint := '';
1009 if cboService.ItemIEN = 0 then Exit;
1010 GetProvDxMode(ProvDx, cboService.ItemID + CSLT_PTR);
1011 // Returns: string A^B
1012 // A = O (optional), R (required) or S (suppress)
1013 // B = F (free-text) or L (lexicon)
1014 with ProvDx do if (Reqd = '') or (PromptMode = '') then Exit;
1015 if ProvDx.Reqd = 'R' then
1016 begin
1017 lblProvDiag.Caption := TX_PROVDX_REQD;
1018 if (BILLING_AWARE) and (ProvDx.PromptMode[1] = '') then btnDiagnosis.Enabled := True;
1019 end
1020 else
1021 lblProvDiag.Caption := TX_PROVDX_OPT;
1022 if ProvDx.Reqd = 'S' then
1023 begin
1024 cmdLexSearch.Enabled := False;
1025 txtProvDiag.Enabled := False;
1026 txtProvDiag.ReadOnly := True;
1027 txtProvDiag.Color := clBtnFace;
1028 txtProvDiag.Font.Color := clBtnText;
1029 end
1030 else
1031 case ProvDx.PromptMode[1] of
1032 'F': begin
1033 cmdLexSearch.Enabled := False;
1034 txtProvDiag.Enabled := True;
1035 txtProvDiag.ReadOnly := False;
1036 txtProvDiag.Color := clWindow;
1037 txtProvDiag.Font.Color := clWindowText;
1038 end;
1039 'L': begin
1040 if BILLING_AWARE then
1041 begin
1042 btnDiagnosis.Enabled := True; //1.4.18
1043 txtProvDiag.Hint := TX_USE_DIAGNOSIS;
1044 end
1045 else
1046 begin
1047 cmdLexSearch.Enabled := True;
1048 txtProvDiag.Hint := TX_USE_LEXICON;
1049 end;
1050 txtProvDiag.Enabled := True;
1051 txtProvDiag.ReadOnly := True;
1052 txtProvDiag.Color := clInfoBk;
1053 txtProvDiag.Font.Color := clInfoText;
1054 end;
1055 end;
1056end;
1057
1058
1059procedure TfrmODCslt.mnuPopProvDxDeleteClick(Sender: TObject);
1060begin
1061 inherited;
1062 ProvDx.Text := '';
1063 ProvDx.Code := '';
1064 txtProvDiag.Text := '';
1065 ControlChange(Self);
1066end;
1067
1068procedure TfrmODCslt.txtProvDiagChange(Sender: TObject);
1069begin
1070 inherited;
1071 if ProvDx.PromptMode = 'F' then
1072 begin
1073 ProvDx.Text := txtProvDiag.Text;
1074 displayDxCode := ProvDx.Text;
1075 end;
1076 ControlChange(Self);
1077end;
1078
1079procedure TfrmODCslt.SetupReasonForRequest(OrderAction: integer);
1080var
1081 EditReason: string;
1082
1083 procedure EnableReason;
1084 begin
1085 memReason.Color := clWindow;
1086 memReason.Font.Color := clWindowText;
1087 memReason.ReadOnly := False;
1088 lblReason.Caption := 'Reason for Request';
1089 end;
1090
1091 procedure DisableReason;
1092 begin
1093 memReason.Color := clInfoBk;
1094 memReason.Font.Color := clInfoText;
1095 memReason.ReadOnly := True;
1096 lblReason.Caption := 'Reason for Request (not editable)';
1097 end;
1098
1099begin
1100 if ((OrderAction = ORDER_QUICK) and (cboService.ItemID <> '') and (Length(memReason.Text) = 0)) then
[829]1101 QuickCopy(DefaultReasonForRequest(cboService.ItemID, True), memReason);
[456]1102 EditReason := GMRCREAF;
1103 if EditReason = '' then EditReason := ReasonForRequestEditable(cboService.ItemID + CSLT_PTR);
1104 case EditReason[1] of
1105 '0': EnableReason;
1106 '1': if OrderAction in [ORDER_COPY, ORDER_EDIT] then
1107 EnableReason
1108 else
1109 DisableReason;
1110 '2': DisableReason
1111 else
1112 EnableReason;
1113 end;
1114end;
1115
1116function TfrmODCslt.ShowPrerequisites: boolean;
1117var
1118 AList: TStringList;
1119const
1120 TC_PREREQUISITES = 'Service Prerequisites - ';
1121begin
1122 Result := True;
1123 AbortOrder := False;
1124 AList := TStringList.Create;
1125 try
1126 with cboService do
1127 if ItemIEN > 0 then
1128 begin
[829]1129 FastAssign(GetServicePrerequisites(ItemID + CSLT_PTR), Alist);
[456]1130 if AList.Count > 0 then
1131 begin
1132 if not DisplayPrerequisites(AList, TC_PREREQUISITES + DisplayText[ItemIndex]) then
1133 begin
1134 memOrder.Clear;
1135 Result := False;
1136 AbortOrder := True;
1137 end
1138 else Result := True;
1139 end;
1140 end;
1141 finally
1142 AList.Free;
1143 end;
1144end;
1145
1146procedure TfrmODCslt.cboServiceExit(Sender: TObject);
1147begin
1148 inherited;
1149 if Length(memOrder.Text) = 0 then Exit;
1150 if (Length(cboService.ItemID) = 0) or (cboService.ItemID = '0') then Exit;
1151 if cboService.ItemID = FLastServiceID then Exit;
1152 cboServiceSelect(cboService);
1153 // CQ #7490, following line commented out v26.24 (RV)
1154 // CQ #9610 and 10074 - uncommented and "if" added v26.54 (RV)
1155 if cboService.Enabled then cboService.SetFocus;
1156 PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
1157end;
1158
1159procedure TfrmODCslt.popReasonPopup(Sender: TObject);
1160begin
1161 inherited;
1162 if PopupComponent(Sender, popReason) is TCustomEdit
1163 then FEditCtrl := TCustomEdit(PopupComponent(Sender, popReason))
1164 else FEditCtrl := nil;
1165 if FEditCtrl <> nil then
1166 begin
1167 popReasonCut.Enabled := FEditCtrl.SelLength > 0;
1168 popReasonCopy.Enabled := popReasonCut.Enabled;
1169 popReasonPaste.Enabled := (not TORExposedCustomEdit(FEditCtrl).ReadOnly) and
1170 Clipboard.HasFormat(CF_TEXT);
1171 end else
1172 begin
1173 popReasonCut.Enabled := False;
1174 popReasonCopy.Enabled := False;
1175 popReasonPaste.Enabled := False;
1176 end;
1177 popReasonReformat.Enabled := True;
1178end;
1179
1180procedure TfrmODCslt.popReasonCutClick(Sender: TObject);
1181begin
1182 inherited;
1183 FEditCtrl.CutToClipboard;
1184end;
1185
1186procedure TfrmODCslt.popReasonCopyClick(Sender: TObject);
1187begin
1188 inherited;
1189 FEditCtrl.CopyToClipboard;
1190end;
1191
1192procedure TfrmODCslt.popReasonPasteClick(Sender: TObject);
1193begin
1194 inherited;
1195 FEditCtrl.SelText := Clipboard.AsText;
1196end;
1197
1198procedure TfrmODCslt.popReasonReformatClick(Sender: TObject);
1199begin
1200 inherited;
1201 if Screen.ActiveControl <> memReason then Exit;
1202 ReformatMemoParagraph(memReason);
1203end;
1204
1205function TfrmODCslt.DefaultReasonForRequest(Service: string;
1206 Resolve: Boolean): TStrings;
1207var
1208 TmpSL: TStringList;
1209 DocInfo: string;
1210 x: string;
1211 HasObjects: boolean;
1212begin
1213 Resolve := FALSE ; // override value passed in - resolve on client - PSI-05-093
1214 DocInfo := '';
1215 TmpSL := TStringList.Create;
1216 try
1217 Result := GetDefaultReasonForRequest(Service + CSLT_PTR, Resolve);
[829]1218 FastAssign(Result, TmpSL);
[456]1219 x := TmpSL.Text;
1220 ExpandOrderObjects(x, HasObjects);
1221 TmpSL.Text := x;
1222 Responses.OrderContainsObjects := HasObjects;
1223 ExecuteTemplateOrBoilerPlate(TmpSL, cboService.ItemIEN , ltConsult, nil, 'Reason for Request: ' + cboService.DisplayText[cboService.ItemIndex], DocInfo);
[829]1224 AbortOrder := WasTemplateDialogCanceled;
1225 Responses.OrderContainsObjects := HasObjects or TemplateBPHasObjects;
1226 if AbortOrder then
1227 begin
1228 Result.Text := '';
1229 Close;
1230 Exit;
1231 end
1232 else
1233 FastAssignWith508Msg(TmpSL, Result);
[456]1234 finally
1235 TmpSL.Free;
1236 end;
1237end;
1238
1239procedure TfrmODCslt.pnlServiceTreeButtonEnter(Sender: TObject);
1240begin
1241 inherited;
1242 (Sender as TPanel).BevelOuter := bvRaised;
1243end;
1244
1245procedure TfrmODCslt.pnlServiceTreeButtonExit(Sender: TObject);
1246begin
1247 inherited;
1248 (Sender as TPanel).BevelOuter := bvNone;
1249end;
1250
1251procedure TfrmODCslt.treServiceKeyDown(Sender: TObject; var Key: Word;
1252 Shift: TShiftState);
1253begin
1254 inherited;
1255 case Key of
1256 VK_SPACE, VK_RETURN:
1257 begin
1258 Key := 0;
1259 FKeyBoarding := False;
1260 treServiceChange(Sender, treService.Selected);
1261 end;
[829]1262 VK_ESCAPE:
1263 begin
1264 key := 0;
1265 btnServiceTreeClick(Self);
1266 end
[456]1267 else
1268 FKeyBoarding := True;
1269 end;
1270end;
1271
1272procedure TfrmODCslt.treServiceKeyUp(Sender: TObject; var Key: Word;
1273 Shift: TShiftState);
1274begin
1275 inherited;
1276 FKeyBoarding := False;
1277end;
1278
1279procedure TfrmODCslt.DoSetFontSize(FontSize: integer);
1280begin
1281 memReason.DefAttributes.Size := FontSize;
1282 treService.Font.Size := FontSize * 7 div 8;
1283end;
1284
1285procedure TfrmODCslt.SetFontSize(FontSize: integer);
1286begin
1287 inherited SetFontSize(FontSize);
1288 DoSetFontSize(FontSize);
1289end;
1290
1291procedure TfrmODCslt.memReasonKeyUp(Sender: TObject; var Key: Word;
1292 Shift: TShiftState);
1293begin
1294 inherited;
1295 if FNavigatingTab then
1296 begin
1297 if ssShift in Shift then
1298 FindNextControl(Sender as TWinControl, False, True, False).SetFocus //previous control
1299 else if ssCtrl in Shift then
1300 FindNextControl(Sender as TWinControl, True, True, False).SetFocus; //next control
1301 FNavigatingTab := False;
1302 end;
1303 if (key = VK_ESCAPE) then begin
1304 FindNextControl(Sender as TWinControl, False, True, False).SetFocus; //previous control
1305 key := 0;
1306 end;
1307end;
1308
1309procedure TfrmODCslt.GetProvDxandValidateCode(AResponses: TResponses);
1310var
1311 tmpDx: TResponse;
1312
1313begin
1314 with AResponses do
1315 begin
1316 tmpDx := TResponse(FindResponseByName('MISC',1));
1317 if tmpDx <> nil then ProvDx.Text := tmpDx.Evalue;
1318 tmpDx := TResponse(FindResponseByName('CODE',1));
1319 sourceOrderID := Responses.CopyOrder;
1320 if (tmpDx <> nil) and (tmpDx.EValue <> '') then
1321 begin
1322 if IsActiveICDCode(tmpDx.EValue) then
1323 ProvDx.Code := tmpDx.Evalue
1324 else
1325 begin
1326 if ProvDx.Reqd = 'R' then
1327 InfoBox(TX_INACTIVE_CODE1 + TX_INACTIVE_CODE_REQD, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK)
1328 else
1329 InfoBox(TX_INACTIVE_CODE1 + TX_INACTIVE_CODE_OPTIONAL, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK);
1330 ProvDx.Code := '';
1331 ProvDx.Text := '';
1332 end;
1333 end;
1334 txtProvDiag.Text := ProvDx.Text;
1335 if ProvDx.Code <> '' then
1336 txtProvDiag.Text := (txtProvDiag.Text + ' (' + ProvDx.Code + ')' )
1337 else
1338 begin
1339 if BILLING_AWARE then
1340 if (sourceOrderID <> '') and (ProvDx.Code <> '') then // if sourceid exists then user is copying an order.
1341 SetUpCopyConsultDiagnoses(sourceOrderID);
1342
1343 end;
1344
1345 end;
1346end;
1347
1348procedure TfrmODCslt.memReasonKeyDown(Sender: TObject; var Key: Word;
1349 Shift: TShiftState);
1350begin
1351 inherited;
1352 //The navigating tab controls were inadvertantently adding tab characters
1353 //This should fix it
1354 FNavigatingTab := (Key = VK_TAB) and ([ssShift,ssCtrl] * Shift <> []);
1355 if FNavigatingTab then
1356 Key := 0;
1357end;
1358
1359procedure TfrmODCslt.memReasonKeyPress(Sender: TObject; var Key: Char);
1360begin
1361 inherited;
1362 if FNavigatingTab then
1363 Key := #0; //Disable shift-tab processing
1364end;
1365
1366procedure TfrmODCslt.cboServiceKeyDown(Sender: TObject; var Key: Word;
1367 Shift: TShiftState);
1368begin
1369 inherited;
1370 //This fixes clearquest: HDS00001418 Makes it so OnClick is not called
1371 //Except when Enter or Space is pressed. VK_LBUTTON activates OnClick in TORComboBoxes
1372 FcboServiceKeyDownStopClick := false;
1373 if (Key <> VK_RETURN) {and (Key <> VK_SPACE)} and (Key <> VK_LBUTTON) then //comment on this line is fix for CQ6789
1374 FcboServiceKeyDownStopClick := True
1375 else
1376 Key := VK_LBUTTON;
1377end;
1378
1379procedure TfrmODCslt.cboServiceKeyUp(Sender: TObject; var Key: Word;
1380 Shift: TShiftState);
1381begin
1382 inherited;
1383 FcboServiceKeyDownStopClick := false;
1384end;
1385
1386
1387procedure TfrmODCslt.btnDiagnosisClick(Sender: TObject);
1388var
1389 leftParan, rightParan: string;
1390 tmpOrderIDList: TStringList;
1391begin
1392 inherited;
1393 tmpOrderIDList := TStringList.Create;
1394 tmpOrderIDList.Clear;
1395 leftParan := '(';
1396 rightParan := ')';
1397 UBAGlobals.BAtmpOrderList.Clear;
1398 UBAGlobals.BAtmpOrderList.Add(Responses.OrderText);
1399 quickCode := '';
1400 if consultQuickOrder then
1401 begin
1402 quickCode := Piece(txtProvDiag.text,'(',2);
1403 quickCode := Piece(quickCode,')',1);
1404 if UBACore.IsICD9CodeActive(quickCode,'ICD',0) then
1405 begin
1406 uBAGlobals.BAConsultDxList.Clear;
1407 uBAGlobals.BAConsultDxList.Add(UBAConst.PRIMARY_DX + U + Piece(txtProvDiag.text,'(',1) + ':' + quickCode);
1408 end;
1409
1410 end;
1411 frmBALocalDiagnoses.Enter(UBAConst.F_CONSULTS, nil);
1412 if displayDxCode = '' then txtProvDiag.Text := ''
1413 else
1414 begin
1415 if displayDxCode <> 'DXCANCEL' then
1416 begin
1417 ProvDx.Code := Piece(displayDxCode,':', 2);
1418 ProvDx.Text := Piece(displayDxCode,':', 1);
1419 txtProvDiag.Text := ProvDx.Text + ' (' + ProvDx.Code + ')';
1420 end;
1421 end;
1422
1423 ProvDx.CodeInactive := False;
1424end;
1425
1426procedure TfrmODCslt.cmdQuitClick(Sender: TObject);
1427begin
1428 inherited;
1429 if BILLING_AWARE then uBAGlobals.BAConsultDxList.Clear;
1430end;
1431
1432procedure TfrmODCslt.SaveConsultDxForNurse(pDiagnosis: string);
1433var
1434 s,tmpTFactors: string;
1435 tmpList: TStringList;
1436begin
1437 tmpList := TStringList.Create;
1438 tmpList.Clear;
1439 s := '';
1440 tmpList.Add(uBAGlobals.BAOrderID);
1441 s := GetPatientTFactors(tmpList);
1442 tmpTFactors := ConvertPIMTreatmentFactors(s);
1443 BANurseConsultOrders.Add(uBAGlobals.BAOrderID + '1' + tmpTFactors + U + ProvDX.Code);
1444end;
1445
1446procedure TfrmODCslt.SetUpCopyConsultDiagnoses(pOrderID:string);
1447var
1448 sourceOrderID, primaryText,primaryCode: string;
1449 sourceOrderList: TStringList;
1450 thisOrderList: TStringList;
1451begin
1452//logic handles setting up diagnoses when copying an order.
1453 sourceOrderList := TStringList.Create;
1454 sourceOrderList.Clear;
1455 thisOrderList := TStringList.Create;
1456 thisOrderList.Clear;
1457 if IsOrderBillable(sourceOrderID) then
1458 begin
1459 thisOrderList.Add(sourceOrderID);
1460 sourceOrderList := rpcRetrieveSelectedOrderInfo(thisOrderList);
1461 primaryText := Piece(sourceOrderList.Strings[0],U,4);
1462 primaryCode := Piece(sourceOrderList.Strings[0],U,3);
1463 txtProvDiag.Text := primaryText + ' (' + primaryCode + ')';
1464 ProvDx.CodeInactive := False;
1465 // need to handle the rest of the dx's
1466 uBAGlobals.BAConsultDxList.Clear;
1467 uBAGlobals.BAConsultDxList.Add(UBAConst.PRIMARY_DX + U + Piece(txtProvDiag.text,'(',1) + ':' + primaryCode);
1468 if (Piece(sourceOrderList.Strings[0],U,5) <> '') then // dx2
1469 uBAGlobals.BAConsultDxList.Add(UBAConst.SECONDARY_DX + U + Piece(sourceOrderList.Strings[0],U,6) + ':' + Piece(sourceOrderList.Strings[0],U,5));
1470 if (Piece(sourceOrderList.Strings[0],U,7) <> '') then // dx3
1471 uBAGlobals.BAConsultDxList.Add(UBAConst.SECONDARY_DX + U + Piece(sourceOrderList.Strings[0],U,8) + ':' + Piece(sourceOrderList.Strings[0],U,7));
1472 if (Piece(sourceOrderList.Strings[0],U,9) <> '') then // dx4
1473 uBAGlobals.BAConsultDxList.Add(UBAConst.SECONDARY_DX + U + Piece(sourceOrderList.Strings[0],U,10) + ':' + Piece(sourceOrderList.Strings[0],U,9));
1474 end;
1475end;
1476
1477procedure TfrmODCslt.FormClose(Sender: TObject; var Action: TCloseAction);
1478begin
1479 inherited;
1480 frmFrame.pnlVisit.Enabled := true;
1481end;
1482
[829]1483procedure TfrmODCslt.FormResize(Sender: TObject);
1484begin
1485 inherited;
1486 AdjustMemReasonSize();
1487end;
1488
1489procedure TfrmODCslt.AdjustMemReasonSize;
1490const
1491 PIXEL_SPACE = 3;
1492begin
1493 pnlReason.Top := cboService.Top + cboService.Height + PIXEL_SPACE;
1494 pnlReason.Height := memOrder.Top - pnlReason.Top - PIXEL_SPACE;
1495end;
1496
[456]1497end.
1498
1499
Note: See TracBrowser for help on using the repository browser.