Index: cprs/branches/HealthSevak-CPRS/CPRS-Chart/fPtSel.pas
===================================================================
--- cprs/branches/HealthSevak-CPRS/CPRS-Chart/fPtSel.pas	(revision 1676)
+++ cprs/branches/HealthSevak-CPRS/CPRS-Chart/fPtSel.pas	(revision 1693)
@@ -1,5 +1,4 @@
 unit fPtSel;
 { Allows patient selection using various pt lists.  Allows display & processing of alerts. }
- //vwpt enhancements included
 
 {$OPTIMIZATION OFF}                              // REMOVE AFTER UNIT IS DEBUGGED
@@ -38,7 +37,9 @@
     lstvAlerts: TCaptionListView;
     N1: TMenuItem;
-    RadioGroup1: TRadioGroup ;
-    //RadioGroup1: TRadioGroup;
     cmdComments: TButton;
+    txtCmdComments: TVA508StaticText;
+    txtCmdRemove: TVA508StaticText;
+    txtCmdForward: TVA508StaticText;
+    txtCmdProcess: TVA508StaticText;
     procedure cmdOKClick(Sender: TObject);
     procedure cmdCancelClick(Sender: TObject);
@@ -80,10 +81,8 @@
     procedure FormResize(Sender: TObject);
     procedure cmdCommentsClick(Sender: TObject);
-
-    //VWPT ENAHANCED PATIENT LOOKUP
-    function IsOther(itemindex:Integer):Boolean;
-    
-    procedure onclick1(Sender: TObject);
-
+    procedure lstvAlertsMouseUp(Sender: TObject; Button: TMouseButton;
+      Shift: TShiftState; X, Y: Integer);
+    procedure cboPatientKeyUp(Sender: TObject; var Key: Word;
+      Shift: TShiftState);
   private
     FsortCol: integer;
@@ -94,4 +93,5 @@
     FNotificationBtnsAdjusted: Boolean;
     FAlertsNotReady: boolean;
+    FMouseUpPos: TPoint;
     procedure WMReadyAlert(var Message: TMessage); message UM_MISC;
     procedure ReadyAlert;
@@ -107,4 +107,6 @@
     procedure AdjustButtonSize(pButton:TButton);
     procedure AdjustNotificationButtons;
+    procedure SetupDemographicsForm;
+    procedure ShowDisabledButtonTexts;
 
   public
@@ -121,9 +123,4 @@
   PtStrs: TStringList;
 
-    //vwpt enhancement
-  itimson : integer = 1;
-  enhanceskip : integer = 0;
-  radiogrp1index : integer = 0;
-
 
 implementation
@@ -132,21 +129,12 @@
 
 uses rCore, uCore, fDupPts, fPtSens, fPtSelDemog, fPtSelOptns, fPatientFlagMulti,
-     uOrPtf, fAlertForward, rMisc, fFrame, fRptBox, VA508AccessibilityRouter;
-
-resourcestring
-  StrFPtSel_lstvAlerts_Co = 'C'+U+'fPtSel.lstvAlerts.Cols';
+     uOrPtf, fAlertForward, rMisc, fFrame, fRptBox, VA508AccessibilityRouter,
+     VAUtils;
+
+var
+  FDragging: Boolean = False;
 
 const
   AliasString = ' -- ALIAS';
-
-   //VWPT ENAHANCED PATIENT LOOKUP
-function TfrmPtSel.IsOther(itemindex:Integer):Boolean;
-var
-   i:Integer  ;
-
-begin
-         Result := True;
-         if (RadioGroup1.ItemIndex = -1) or (RadioGroup1.ItemIndex = 0) or (itimson = 0) then Result := False;
-end;
 
 procedure SelectPatient(ShowNotif: Boolean; FontSize: Integer; var UserCancelled: boolean);
@@ -191,19 +179,14 @@
 var
   Rect: TRect;
-//  TheFormHeight: integer;
   SplitterTop, t1, t2, t3: integer;
 begin
+  SetFormPosition(self);
   ResizeAnchoredFormToFont(self);
-//  TheFormHeight := pnlPtSel.Height;
-  // Make the form bigger (140%) to show notifications and show notification controls.
   if ShowNotif then
   begin
