Ignore:
Timestamp:
Jul 6, 2008, 8:20:14 PM (16 years ago)
Author:
Kevin Toppenberg
Message:

Uploading from OR_30_258

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/foia-cprs/CPRS-Chart/fNotes.pas

    r459 r460  
    11unit fNotes;
    22{$O-}
    3 {
    4 NOTES:
    5     TAB ORDER:
    6       Becuase of the Dynamic ways of this form, the tab order must be
    7       coded into the onExit events of the controls. If a new control is
    8       added that needs access with tab & shift tab you must add the
    9       code. Right clicking on the form and selecting tab order will not
    10       be sufficient. See TfrmNotes.memPCEShowExit procedure for example.
    11 }
    123
    134interface
     
    167  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    178  fHSplit, StdCtrls, ExtCtrls, Menus, ComCtrls, ORCtrls, ORFn, uConst, ORDtTm,
    18   uPCE, ORClasses, fDrawers, ImgList, rTIU, uTIU, uDocTree, fRptBox, fPrintList;
     9  uPCE, ORClasses, fDrawers, ImgList, rTIU, uTIU, uDocTree, fRptBox, fPrintList,
     10  fNoteST, ORNet, fNoteSTStop;
    1911
    2012type
     
    116108    N3: TMenuItem;
    117109    mnuEditDialgFields: TMenuItem;
     110    tvNotes: TORTreeView;
    118111    lvNotes: TCaptionListView;
    119112    sptList: TSplitter;
     
    143136    popNoteMemoInsTemplate: TMenuItem;
    144137    popNoteMemoEncounter: TMenuItem;
    145     tvNotes: TORTreeView;
     138    mnuSearchForText: TMenuItem;
     139    popSearchForText: TMenuItem;
     140    mnuViewInformation: TMenuItem;
     141    mnuViewDemo: TMenuItem;
     142    mnuViewVisits: TMenuItem;
     143    mnuViewPrimaryCare: TMenuItem;
     144    mnuViewMyHealtheVet: TMenuItem;
     145    mnuInsurance: TMenuItem;
     146    mnuViewFlags: TMenuItem;
     147    mnuViewReminders: TMenuItem;
     148    mnuViewRemoteData: TMenuItem;
     149    mnuViewPostings: TMenuItem;
    146150    procedure mnuChartTabClick(Sender: TObject);
    147151    procedure lstNotesClick(Sender: TObject);
     
    214218    procedure dlgReplaceTextFind(Sender: TObject);
    215219    procedure mnuActAttachtoIDParentClick(Sender: TObject);
    216     procedure memNewNoteKeyDown(Sender: TObject; var Key: Word;
    217       Shift: TShiftState);
     220    procedure memNewNoteKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
    218221    procedure sptHorzCanResize(Sender: TObject; var NewSize: Integer; var Accept: Boolean);
    219222    procedure popNoteMemoInsTemplateClick(Sender: TObject);
     
    222225    procedure tvNotesDeletion(Sender: TObject; Node: TTreeNode);
    223226    procedure tvNotesExit(Sender: TObject);
     227    procedure pnlReadExit(Sender: TObject);
    224228    procedure cmdNewNoteExit(Sender: TObject);
    225229    procedure FormHide(Sender: TObject);
    226230    procedure FormShow(Sender: TObject);
     231    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
     232      Y: Integer);
    227233    procedure memNewNoteKeyPress(Sender: TObject; var Key: Char);
    228234    procedure memNewNoteKeyUp(Sender: TObject; var Key: Word;
     
    231237    procedure cmdChangeExit(Sender: TObject);
    232238    procedure cmdPCEExit(Sender: TObject);
    233     procedure memNoteExit(Sender: TObject);
    234     procedure lvNotesExit(Sender: TObject);
     239    procedure ViewInfo(Sender: TObject);
     240    procedure mnuViewInformationClick(Sender: TObject);
    235241  private
    236242    FNavigatingTab : Boolean; //Currently Using tab to navigate
     
    255261    FOldDrawerPnlEncounterButtonExit: TNotifyEvent;
    256262    FOldDrawerEdtSearchExit: TNotifyEvent;
     263    FMousing: TDateTime;
    257264    FStarting: boolean;
    258265    procedure frmFramePnlPatientExit(Sender: TObject);
     
    261268    procedure frmDrawerEdtSearchExit(Sender: TObject);
    262269    procedure ClearEditControls;
    263     procedure DoAutoSave;
     270    procedure DoAutoSave(Suppress: integer = 1);
    264271    function GetTitleText(AnIndex: Integer): string;
    265272    procedure InsertAddendum;
     
    310317var
    311318  frmNotes: TfrmNotes;
     319  SearchTextStopFlag: Boolean;   // Text Search CQ: HDS00002856
    312320
    313321implementation
     
    389397                      ' but will remain indefinitely discoverable to HIMS.' +CRLF +CRLF;
    390398  TX_AUTH_SIGNED    = 'Author has not signed, are you SURE you want to sign.' +CRLF;
    391 
     399{
     400type
     401  //CQ8300
     402  ClipboardData = record
     403     Text: array[0..255] of char;
     404  end;
     405}
    392406var
    393407  uPCEShow, uPCEEdit:  TPCEData;
     
    399413  uChanging: Boolean;
    400414  uIDNotesActive: Boolean;
     415
    401416
    402417{ TPage common methods --------------------------------------------------------------------- }
     
    631646    {LastCosigner & LastCosignerName aren't cleared because they're used as default for next note.}
    632647    Lines        := nil;
     648    PRF_IEN := 0;
     649    ActionIEN := '';
    633650  end;
    634651  // clear the editing controls (also clear the new labels?)
    635652  txtSubject.Text := '';
    636   memNewNote.Clear;
     653  if memNewNote <> nil then memNewNote.Clear; //CQ7012 Added test for nil
    637654  timAutoSave.Enabled := False;
    638655  // clear the PCE object for editing
     
    754771    if IsConsultTitle(Title) and (PkgIEN = 0) then Result := True;
    755772    if IsSurgeryTitle(Title) and (PkgIEN = 0) then Result := True;
     773    if IsPRFTitle(Title) and (PRF_IEN = 0) and (not DocType = TYP_ADDENDUM) then Result := True;
    756774    if (DocType = TYP_ADDENDUM) then
    757775    begin
     
    760778    begin
    761779      if Title > 0 then CurTitle := Title else CurTitle := DocType;
    762       if AskCosignerForTitle(CurTitle, Author) and (Cosigner <= 0) then Result := True;
     780      if AskCosignerForTitle(CurTitle, Author, DateTime) and (Cosigner <= 0) then Result := True;
    763781    end;
    764782  end;
     
    897915  x, WhyNot, DocInfo: string;
    898916begin
     917  if frmFrame.Timedout then Exit;
     918
    899919  FNewIDChild := IsIDChild;
    900920  EnableAutosave := FALSE;
     
    932952    end;
    933953    // check to see if interaction necessary to get required fields
    934     if LacksRequiredForCreate or VerifyNoteTitle or UnresolvedConsultsExist
     954    GetUnresolvedConsultsInfo;
     955    if LacksRequiredForCreate or VerifyNoteTitle or uUnresolvedConsults.UnresolvedConsultsExist
    935956      then HaveRequired := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
    936957      else HaveRequired := True;
     
    953974        //7348^Note Title^3000913^NERD, YOURA  (N0165)^1329;Rich Vertigan;VERTIGAN,RICH^8E REHAB MED^complete^Adm: 11/05/98;2981105.095547^        ;^^0^^^2
    954975        with FEditNote do
    955           begin
    956             x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
    957                  Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
    958                  U + U + U + U + U + U + U;
    959           end;
     976        begin
     977          x := IntToStr(CreatedNote.IEN) + U + TitleName + U + FloatToStr(FEditNote.DateTime) + U +
     978               Patient.Name + U + IntToStr(Author) + ';' + AuthorName + U + LocationName + U + 'new' + U +
     979               U + U + U + U + U + U + U;
     980          //Link Note to PRF Action
     981          if PRF_IEN <> 0 then
     982            if sCallV('TIU LINK TO FLAG', [CreatedNote.IEN,PRF_IEN,ActionIEN,Patient.DFN]) = '0' then
     983              ShowMessage('TIU LINK TO FLAG: FAILED');
     984        end;
    960985
    961986        lstNotes.Items.Insert(0, x);
     
    9951020        FChanged := False;
    9961021        cmdChangeClick(Self); // will set captions, sign state for Changes
    997         lstNotesClick(Self);  // will makepnlWrite visible
     1022        lstNotesClick(Self);  // will make pnlWrite visible
    9981023        if timAutoSave.Interval <> 0 then EnableAutosave := TRUE;
    9991024        if txtSubject.Visible then txtSubject.SetFocus else memNewNote.SetFocus;
     
    10651090    else HaveRequired := True;
    10661091  // lock the consult request if there is a consult
    1067   with FEditNote do if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
     1092  if HaveRequired then
     1093    with FEditNote do
     1094      if (PkgIEN > 0) and (PkgPtr = PKG_CONSULTS) then HaveRequired := LockConsultRequest(PkgIEN);
    10681095  if HaveRequired then
    10691096  begin
     
    12851312  inherited;
    12861313  LimitEditWidth(memNewNote, MAX_PROGRESSNOTE_WIDTH - 1);
    1287   memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_PROGRESSNOTE_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
    1288   pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
     1314
     1315  //CQ7012 Added test for nil
     1316  if memNewNote <> nil then
     1317     memNewNote.Constraints.MinWidth := TextWidthByFont(memNewNote.Font.Handle, StringOfChar('X', MAX_PROGRESSNOTE_WIDTH)) + (LEFT_MARGIN * 2) + ScrollBarWidth;
     1318  //CQ7012 Added test for nil
     1319   if (Self <> nil) and (pnlLeft <> nil) and (pnlWrite <> nil) and (sptHorz <> nil) then
     1320     pnlLeft.Width := self.ClientWidth - pnlWrite.Width - sptHorz.Width;
    12891321end;
    12901322
     
    13951427    // no other note being edited, so just proceed as before.
    13961428    UpdateEncounterInfo;
    1397   cmdPCE.Enabled := TRUE;
     1429  if cmdPCE <> nil then
     1430    cmdPCE.Enabled := TRUE
    13981431end;
    13991432
     
    14661499  OKPressed, IsIDChild: Boolean;
    14671500  x: string;
     1501  DisAssoText : String;
    14681502begin
    14691503  inherited;
     
    14711505  LastTitle   := FEditNote.Title;
    14721506  FEditNote.IsNewNote := False;
     1507  DisAssoText := '';
     1508  if (FEditNote.PkgPtr = PKG_CONSULTS) then
     1509    DisAssoText := 'Consults';
     1510  if (FEditNote.PkgPtr = PKG_PRF) then
     1511    DisAssoText := 'Patient Record Flags';
     1512  if (DisAssoText <> '') and (Sender <> Self) then
     1513    if InfoBox('If this title is changed, Any '+DisAssoText+' will be disassociated'+
     1514               ' with this note',
     1515               'Disassociate '+DisAssoText+'?',MB_OKCANCEL) = IDCANCEL   then
     1516      exit;
    14731517  if FEditNote.PkgPtr = PKG_CONSULTS then LastConsult := FEditNote.PkgIEN else LastConsult := 0;;
    14741518  if Sender <> Self then OKPressed := ExecuteNoteProperties(FEditNote, CT_NOTES, IsIDChild, FNewIDChild, '', 0)
     
    15001544  lstNotes.Items[EditingIndex] := x;
    15011545  Changes.ReplaceText(CH_DOC, lstNotes.ItemID, GetTitleText(EditingIndex));
    1502   with FEditNote do if (PkgPtr = PKG_CONSULTS) and (LastConsult <> PkgIEN) then
     1546  with FEditNote do
     1547  begin
     1548  if (PkgPtr = PKG_CONSULTS) and (LastConsult <> PkgIEN) then
    15031549  begin
    15041550    // try to lock the new consult, reset to previous if unable
     
    15141560    end;
    15151561  end;
     1562  //Link Note to PRF Action
     1563  if PRF_IEN <> 0 then
     1564    if sCallV('TIU LINK TO FLAG', [lstNotes.ItemIEN,PRF_IEN,ActionIEN,Patient.DFN]) = '0' then
     1565      ShowMessage('TIU LINK TO FLAG: FAILED');
     1566  end;
     1567
    15161568  if LastTitle <> FEditNote.Title then mnuActLoadBoilerClick(Self);
    15171569end;
     
    15321584end;
    15331585
    1534 procedure TfrmNotes.DoAutoSave;
     1586procedure TfrmNotes.DoAutoSave(Suppress: integer = 1);
    15351587var
    15361588  ErrMsg: string;
     
    15421594    timAutoSave.Enabled := False;
    15431595    try
    1544       SetText(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex),1);
     1596      SetText(ErrMsg, memNewNote.Lines, lstNotes.GetIEN(EditingIndex), Suppress);
    15451597    finally
    15461598      timAutoSave.Enabled := True;
     
    15661618var
    15671619  AuthCtxt: TAuthorContext;
     1620  SearchCtxt: TSearchContext; // Text Search CQ: HDS00002856
    15681621  DateRange: TNoteDateRange;
    15691622  Saved: Boolean;
     
    16021655                   LoadNotes;
    16031656                 end;
     1657  // Text Search CQ: HDS00002856 --------------------
     1658  NC_SEARCHTEXT: begin;
     1659                   SearchTextStopFlag := False;
     1660                   SelectSearchText(Font.Size, FCurrentContext.SearchString, SearchCtxt );
     1661                   with SearchCtxt do if Changed then
     1662                   begin
     1663                     //FCurrentContext.Status := IntToStr(ViewContext);
     1664                     frmSearchStop.Show;
     1665                     lblNotes.Caption := 'Search: '+ SearchString;
     1666                     frmSearchStop.lblSearchStatus.Caption := lblNotes.Caption;
     1667                     FCurrentContext.SearchString := SearchString;
     1668                     LoadNotes;
     1669                   end;
     1670                   // Only do LoadNotes if something changed
     1671                 end;
     1672  // Text Search CQ: HDS00002856 --------------------
    16041673  NC_UNCOSIGNED: begin
    16051674                   FillChar(FCurrentContext, SizeOf(FCurrentContext), 0);
     
    16671736  end; {case}
    16681737  lblNotes.Caption := SetNoteTreeLabel(FCurrentContext);
     1738  // Text Search CQ: HDS00002856 --------------------
     1739  If FCurrentContext.SearchString <> '' then
     1740    lblNotes.Caption := lblNotes.Caption+', containing "'+FCurrentContext.SearchString+'"';
     1741  If SearchTextStopFlag=True then begin;
     1742    lblNotes.Caption := 'Search for "'+FCurrentContext.SearchString+'" was stopped!';
     1743  end;
     1744  frmSearchStop.Hide;
     1745  // Text Search CQ: HDS00002856 --------------------
    16691746  lblNotes.hint := lblNotes.Caption;
    16701747  tvNotes.Caption := lblNotes.Caption;
     
    21282205procedure TfrmNotes.SaveSignItem(const ItemID, ESCode: string);
    21292206{ saves and optionally signs a progress note or addendum }
     2207const
     2208  SIG_COSIGN = 'COSIGNATURE';
     2209  SIG_SIGN   = 'SIGNATURE';
    21302210var
    21312211  AnIndex, IEN, i: Integer;
    21322212  Saved, ContinueSign: Boolean;  {*RAB* 8/26/99}
    2133   SignSts: TActionRec;
     2213  ActionSts, SignSts: TActionRec;
    21342214  APCEObject: TPCEData;
    21352215  OK: boolean;
    2136 
     2216  ActionType, SignTitle: string;
    21372217begin
    21382218  AnIndex := -1;
     
    21592239  if Length(ESCode) > 0 then
    21602240  begin
    2161     if not NoteHasText(IEN) then
     2241    if CosignDocument(IEN) then
     2242    begin
     2243      SignTitle := TX_COSIGN;
     2244      ActionType := SIG_COSIGN;
     2245    end else
     2246    begin
     2247      SignTitle := TX_SIGN;
     2248      ActionType := SIG_SIGN;
     2249    end;
     2250    ActOnDocument(ActionSts, IEN, ActionType);
     2251    if not ActionSts.Success then
     2252      begin
     2253        InfoBox(ActionSts.Reason, TX_IN_AUTH, MB_OK);
     2254        ContinueSign := False;
     2255      end
     2256    else if not NoteHasText(IEN) then
    21622257      begin
    21632258        InfoBox(TX_EMPTY_NOTE1, TC_EMPTY_NOTE, MB_OK or MB_ICONERROR);
     
    22762371
    22772372procedure TfrmNotes.popNoteMemoFindClick(Sender: TObject);
     2373//var
     2374  //hData: THandle;  //CQ8300
     2375  //pData: ^ClipboardData; //CQ8300
    22782376begin
    22792377  inherited;
     
    22842382      FindText := '';
    22852383      Options := [frDown, frHideUpDown];
     2384{
     2385      //CQ8300
     2386      OpenClipboard(dlgFindText.Handle);
     2387      hData := GetClipboardData(CF_TEXT);
     2388      pData := GlobalLock(hData);
     2389      FindText := pData^.Text;
     2390      GlobalUnlock(hData);
     2391      CloseClipboard;
     2392      //end CQ8300
     2393}
    22862394      Execute;
    22872395    end;
     
    23222430begin
    23232431  inherited;
    2324   DoAutoSave;
     2432  DoAutoSave(0);
    23252433  timAutoSave.Enabled := False;
    23262434  try
    23272435    SpellCheckForControl(memNewNote);
    23282436  finally
     2437    FChanged := True;
     2438    DoAutoSave(0);
    23292439    timAutoSave.Enabled := True;
    23302440  end;
     
    23342444begin
    23352445  inherited;
    2336   DoAutoSave;
     2446  DoAutoSave(0);
    23372447  timAutoSave.Enabled := False;
    23382448  try
    23392449    GrammarCheckForControl(memNewNote);
    23402450  finally
     2451    FChanged := True;
     2452    DoAutoSave(0);
    23412453    timAutoSave.Enabled := True;
    23422454  end;
     
    23992511  SigAction: integer;
    24002512  SavedDocID: string;
     2513  ARefDate: TFMDateTime;
    24012514begin
    24022515  inherited;
     
    24322545  if not LockConsultRequestAndNote(lstNotes.ItemIEN) then Exit;
    24332546  Exclusions := GetCurrentSigners(lstNotes.ItemIEN);
    2434   SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES);
     2547  ARefDate := StrToFloat(Piece(lstNotes.Items[lstNotes.ItemIndex], U, 3));
     2548  SelectAdditionalSigners(Font.Size, lstNotes.ItemIEN, SigAction, Exclusions, SignerList, CT_NOTES, ARefDate);
    24352549  with SignerList do
    24362550    begin
     
    27132827//===================  Added for sort/search enhancements ======================
    27142828procedure TfrmNotes.LoadNotes;
     2829const
     2830  INVALID_ID = -1;
     2831  INFO_ID = 1;
    27152832var
    27162833  tmpList: TStringList;
    27172834  ANode: TORTreeNode;
     2835  x,xx,noteId: integer;   // Text Search CQ: HDS00002856
     2836  Dest: TStrings;  // Text Search CQ: HDS00002856
     2837  KeepFlag: Boolean;  // Text Search CQ: HDS00002856
     2838  NoteCount, NoteMatches: integer;  // Text Search CQ: HDS00002856
    27182839begin
    27192840  tmpList := TStringList.Create;
     
    27592880        ListNotesForTree(tmpList, StrToIntDef(Status, 0), FMBeginDate, FMEndDate, Author, MaxDocs, TreeAscending);
    27602881        CreateListItemsforDocumentTree(FDocList, tmpList, StrToIntDef(Status, 0), GroupBy, TreeAscending, CT_NOTES);
     2882
     2883        // Text Search CQ: HDS00002856 ---------------------------------------
     2884        if FCurrentContext.SearchString<>''  then   // Text Search CQ: HDS00002856
     2885          begin
     2886            NoteMatches := 0;
     2887            Dest:=TStringList.Create;
     2888            NoteCount:=FDocList.Count-1;
     2889            if FDocList.Count>0 then
     2890              for x := FDocList.Count-1 downto 1 do begin;  // Don't do 0, because it's informational
     2891                KeepFlag:=False;
     2892                lblNotes.Caption:='Scanning '+IntToStr(NoteCount-x+1)+' of '+IntToStr(NoteCount)+', '+IntToStr(NoteMatches);
     2893                If NoteMatches=1 then lblNotes.Caption:=lblNotes.Caption+' match' else
     2894                                      lblNotes.Caption:=lblNotes.Caption+' matches';
     2895                frmSearchStop.lblSearchStatus.Caption := lblNotes.Caption;
     2896                frmSearchStop.lblSearchStatus.Repaint;
     2897                lblNotes.Repaint;
     2898                // Free up some ticks so they can click the "Stop" button
     2899                application.processmessages;
     2900                application.processmessages;
     2901                application.processmessages;
     2902                If SearchTextStopFlag = False then begin
     2903                  noteId := StrToIntDef(Piece(FDocList.Strings[x],'^',1),-1);
     2904                  if (noteId = INVALID_ID) or (noteId = INFO_ID) then
     2905                    Continue;
     2906                  CallV('TIU GET RECORD TEXT', [Piece(FDocList.Strings[x],'^',1)]);
     2907                  Dest.Assign(RPCBrokerV.Results);
     2908                  If Dest.Count > 0 then
     2909                     for xx := 0 to Dest.Count-1 do
     2910                     begin
     2911                      //Dest.Strings[xx] := StringReplace(Dest.Strings[xx],'#13',' ',[rfReplaceAll, rfIgnoreCase]);
     2912                      if Pos(Uppercase(FCurrentContext.SearchString),Uppercase(Dest.Strings[xx]))>0 then
     2913                        keepflag:=true;
     2914                     end;
     2915                  If KeepFlag=False then begin;
     2916                    if FDocList.Count >= x then
     2917                      FDocList.Delete(x);
     2918                    if (tmpList.Count >= x) and (x > 0) then
     2919                      tmpList.Delete(x-1);
     2920                  end else
     2921                    Inc(NoteMatches);
     2922                end;
     2923              end;
     2924            Dest.Free;
     2925          end;
     2926        // Text Search CQ: HDS00002856 ---------------------------------------
     2927
    27612928        UpdateTreeView(FDocList, tvNotes);
    27622929      end;
     
    30963263var
    30973264  WhyNot: string;
     3265  //Saved: boolean;
    30983266begin
    30993267  if EditingIndex <> -1 then
     
    32133381procedure TfrmNotes.ShowPCEButtons(Editing: boolean);
    32143382begin
     3383  if frmFrame.Timedout then Exit;
     3384
    32153385  FEditingNotePCEObj := Editing;
    32163386  if Editing or AnytimeEncounters then
     
    34243594    SetPiece(x, U, 5, NewAuth + ';' + AuthNameCheck);
    34253595    lstNotes.Items[EditingIndex] := x;
    3426     if AskCosignerForTitle(Title, Author) then
     3596    if AskCosignerForTitle(Title, Author, DateTime) then
    34273597    begin
    34283598      InfoBox(UpperCase(AuthNameCheck) + TX_COSIGNER_REQD, TC_COSIGNER_REQD, MB_OK);
     
    34953665procedure TfrmNotes.tvNotesExit(Sender: TObject);
    34963666begin
    3497   if Boolean(Hi(GetKeyState(VK_TAB))) and (not Boolean(Hi(GetKeyState(VK_SHIFT))))then
     3667  if IncSecond(FMousing,1) < Now then
    34983668  begin
    34993669    if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
     
    35033673      FindNextControl( cmdPCE, True, True, False).SetFocus;
    35043674  end;
     3675  FMousing := 0;
     3676end;
     3677
     3678procedure TfrmNotes.pnlReadExit(Sender: TObject);
     3679begin
     3680  inherited;
     3681  if IncSecond(FMousing,1) < Now then
     3682  begin
     3683    if (Screen.ActiveControl = frmFrame.pnlPatient) then
     3684      FindNextControl( tvNotes, True, True, False).SetFocus
     3685    else
     3686    if (Screen.ActiveControl = frmDrawers.pnlTemplatesButton) or
     3687        (Screen.ActiveControl = frmDrawers.pnlEncounterButton) or
     3688        (Screen.ActiveControl = cmdNewNote) or
     3689        (Screen.ActiveControl = cmdPCE) then
     3690      FindNextControl( frmDrawers.pnlTemplatesButton, False, True, False).SetFocus;
     3691  end;
     3692  FMousing := 0;
    35053693end;
    35063694
     
    35083696begin
    35093697  inherited;
    3510   if Boolean(Hi(GetKeyState(VK_TAB))) and
    3511      (not frmDrawers.pnlEncounterButton.CanFocus) and
    3512      (not Boolean(Hi(GetKeyState(VK_SHIFT)))) then
    3513     if (memPCEShow.CanFocus) then
    3514       memPCEShow.SetFocus
     3698  if IncSecond(FMousing,1) < Now then
     3699  begin
     3700    if (Screen.ActiveControl = lvNotes) or
     3701        (Screen.ActiveControl = memNote) then
     3702      frmFrame.pnlPatient.SetFocus
    35153703    else
    3516       frmFrame.pnlPatient.SetFocus;
     3704    if (Screen.ActiveControl = tvNotes) then
     3705      FindNextControl( frmFrame.pnlPatient, False, True, False).SetFocus;
     3706  end;
     3707  FMousing := 0;
    35173708end;
    35183709
     
    35203711begin
    35213712  FOldFramePnlPatientExit(Sender);
    3522   if Boolean(Hi(GetKeyState(VK_TAB))) then
     3713  if IncSecond(FMousing,1) < Now then
    35233714  begin
    35243715    if (Screen.ActiveControl = lvNotes) or
     
    35263717      FindNextControl( lvNotes, False, True, False).SetFocus;
    35273718  end;
     3719  FMousing := 0;
    35283720end;
    35293721
     
    35593751begin
    35603752  FOldDrawerPnlTemplatesButtonExit(Sender);
    3561   if Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT))) then
    3562     if memNewNote.CanFocus then
    3563       memNewNote.SetFocus
    3564     else if memNote.CanFocus then
    3565       memNote.SetFocus;
     3753  if Boolean(Hi(GetKeyState(VK_TAB))) and  (memNewNote.CanFocus) and
     3754     Boolean(Hi(GetKeyState(VK_SHIFT))) then
     3755    memNewNote.SetFocus
     3756  else
     3757    cmdNewNoteExit(Sender);
    35663758end;
    35673759
     
    35703762  FOldDrawerPnlEncounterButtonExit(Sender);
    35713763  cmdNewNoteExit(Sender);
     3764end;
     3765
     3766procedure TfrmNotes.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
     3767  Y: Integer);
     3768begin
     3769  inherited;
     3770  FMousing := Now;
    35723771end;
    35733772
     
    36063805  if Boolean(Hi(GetKeyState(VK_TAB))) then
    36073806    if Boolean(Hi(GetKeyState(VK_SHIFT))) then
    3608       if cmdPCE.CanFocus then
    3609         cmdPCE.SetFocus
    3610       else
    3611         cmdNewNote.SetFocus
     3807      cmdPCE.SetFocus
    36123808    else
    36133809      frmFrame.pnlPatient.SetFocus;
     
    36293825  if Boolean(Hi(GetKeyState(VK_TAB))) and
    36303826     Not Boolean(Hi(GetKeyState(VK_SHIFT))) then
    3631     memPCEShow.SetFocus;
    3632 end;
    3633 
    3634 procedure TfrmNotes.memNoteExit(Sender: TObject);
    3635 begin
    3636   inherited;
    3637   //Fix the Tab Order  Make Drawers Buttons Accessible
    3638   if Boolean(Hi(GetKeyState(VK_TAB))) then
    3639     if Boolean(Hi(GetKeyState(VK_SHIFT))) then
    3640     begin
    3641       if lvNotes.CanFocus then
    3642         lvNotes.SetFocus
    3643       else if tvNotes.CanFocus then
    3644         tvNotes.SetFocus;
    3645     end
    3646     else if frmDrawers.pnlTemplatesButton.CanFocus then
    3647       frmDrawers.pnlTemplatesButton.SetFocus
    3648 
    3649 end;
    3650 
    3651 procedure TfrmNotes.lvNotesExit(Sender: TObject);
    3652 begin
    3653   inherited;
    3654   if Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT))) then
    3655     if tvNotes.CanFocus then
    3656       tvNotes.SetFocus
     3827        if memPCEShow.Visible then //CQ7120
     3828           memPCEShow.SetFocus; //CQ7120
     3829end;
     3830
     3831procedure TfrmNotes.ViewInfo(Sender: TObject);
     3832begin
     3833  inherited;
     3834  frmFrame.ViewInfo(Sender);
     3835end;
     3836
     3837procedure TfrmNotes.mnuViewInformationClick(Sender: TObject);
     3838begin
     3839  inherited;
     3840  mnuViewDemo.Enabled := frmFrame.pnlPatient.Enabled;
     3841  mnuViewVisits.Enabled := frmFrame.pnlVisit.Enabled;
     3842  mnuViewPrimaryCare.Enabled := frmFrame.pnlPrimaryCare.Enabled;
     3843  mnuViewMyHealtheVet.Enabled := not (Copy(frmFrame.laMHV.Hint, 1, 2) = 'No');
     3844  mnuInsurance.Enabled := not (Copy(frmFrame.laVAA2.Hint, 1, 2) = 'No');
     3845  mnuViewFlags.Enabled := frmFrame.lblFlag.Enabled;
     3846  mnuViewRemoteData.Enabled := frmFrame.lblCirn.Enabled;
     3847  mnuViewReminders.Enabled := frmFrame.pnlReminders.Enabled;
     3848  mnuViewPostings.Enabled := frmFrame.pnlPostings.Enabled;
    36573849end;
    36583850
     
    36623854
    36633855finalization
    3664   uPCEEdit.Free;
    3665   uPCEShow.Free;
     3856  if (uPCEEdit <> nil) then uPCEEdit.Free; //CQ7012 Added test for nil
     3857  if (uPCEShow <> nil) then uPCEShow.Free; //CQ7012 Added test for nil
    36663858
    36673859end.
Note: See TracChangeset for help on using the changeset viewer.