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/fNoteProps.pas

    r459 r460  
    1 unit fNoteProps;                           
     1unit fNoteProps;
    22
    33interface
     
    55uses
    66  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    7   StdCtrls, ORDtTm, ORCtrls, ExtCtrls, rTIU, uConst, uTIU, ORFn, ORNet;
     7  StdCtrls, ORDtTm, ORCtrls, ExtCtrls, rTIU, uConst, uTIU, ORFn, ORNet,
     8  ComCtrls, Buttons;
    89
    910type
     11  {This object holds a List of Actions as Returned VIA the RPCBroker}
     12  TPRFActions = class(TObject)
     13  private
     14    FPRFActionList : TStringList;
     15  public
     16    //procedure to show the Action in a ListView, requires a listview parameter
     17    procedure ShowActionsOnList(DisplayList : TCaptionListView);
     18    //procedure to load the actions, this will call the RPC
     19    procedure Load(TitleIEN : Int64; DFN : String);
     20    //returns true if the Action at the Index passed is associated with a note
     21    function SelActionHasNote(lstIndex : integer) : boolean;
     22    //return the Action IEN at the Index passed
     23    function GetActionIEN(lstIndex : integer) : String;
     24    //return the PRF IEN at the Index passed
     25    function GetPRF_IEN(lstIndex : integer) : integer;
     26    constructor Create();
     27    destructor Destroy(); override;
     28  end;
     29
    1030  TfrmNoteProperties = class(TForm)
    1131    lblNewTitle: TLabel;
     
    4262    lblProcDateTime: TOROffsetLabel;
    4363    btnShowList: TButton;
     64    pnlPRF: TORAutoPanel;
     65    lblPRF: TLabel;
     66    Bevel1: TBevel;
     67    lvPRF: TCaptionListView;
     68    btnDetails: TButton;
    4469    procedure FormShow(Sender: TObject);
    4570    procedure cboNewTitleNeedData(Sender: TObject; const StartFrom: String;
     
    6388    procedure FormResize(Sender: TObject);
    6489    procedure calNoteEnter(Sender: TObject);
     90    procedure FormDestroy(Sender: TObject);
     91    procedure btnDetailsClick(Sender: TObject);
     92    procedure lstRequestsChange(Sender: TObject);
    6593  private
    6694    FCosignIEN: Int64;      // store cosigner that was passed in
     
    81109    FProcDateTime: TFMDateTime;
    82110    FCPStatusFlag: integer;
     111    FPRFActions : TPRFActions;
     112    FStarting: boolean;
    83113    procedure SetCosignerRequired(DoSetup: boolean);
    84114    procedure FormatRequestList;
    85115    procedure ShowRequestList(ShouldShow: Boolean);
    86116    procedure ShowSurgCaseList(ShouldShow: Boolean);
     117    procedure ShowPRFList(ShouldShow: Boolean);
    87118    procedure ShowClinProcFields(YesNo: boolean);
     119    procedure SetGenericFormSize;
    88120    procedure UMDelayEvent(var Message: TMessage); message UM_DELAYEVENT;
    89121  public
    90122    { Public declarations }
     123
    91124  end;
     125
    92126
    93127function ExecuteNoteProperties(var ANote: TEditNoteRec; CallingTab: integer; IDNoteTitlesOnly,
     
    101135 TC_INACTIVE_USER     = 'Inactive User Alert';
    102136
     137 PIXEL_SPACE = 6;
     138
    103139implementation
    104140
    105141{$R *.DFM}
    106142
    107 uses uCore, rCore, rConsults, uConsults, rSurgery, uAccessibleListBox;
     143uses uCore, rCore, rConsults, uConsults, rSurgery, uAccessibleListBox, fRptBox;
    108144
    109145{ Initial values in ANote
     
    133169  TX_REQ_REQUEST       = CRLF + 'This title requires the selection of an associated consult request.';
    134170  TX_REQ_SURGCASE      = CRLF + 'This title requires the selection of an associated surgery case.';
     171  TX_REQ_PRF_ACTION    = CRLF + 'Notes of this title require the selection of a patient record flag action.';
     172  TX_REQ_PRF_NOTE      = CRLF + 'This action has already been assigned to another note.';
    135173  TX_NO_FUTURE         = CRLF + 'A reference date/time in the future is not allowed.';
    136174  TX_COS_SELF          = CRLF + 'You cannot make yourself a cosigner.';
     
    153191  ACTIVE_STATUS = 'ACTIVE,PENDING,SCHEDULED';
    154192
     193  PRF_LABEL = 'Which Patient Record Flag Action should this Note be linked to?';
     194
     195  FLAG_NAME = 1;
     196  PRF_IEN = 2;
     197  ACTION_NAME = 3;
     198  ACTION_IEN = 4;
     199  ACTION_DATE_I = 5;
     200  ACTION_DATE = 6;
     201  NOTE_IEN = 7;
     202
    155203
    156204var
     
    176224      FIsClinProcNote := (AClassName = DCL_CLINPROC);
    177225      FCPStatusFlag := CPStatusFlag;
    178       uShowUnresolvedOnly := False;
     226      //uShowUnresolvedOnly := False;                      //v26.5 (RV)
     227      uShowUnresolvedOnly := True;                         //v26.5 (RV)
    179228      if ANote.DocType <> TYP_ADDENDUM then
    180229        begin
     
    210259           CT_NOTES:      begin
    211260                            Caption := 'Progress Note Properties';
    212                             if ANote.IsNewNote and UnresolvedConsultsExist then
    213                               uShowUnresolvedOnly := InfoBox(TX_UNRESOLVED_CONSULTS, 'Unresolved Consults Exist',
    214                                 MB_YESNO or MB_ICONQUESTION) = IDYES;
     261                            if ANote.IsNewNote then
     262                            begin
     263                              GetUnresolvedConsultsInfo; // v26.5 (RV) removed nag screen
     264                            end;
    215265                            cboNewTitle.InitLongList('');
    216266                            cboAuthor.InitLongList(ANote.AuthorName);
     
    235285        end;
    236286      ShowClinProcFields(FIsClinProcNote);
     287      FStarting := True;
    237288      if ANote.Title > 0 then cboNewTitle.SelectByIEN(ANote.Title);
    238289      if (ANote.Title > 0) and (cboNewTitle.ItemIndex < 0)
    239290        then cboNewTitle.SetExactByIEN(ANote.Title, ANote.TitleName);
     291      FStarting := False;
    240292      calNote.FMDateTime := ANote.DateTime;
    241293      // setup cosigner fields
     
    248300      SetCosignerRequired(True);
    249301      // setup package fields
     302      SetGenericFormSize;
    250303      case FCallingTab of
    251304        CT_CONSULTS:  begin
    252305                        ShowRequestList(False);
    253306                        ShowSurgCaseList(False);
     307                        ShowPRFList(False);
    254308                      end;
    255309        CT_SURGERY :  begin
    256310                        ShowRequestList(False);
    257311                        ShowSurgCaseList(False);
     312                        ShowPRFList(False);
    258313                      end;
    259314        CT_NOTES   :  begin
    260                         if IsConsultTitle(ANote.Title) then
    261                           begin
    262                             ShowRequestList(True);
    263                             ShowSurgCaseList(False);
    264                           end
    265                         else if IsSurgeryTitle(ANote.Title) then
    266                           begin
    267                             ShowSurgCaseList(True);
    268                             ShowRequestList(False);
    269                           end
    270                         else
    271                           begin
    272                             ShowRequestList(False);
    273                             ShowSurgCaseList(False);
    274                           end;
     315                        with uUnresolvedConsults do                          // v26.5 (RV)
     316                          ShowRequestList(IsConsultTitle(ANote.Title) or
     317                            (UnresolvedConsultsExist and ShowNagScreen));    // v26.5 (RV)
     318                        ShowSurgCaseList(IsSurgeryTitle(ANote.Title));
     319                        ShowPRFList(IsPRFTitle(ANote.Title));
    275320                      end;
    276321      end;
     
    283328      end;
    284329      cboNewTitle.Caption := lblNewTitle.Caption;
     330      FStarting := True;
    285331      cboNewTitleExit(frmNoteProperties);        // force display of request/case list
     332      FStarting := False;
    286333      if uShowUnresolvedOnly then                // override previous display if SHOW ME clicked on entrance
    287334      begin
    288         cboNewTitle.ItemIndex := -1;
     335        //cboNewTitle.ItemIndex := -1;      CQ#7587, v26.25 - RV
    289336        uShowUnresolvedOnly := not uShowUnresolvedOnly;
    290337        FormatRequestList;
     
    351398                              PkgPtr := PKG_SURGERY;
    352399                              PkgRef := IntToStr(PkgIEN) + ';' + PkgPtr;
     400                            end
     401                          else if pnlPRF.Visible then //PRF
     402                            begin
     403                              PRF_IEN := FPRFActions.GetPRF_IEN(lvPRF.ItemIndex);
     404                              ActionIEN := FPRFActions.GetActionIEN(lvPRF.ItemIndex);
    353405                            end;
    354406                        end;
     
    392444  begin
    393445    if cboNewTitle.ItemIEN = 0
    394       then lblCosigner.Visible := AskCosignerForTitle(FDocType,            cboAuthor.ItemIEN)
    395       else lblCosigner.Visible := AskCosignerForTitle(cboNewTitle.ItemIEN, cboAuthor.ItemIEN);
     446      then lblCosigner.Visible := AskCosignerForTitle(FDocType,            cboAuthor.ItemIEN, calNote.FMDateTime)
     447      else lblCosigner.Visible := AskCosignerForTitle(cboNewTitle.ItemIEN, cboAuthor.ItemIEN, calNote.FMDateTime);
    396448  end;
    397449  cboCosigner.Visible := lblCosigner.Visible;
     
    427479  SavedIEN: integer;
    428480begin
     481  ShouldShow := ShouldShow and (FCallingTab = CT_NOTES);
    429482  if FDocType = TYP_ADDENDUM then ShouldShow := False;
     483  pnlConsults.Visible := ShouldShow;
    430484  if ShouldShow then
    431485  begin
    432486    SavedIEN := lstRequests.ItemIEN;
    433     for i := 0 to Pred(ControlCount) do
    434       if Controls[i].Tag = 1 then Controls[i].Visible := True;
    435     pnlConsults.Align := alBottom;
    436     ClientHeight := cboCosigner.Top + cboCosigner.Height + 6 + pnlConsults.Height;
     487    ClientHeight := cboCosigner.Top + cboCosigner.Height + PIXEL_SPACE + pnlConsults.Height;
    437488    lstRequests.Items.Clear;
    438489    if uConsultsList.Count = 0 then ListConsultRequests(uConsultsList);
     
    451502    lblConsult1.Visible := (cboNewTitle.ItemIndex > -1);
    452503    lstRequests.SelectByIEN(SavedIEN);
    453   end else
    454   begin
    455     for i := 0 to Pred(ControlCount) do
    456       if Controls[i].Tag = 1 then Controls[i].Visible := False;
    457     ClientHeight := cboCosigner.Top + cboCosigner.Height + 6;
    458   end;
     504    btnDetails.Enabled := (lstRequests.ItemIndex > -1);
     505  end
    459506end;
    460507
    461508procedure TfrmNoteProperties.ShowSurgCaseList(ShouldShow: Boolean);
    462509{ called initially & whenever title changes }
    463 var
    464   i: Integer;
    465 begin
     510begin
     511  pnlSurgery.Visible := ShouldShow;
    466512  if FDocType = TYP_ADDENDUM then ShouldShow := False;
    467513  if ShouldShow then
    468514  begin
    469     for i := 0 to Pred(ControlCount) do
    470       if Controls[i].Tag = 2 then Controls[i].Visible := True;
    471     pnlSurgery.Align := alBottom;
    472     ClientHeight := cboCosigner.Top + cboCosigner.Height + 6 + pnlSurgery.Height;
     515    ClientHeight := cboCosigner.Top + cboCosigner.Height + PIXEL_SPACE + pnlSurgery.Height;
    473516    if lstSurgery.Items.Count = 0 then ListSurgeryCases(lstSurgery.Items);
    474   end else
    475   begin
    476     for i := 0 to Pred(ControlCount) do
    477       if Controls[i].Tag = 2 then Controls[i].Visible := False;
    478     ClientHeight := cboCosigner.Top + cboCosigner.Height + 6;
    479   end;
     517  end
    480518end;
    481519
     
    503541
    504542procedure TfrmNoteProperties.cboNewTitleMouseClick(Sender: TObject);
     543const
     544  TX_NEED_CONSULT_TITLE = 'You currently have unresolved consults awaiting completion.' + CRLF +
     545                          'The selected title cannot be used to complete consults.' + CRLF +
     546                          'You must select a Consults title to complete a consult.' + CRLF + CRLF +
     547                          'Answer "YES" to continue with this title and not complete a consult.' + CRLF +
     548                          'Answer "NO" to select a different title.' + CRLF + CRLF +
     549                          'Do you want to use this title and continue?';                         
     550  TC_NOT_CONSULT_TITLE = 'Not a consult title';
     551var
     552  WantsToCompleteConsult: boolean;
     553  ConsultTitle: boolean;
    505554begin
    506555  with cboNewTitle do
     
    515564      CT_CONSULTS:  ;  // no action
    516565      CT_SURGERY :  ;  // no action
    517       CT_NOTES   :  if IsConsultTitle(cboNewTitle.ItemIEN) then
    518                       begin
    519                         ShowSurgCaseList(False);
    520                         ShowRequestList(True);
    521                       end
    522                     else if IsSurgeryTitle(cboNewTitle.ItemIEN) then
    523                       begin
    524                         ShowRequestList(False);
    525                         ShowSurgCaseList(True);
    526                       end
    527                     else
    528                       begin
    529                         ShowRequestList(False);
    530                         ShowSurgCaseList(False);
    531                       end;
     566      CT_NOTES   :  begin            // v26.5 (RV) main changes here
     567                      WantsToCompleteConsult := False;
     568                      ConsultTitle := IsConsultTitle(cboNewTitle.ItemIEN);
     569                      if (pnlConsults.Visible) and
     570                         (lstRequests.Items.Count > 0) and
     571                         (not FStarting) and
     572                         (*(lstRequests.ItemID <> '') and*)
     573                         (not ConsultTitle) then
     574                          WantsToCompleteConsult := (InfoBox(TX_NEED_CONSULT_TITLE,
     575                                                            TC_NOT_CONSULT_TITLE,
     576                                                            MB_ICONWARNING or MB_YESNO or MB_DEFBUTTON2) = IDNO);
     577                      if WantsToCompleteConsult and (not ConsultTitle) then cboNewTitle.ItemIndex := -1;
     578                      SetGenericFormSize;
     579                      ShowRequestList(WantsToCompleteConsult or ConsultTitle);
     580                      ShowSurgCaseList(IsSurgeryTitle(cboNewTitle.ItemIEN));
     581                      ShowPRFList(IsPRFTitle(cboNewTitle.ItemIEN));
     582                    end;
    532583    end;
    533584  SetCosignerRequired(True);
     
    573624//var x: string;
    574625begin
    575   with cboCosigner do if Text = '' then ItemIndex := -1;
     626  with cboCosigner do if ((Text = '') or (ItemIEN = 0)) then
     627  begin
     628    ItemIndex := -1;
     629    FCosignIEN := 0;
     630    FCosignName := '';
     631    exit;
     632  end;
    576633  FCosignIEN := cboCosigner.ItemIEN;
    577634  FCosignName := Piece(cboCosigner.Items[cboCosigner.ItemIndex], U, 2);
     
    602659                       ShowRequestList(False);
    603660                       ShowSurgCaseList(False);
     661                       ShowPRFList(False);
    604662                    end;
    605663  end;*)
    606664  SetCosignerRequired(False);
    607665  ErrMsg := '';
    608    if cboNewTitle.ItemIEN = 0 then
    609     ErrMsg := ErrMsg + TX_REQ_TITLE
    610     //code added 12/2002  check note parm - one per visit  GRE
    611   else if OneNotePerVisit(CboNewTitle.ItemIEN, Patient.DFN, Encounter.VisitStr)then
    612       ErrMsg := ErrMsg + TX_ONE_NOTE_PER_VISIT1
    613                        + Piece(cboNewTitle.Items[cboNewTitle.ItemIndex],U,2)
    614                        + TX_ONE_NOTE_PER_VISIT2
    615     else
     666  if cboNewTitle.ItemIEN = 0 then
     667    ErrMsg := ErrMsg + TX_REQ_TITLE ;
     668  if ErrMsg = '' then
     669    begin
     670      if FDocType = TYP_ADDENDUM then
     671        begin
     672          if OneNotePerVisit(TYP_ADDENDUM, Patient.DFN, Encounter.VisitStr)then
     673            ErrMsg := ErrMsg + TX_ONE_NOTE_PER_VISIT1
     674                     + 'Addendum to ' + Piece(cboNewTitle.Items[cboNewTitle.ItemIndex],U,2)
     675                     + TX_ONE_NOTE_PER_VISIT2;
     676        end
     677        //code added 12/2002  check note parm - one per visit  GRE
     678      else if OneNotePerVisit(CboNewTitle.ItemIEN, Patient.DFN, Encounter.VisitStr)then
     679            ErrMsg := ErrMsg + TX_ONE_NOTE_PER_VISIT1
     680                     + Piece(cboNewTitle.Items[cboNewTitle.ItemIndex],U,2)
     681                     + TX_ONE_NOTE_PER_VISIT2;
     682    end;
     683  if ErrMsg = '' then
    616684    begin
    617685      if FIDNoteTitlesOnly then
     
    626694          else if ((pnlSurgery.Visible) and (lstSurgery.ItemIndex < 0)) then
    627695            ErrMsg := ErrMsg + TX_REQ_SURGCASE
     696          else if (pnlPRF.Visible) then
     697          begin
     698            if (lvPRF.ItemIndex < 0) then
     699              ErrMsg := ErrMsg + TX_REQ_PRF_ACTION
     700            else if FPRFActions.SelActionHasNote(lvPRF.ItemIndex) then
     701              ErrMsg := ErrMsg + TX_REQ_PRF_NOTE;
     702          end;
    628703        end;
    629704    end;
     
    635710       if (cboCosigner.ItemIEN = 0)     then ErrMsg := ErrMsg + TX_REQ_COSIGNER;
    636711      //if (cboCosigner.ItemIEN = User.DUZ) then ErrMsg := TX_COS_SELF;  // (CanCosign will do this check)
    637       if (cboCosigner.ItemIEN > 0) and not CanCosign(cboNewTitle.ItemIEN, FDocType, cboCosigner.ItemIEN)
     712      if (cboCosigner.ItemIEN > 0) and not CanCosign(cboNewTitle.ItemIEN, FDocType, cboCosigner.ItemIEN, calNote.FMDateTime)
    638713        then ErrMsg := cboCosigner.Text + TX_COS_AUTH;
    639714        //code added 02/2003  check if User is Inactive   GRE
     
    719794    else
    720795      Caption := SHOW_UNRESOLVED;
    721   ShowRequestList(True);
     796  with uUnresolvedConsults do if (UnresolvedConsultsExist and ShowNagScreen) then pnlConsults.Visible := TRUE;  //v26.27 (RV)
     797  ShowRequestList(pnlConsults.Visible);      //v26.5 (RV)
     798  //ShowRequestList(True);                   //v26.5 (RV)
    722799end;
    723800
     
    739816end;
    740817
     818procedure TfrmNoteProperties.ShowPRFList(ShouldShow: Boolean);
     819begin
     820  pnlPRF.Visible := ShouldShow and not (FDocType = TYP_ADDENDUM);
     821  if pnlPRF.Visible then
     822  begin
     823    ClientHeight := cboCosigner.Top + cboCosigner.Height + PIXEL_SPACE + pnlPRF.Height;
     824    if FPRFActions = nil then
     825      FPRFActions := TPRFActions.Create;
     826    FPRFActions.Load(cboNewTitle.ItemIEN,Patient.DFN);
     827    if RPCBrokerV.Results.Count <> 0 then
     828      lblPRF.Caption := PRF_LABEL
     829    else
     830      lblPRF.Caption := 'No Linkable Actions for this Patient and/or Title.';
     831    FPRFActions.ShowActionsOnList(lvPRF);
     832    //Fix for CQ: 6926
     833    lvPRF.Columns.BeginUpdate;
     834    lvPRF.Columns.EndUpdate;
     835    //End Fix for CQ: 6926
     836  end
     837end;
     838
     839procedure TfrmNoteProperties.SetGenericFormSize;
     840begin
     841  ClientHeight := cboCosigner.Top + cboCosigner.Height + PIXEL_SPACE;
     842end;
     843
     844{ TPRFActions }
     845
     846constructor TPRFActions.Create;
     847begin
     848  inherited;
     849  FPRFActionList := TStringList.Create;
     850end;
     851
     852destructor TPRFActions.Destroy;
     853begin
     854  FPRFActionList.Free;
     855  inherited;
     856end;
     857
     858function TPRFActions.GetActionIEN(lstIndex: integer): String;
     859begin
     860  Result := Piece(FPRFActionList[lstIndex],U,ACTION_IEN);
     861end;
     862
     863function TPRFActions.GetPRF_IEN(lstIndex: integer): integer;
     864begin
     865  Result := StrToInt(Piece(FPRFActionList[lstIndex],U,PRF_IEN));
     866end;
     867
     868procedure TPRFActions.Load(TitleIEN : Int64; DFN : String);
     869begin
     870  CallV('TIU GET PRF ACTIONS', [TitleIEN,DFN]);
     871  FPRFActionList.Assign(RPCBrokerV.Results);
     872end;
     873
     874function TPRFActions.SelActionHasNote(lstIndex: integer): boolean;
     875begin
     876  Result := false;
     877  if Piece(FPRFActionList[lstIndex],U,NOTE_IEN) <> '' then
     878    Result := true;
     879end;
     880
     881procedure TPRFActions.ShowActionsOnList(DisplayList: TCaptionListView);
     882var
     883  i : integer;
     884  ListItem: TListItem;
     885begin
     886  DisplayList.Clear;
     887  for i := 0 to FPRFActionList.Count-1 do
     888  begin
     889    //Caption="Text for Screen Reader" SubItem1=Flag SubItem2=Date SubItem3=Action SubItem4=Note
     890    ListItem := DisplayList.Items.Add;
     891    ListItem.Caption := PRF_LABEL; //Screen readers don't read the first column title on a listview.
     892    ListItem.SubItems.Add(Piece(FPRFActionList[i],U,FLAG_NAME));
     893    ListItem.SubItems.Add(Piece(FPRFActionList[i],U,ACTION_DATE));
     894    ListItem.SubItems.Add(Piece(FPRFActionList[i],U,ACTION_NAME));
     895    if SelActionHasNote(i) then
     896      ListItem.SubItems.Add('Yes')
     897    else
     898      ListItem.SubItems.Add('No');
     899  end;
     900end;
     901
     902procedure TfrmNoteProperties.FormDestroy(Sender: TObject);
     903begin
     904  FPRFActions.Free;
     905end;
     906
     907procedure TfrmNoteProperties.btnDetailsClick(Sender: TObject);
     908var
     909  ConsultDetail: TStringList;
     910begin
     911  if lstRequests.ItemIEN <= 0 then exit;
     912  ConsultDetail := TStringList.Create;
     913  try
     914    LoadConsultDetail(ConsultDetail, lstRequests.ItemIEN) ;
     915    ReportBox(ConsultDetail, 'Consult Details: #' + lstRequests.ItemID + ' - ' +
     916               Piece(lstRequests.Items[lstRequests.ItemIndex], U, 3), TRUE);
     917  finally
     918    ConsultDetail.Free;
     919  end;
     920end;
     921
     922procedure TfrmNoteProperties.lstRequestsChange(Sender: TObject);
     923begin
     924  btnDetails.Enabled := (lstRequests.ItemIEN > 0);
     925end;
     926
    741927end.
Note: See TracChangeset for help on using the changeset viewer.