-//    TheFormHeight := Round(TheFormHeight * 2.4);
-//    pnlDivide.Height := lblNotifications.Height + 4;
     pnlDivide.Visible := True;
     lstvAlerts.Visible := True;
     pnlNotifications.Visible := True;
     pnlPtSel.BevelOuter := bvRaised;
-//    ClientHeight := TheFormHeight;
   end
   else
@@ -212,16 +195,9 @@
     lstvAlerts.Visible := False;
     pnlNotifications.Visible := False;
-//    ClientHeight := TheFormHeight;
-//    pnlPtSel.Anchors := [akLeft,akRight,akTop,akBottom];
-  end;
-//  ClientHeight := TheFormHeight;
-//  VertScrollBar.Range := TheFormHeight;
-
-  //After all of this calcualtion, we still use the saved preferences when possible
-  SetFormPosition(self);
+  end;
+  //SetFormPosition(self);
   Rect := BoundsRect;
   ForceInsideWorkArea(Rect);
   BoundsRect := Rect;
-
   if frmFrame.EnduringPtSelSplitterPos <> 0 then
     SplitterTop := frmFrame.EnduringPtSelSplitterPos
@@ -270,8 +246,4 @@
     Items.Add(LLS_SPACE);
     cboPatient.InitLongList('');
-  //VWPT
-  //cboPatient.LongList := True;
-  //cboPateint.HintonItem := True;
-  //end
     RedrawActivate(cboPatient.Handle);
   end;
@@ -402,32 +374,7 @@
     end;
 
-var caption:string;
-index:integer;
-
-   
 begin
   with cboPatient do
-    if IsOther(integer(1))and (IsRPL <> '1')and (enhanceskip=0) and (frmPtSelOptns.IsEnhanced(Text))and (not frmPtSelOptns.IsPatientName(Text)) then
-      begin
-        if (IsRPL = '1') then
-          ///ListPtByRPLLast5(Items, Text)   Messagebox error
-        else
-         begin
-             index := RadioGroup1.ItemIndex;
-             caption := piece(RadioGroup1.Items[index],'&',2);
-             //Application.MessageBox(pChar(caption), pChar('Message'),MB_OK);
-             //caption := '' ; //derivative of integer(1) or other index of radio button selection
-             ListPtByOther(Items, Text,caption); // one extra argument on radio button selection
-             if Items.Count>0  then
-             begin
-                  //itimson :=0 ;//no check for timson change in cbopatient until after click event finished
-             RadioGroup1.ItemIndex  := 0;
-             RadioGroup1.SetFocus;
-             RadioGroup1.Refresh;
-             end;
-             ShowMatchingPatients;
-         end;
-      end
-    else if frmPtSelOptns.IsLast5(Text) then
+    if frmPtSelOptns.IsLast5(Text) then
       begin
         if (IsRPL = '1') then
@@ -443,20 +390,6 @@
         else
            ListPtByFullSSN(Items, Text);
-        ShowMatchingPatients
-      end
-    else if (not IsOther(integer(1))) and (IsRPL <> '1')and (enhanceskip=0) and (frmPtSelOptns.IsEnhanced(Text)) and (not frmPtSelOptns.IsPatientName(Text)) then
-    begin
-
-           ListPtByTimson(Items,Text) ;
-           ShowMatchingPatients;
-          //vwpt enhanced changes
-          //check for change here if itimson flag =1 .no matter what however, even if 0,
-         //set it back to 1
-         //itimson :=1;
-         //end vwpt enhanced
-
-
-    end
-    //enhanceskip := 0 ;
+        ShowMatchingPatients;
+      end;
 end;
 
@@ -473,4 +406,11 @@
 end;
 
+procedure TfrmPtSel.cboPatientKeyUp(Sender: TObject; var Key: Word;
+  Shift: TShiftState);
+begin
+  inherited;
+  if (Key = VK_BACK) and (cboPatient.Text = '') then cboPatient.ItemIndex := -1;
+end;
+
 procedure TfrmPtSel.cboPatientMouseClick(Sender: TObject);
 begin
@@ -487,17 +427,4 @@
 procedure TfrmPtSel.cboPatientDblClick(Sender: TObject);
 begin
-  // vwpt enhanced   on click or double clck set mode back to normal to a.) not allow change event
- //erroneously checked with false lookup, and b.0 immedicately put back into normal mode
- //without separate step needed.
-  if (RadioGroup1.ItemIndex  > 0) then
-  begin
-  //itimson :=0 ;//no check for timson change in cbopatient until after click event finished
-  RadioGroup1.ItemIndex  := 0;
-  RadioGroup1.SetFocus;
-  RadioGroup1.Refresh;
-  end;
-  //enhanceskip:=1 ;
-
-//end vwpt enhanced
   if Length(cboPatient.ItemID) > 0 then cmdOKClick(Self);  //*DFN*
 end;
@@ -573,16 +500,4 @@
   AccessStatus: integer;
 begin
-// vwpt enhanced   on click or double clck set mode back to normal to a.) not allow change event
-//erroneiusly checked with false lookup, and b.0 immedicately put back into normal mode
-//without separate step needed.
-  if (RadioGroup1.ItemIndex  > 0 ) then
-  begin
-  //itimson :=0 ;//no check for timson change in cbopatient until after click event finished
-  RadioGroup1.ItemIndex  := 0;
-  RadioGroup1.SetFocus;
-  RadioGroup1.Refresh;
-  end;
-
-//end vwpt enhanced
 if not (Length(cboPatient.ItemID) > 0) then  //*DFN*
   begin
@@ -731,5 +646,5 @@
           ADFN := Piece(XQAID, ',', 2);  //*DFN*
           AFollowUp := StrToIntDef(Piece(Piece(XQAID, ';', 1), ',', 3), 0);
-          Notifications.Add(ADFN, AFollowUp, RecordID);
+          Notifications.Add(ADFN, AFollowUp, RecordID, Items[i].SubItems[3]); //CB
           enableclose := true;
         end
@@ -812,6 +727,19 @@
 
 procedure TfrmPtSel.lstvAlertsDblClick(Sender: TObject);
+var
+  ScreenCurPos, ClientCurPos: TPoint;
 begin
   cmdProcessClick(Self);
+  ScreenCurPos.X := 0;
+  ScreenCurPos.Y := 0;
+  ClientCurPos.X := 0;
+  ClientCurPos.Y := 0;
+  if GetCursorPos(ScreenCurPos) then ClientCurPos := lstvAlerts.ScreenToClient(ScreenCurPos); //convert screen coord. to client coord.
+  //fixes CQ 18657: double clicking on notification, does not go to pt. chart until mouse is moved. [v28.4 - TC]
+  if (FMouseUpPos.X = ClientCurPos.X) and (FMouseUpPos.Y = ClientCurPos.Y) then
+    begin
+      lstvAlerts.BeginDrag(False,0);
+      FDragging := True;
+    end;
 end;
 
@@ -866,7 +794,17 @@
 
 procedure TfrmPtSel.FormDestroy(Sender: TObject);
+var
+  i: integer;
+  AString: string;
 begin
   SaveUserBounds(Self);
   frmFrame.EnduringPtSelSplitterPos := pnlPtSel.Height;
+  AString := '';
+  for i := 0 to 6 do
+  begin
+    AString := AString + IntToStr(lstvAlerts.Column[i].Width);
+    if i < 6 then AString:= AString + ',';
+  end;
+  frmFrame.EnduringPtSelColumns := AString;
  end;
 
@@ -888,5 +826,5 @@
 begin
   frmPtSelDemog.Left := cboPatient.Left + cboPatient.Width + 9;
-  //  frmPtSelDemog.Width := frmPtSel.CmdCancel.Left - frmPtSelDemog.Left-2;// before vwpt enhancements pnlPtSel.Width - frmPtSelDemog.Left - 2;
+  frmPtSelDemog.Width := pnlPtSel.Width - frmPtSelDemog.Left - 2;
   frmPtSelOptns.Width := cboPatient.Left-8;
 end;
@@ -895,28 +833,5 @@
 begin
   inherited;
-// This needs to be in Loaded rather than FormCreate or the TORAutoPanel resize logic breaks.
-  //vwpt enhancements
-  CmdOK.parent := pnlPtSel;
-  CmdCancel.parent  :=  pnlPtSel;
-  //end vwpt
-  frmPtSelDemog := TfrmPtSelDemog.Create(Self);  // Was application - kcm
-  with frmPtSelDemog do
-  begin
-    parent := pnlPtSel;
-    Top := 4; //before vwpt change was 65
-    Left := cboPatient.Left + cboPatient.Width + 9;
-    //Width := pnlPtSel.Width - Left - 2; //before vwpt change
-    Width := CmdCancel.Left - Left-2  ;
-    TabOrder := cmdCancel.TabOrder + 1;  //Place after cancel button
-    Show;
-  end;
-
-  with RadioGroup1 do
-  begin
-      parent := pnlPtSel;
-      TabOrder  := cmdCancel.TabOrder + 2;
-      Show;
-  end;
-  //end vwpt enhancements
+  SetupDemographicsForm;
 
   frmPtSelOptns := TfrmPtSelOptns.Create(Self);  // Was application - kcm
@@ -940,4 +855,36 @@
 end;
 
+procedure TfrmPtSel.ShowDisabledButtonTexts;
+begin
+  if ScreenReaderActive then
+  begin
+    txtCmdProcess.Visible := not cmdProcess.Enabled;
+    txtCmdRemove.Visible := not cmdRemove.Enabled;
+    txtCmdForward.Visible := not cmdForward.Enabled;
+    txtCmdComments.Visible := not cmdComments.Enabled;
+  end;
+end;
+
+procedure TfrmPtSel.SetupDemographicsForm;
+begin
+  // This needs to be in Loaded rather than FormCreate or the TORAutoPanel resize logic breaks.
+  frmPtSelDemog := TfrmPtSelDemog.Create(Self);
+  // Was application - kcm
+  with frmPtSelDemog do
+  begin
+    parent := pnlPtSel;
+    Top := cmdCancel.Top + cmdCancel.Height + 2;
+    Left := cboPatient.Left + cboPatient.Width + 9;
+    Width := pnlPtSel.Width - Left - 2;
+    TabOrder := cmdCancel.TabOrder + 1;
+    //Place after cancel button
+    Show;
+  end;
+  if ScreenReaderActive then begin
+    frmPtSelDemog.Memo.Show;
+    frmPtSelDemog.Memo.BringToFront;
+  end;
+end;
+
 procedure TfrmPtSel.RPLDisplay;
 begin
@@ -950,18 +897,10 @@
 
 procedure TfrmPtSel.FormClose(Sender: TObject; var Action: TCloseAction);
-var
-  colSizes : String;
-begin
-  colSizes := '';
-  with lstvAlerts do begin
-    colSizes := IntToStr(Columns[0].Width) + ',';  //Info                 Caption
-    colSizes := colSizes + IntToStr(Columns[1].Width) + ',';  //Patient              SubItems[0]
-    colSizes := colSizes + IntToStr(Columns[2].Width) + ',';  //Location             SubItems[1]
-    colSizes := colSizes + IntToStr(Columns[3].Width) + ',';  //Urgency              SubItems[2]
-    colSizes := colSizes + IntToStr(Columns[4].Width) + ',';  //Alert Date/Time      SubItems[3]
-    colSizes := colSizes + IntToStr(Columns[5].Width) + ',';  //Message Text         SubItems[4]
-    colSizes := colSizes + IntToStr(Columns[6].Width);  //Forwarded By/When    SubItems[5]
-  end;
-  SizeHolder.SetSize(StrFPtSel_lstvAlerts_Co,colSizes);
+begin
+if FDragging then
+begin
+  lstvAlerts.EndDrag(True); //terminate fake dragging operation from lstvAlertsDblClick.
+  FDragging := False;
+end;
 
 if (IsRPL = '1') then                          // Deal with restricted patient list users.
@@ -975,4 +914,5 @@
   DefaultButton := cmdOK;
   FAlertsNotReady := FALSE;
+  ShowDisabledButtonTexts;
 end;
 
@@ -1060,8 +1000,7 @@
   NewItem: TListItem;
   I,J: Integer;
-  Comment,colSizes : String;
+  Comment: String;
 begin
   // Load the items
-  colSizes := '';
   lstvAlerts.Items.Clear;
   List := TStringList.Create;
@@ -1092,30 +1031,15 @@
    with lstvAlerts do
      begin
-        colSizes := SizeHolder.GetSize(StrFPtSel_lstvAlerts_Co);
-        if colSizes = '' then begin
-          Columns[0].Width := 40;          //Info                 Caption
-          Columns[1].Width := 195;         //Patient              SubItems[0]
-          Columns[2].Width := 75;          //Location             SubItems[1]
-          Columns[3].Width := 95;          //Urgency              SubItems[2]
-          Columns[4].Width := 150;         //Alert Date/Time      SubItems[3]
-          Columns[5].Width := 310;         //Message Text         SubItems[4]
-          Columns[6].Width := 290;         //Forwarded By/When    SubItems[5]
-        end else begin
-          Columns[0].Width := StrToInt(piece(colSizes,',',1));          //Info                 Caption
-          Columns[1].Width := StrToInt(piece(colSizes,',',2));         //Patient              SubItems[0]
-          Columns[2].Width := StrToInt(piece(colSizes,',',3));          //Location             SubItems[1]
-          Columns[3].Width := StrToInt(piece(colSizes,',',4));          //Urgency              SubItems[2]
-          Columns[4].Width := StrToInt(piece(colSizes,',',5));         //Alert Date/Time      SubItems[3]
-          Columns[5].Width := StrToInt(piece(colSizes,',',6));         //Message Text         SubItems[4]
-          Columns[6].Width := StrToInt(piece(colSizes,',',7));         //Forwarded By/When    SubItems[5]
-        end;
-
+        Columns[0].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 1), 40);          //Info                 Caption
+        Columns[1].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 2), 195);         //Patient              SubItems[0]
+        Columns[2].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 3), 75);          //Location             SubItems[1]
+        Columns[3].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 4), 95);          //Urgency              SubItems[2]
+        Columns[4].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 5), 150);         //Alert Date/Time      SubItems[3]
+        Columns[5].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 6), 310);         //Message Text         SubItems[4]
+        Columns[6].Width := StrToIntDef(Piece(frmFrame.EnduringPtSelColumns, ',', 7), 290);         //Forwarded By/When    SubItems[5]
      //Items not displayed in Columns:     XQAID                SubItems[6]
      //                                    Remove w/o process   SubItems[7]
      //                                    Forwarding comments  SubItems[8]
      end;
-  //with lstvAlerts do      ca comment out 12/24/03 to prevent default selection of first alert on list
-    //if (ItemIndex = -1) and (Items.Count > 0) then
-      //ItemIndex := 0;
 end;
 
@@ -1254,4 +1178,5 @@
   cmdForward.Enabled := ShowButts;
   cmdComments.Enabled := ShowButts and (lstvAlerts.SelCount = 1) and (lstvAlerts.Selected.SubItems[8] <> '');
+  ShowDisabledButtonTexts;
 end;
 
@@ -1285,4 +1210,11 @@
 end;
 
+procedure TfrmPtSel.lstvAlertsMouseUp(Sender: TObject; Button: TMouseButton;
+  Shift: TShiftState; X, Y: Integer);
+begin
+  inherited;
+  FMouseUpPos := Point(X,Y);
+end;
+
 procedure TfrmPtSel.FormShow(Sender: TObject);
 {
@@ -1296,4 +1228,6 @@
   sortResult := rCore.GetSortMethod;
   sortMethod := Piece(sortResult, U, 1);
+  if sortMethod = '' then
+     sortMethod := 'D';
   FsortDirection := Piece(sortResult, U, 2);
   if FsortDirection = 'F' then
@@ -1385,37 +1319,4 @@
 end;
 
-//vwpt enhanced //
-procedure TfrmPtSel.onclick1(Sender: TObject);  //click on RadioGroup1
-var index :integer;
-
-begin
-if RadioGroup1.ItemIndex >0 then
- begin
-     itimson := 1  ;
-     cboPatient.Text := '' ;
-     if (frmPtSelOptns.radAll.Checked <> True)and (frmPtSelOptns.radDflt.Checked <> True) then
-     begin
-        radiogrp1index :=0  ;
-        RadioGroup1.ItemIndex  := 0;
-        RadioGroup1.SetFocus;
-        RadioGroup1.Refresh;
-     end
-     else
-     begin
-          index := RadioGroup1.ItemIndex;
-          radiogrp1index := index;
-          cboPatient.Hint  := 'Enter ' + piece(RadioGroup1.Items[index],'&',2);
-     end ;
- end
- else
- begin
-       //itimson := 0;
-        cboPatient.Hint :=  'Enter name,Full SSN,Last4(x1234),''HRN'',DOB,or Phone#'  ;
-        radiogrp1index := 0;
- end;
-
-end;
- //end vwpt enhanced
-
 
 end.
