Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/Orders/fODDiet.pas

    r456 r829  
    55uses
    66  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    7   fODBase, ComCtrls, ExtCtrls, StdCtrls, Grids, ORCtrls, ORDtTm, ORFn, uConst;
     7  fODBase, ComCtrls, ExtCtrls, StdCtrls, Grids, ORCtrls, ORDtTm, ORFn, uConst,
     8  VA508AccessibilityManager;
    89
    910type
     
    161162    FIsolationID: string;
    162163    FTabChanging: Boolean;
     164    FGiveMultiTabMessage: boolean;
    163165    procedure DietCheckForNPO;
    164166    procedure DietCheckForTF;
     
    192194    procedure OPDietCheckForNPO;
    193195    procedure OPDietCheckForTF;
    194     function PatientHasRecurringMeals(var MealList: TStringList; MealType: string = ''): boolean;
     196    function  PatientHasRecurringMeals(var MealList: TStringList; MealType: string = ''): boolean;
     197    //procedure CheckForAutoDCOrders(EvtID: integer; CurrentText: string; var CancelText: string; Sender: TObject);
    195198  protected
    196199    procedure InitDialog; override;
     
    210213{$R *.DFM}
    211214
    212 uses uCore, rODBase, rODDiet, rCore, rOrders, fODDietLT, uAccessibleStringGrid, DateUtils;
     215uses uCore, rODBase, rODDiet, rCore, rOrders, fODDietLT, DateUtils,
     216  fOrders, uODBase, VA508AccessibilityRouter;
    213217
    214218const
     
    314318begin
    315319  inherited;
     320  FGiveMultiTabMessage := ScreenReaderSystemActive;
    316321  AbortOrder := False;
    317322  uRecurringMealList := TStringList.Create;
     
    366371        end;
    367372    end;
    368   TAccessibleStringGrid.WrapControl(grdSelected);
    369373end;
    370374
    371375procedure TfrmODDiet.FormDestroy(Sender: TObject);
    372376begin
    373   TAccessibleStringGrid.UnwrapControl(grdSelected);
    374377  TFClearGrid;
    375378  uRecurringMealList.Free;
     
    667670end;
    668671
    669 procedure TfrmODDiet.nbkDietChange(Sender: TObject);
    670 var
    671   x, CxMsg: string ;
    672   i: integer;
    673   AStringList: TStringList;
     672(*procedure TfrmODDiet.CheckForAutoDCOrders(EvtID: integer; CurrentText: string; var CancelText: string; Sender: TObject);
    674673const
    675 //  TX_CX_CUR = 'A new diet order will CANCEL and REPLACE this current diet:' + CRLF + CRLF;
    676674  TX_CX_CUR = 'A new diet order will CANCEL and REPLACE this current diet now unless' + CRLF +
    677675              'you specify a start date for when the new diet should replace the current' + CRLF +
    678676              'diet:' + CRLF + CRLF;
    679677  TX_CX_FUT = 'A new diet order with no expiration date will CANCEL and REPLACE these diets:' + CRLF + CRLF;
     678  TX_CX_DELAYED1 =  'There are other delayed diet orders for this release event:';
     679  TX_CX_DELAYED2 =  'This new diet order may cancel and replace those other diets' + CRLF +
     680                    'IMMEDIATELY ON RELEASE, unless you either:' + CRLF + CRLF +
     681
     682                    '1. Specify an expiration date/time for this order that will' + CRLF +
     683                    '   be prior to the start date/time of those other orders; or' + CRLF + CRLF +
     684
     685                    '2. Specify a later start date/time for this order for when you' + CRLF +
     686                    '   would like it to cancel and replace those other orders.';
     687
     688var
     689  i: integer;
     690  AStringList: TStringList;
     691  AList: TList;
     692  x, PtEvtIFN, PtEvtName: string;
     693  //AResponse: TResponse;
     694begin
     695  if Self.EvtID = 0 then   // check current and future released diets
     696  begin
     697    x := CurrentText;
     698    if Piece(x, #13, 1) <> 'Current Diet:  ' then
     699    begin
     700      AStringList := TStringList.Create;
     701      try
     702        AStringList.Text := x;
     703        CancelText := TX_CX_CUR + #9 + Piece(AStringList[0], ':', 1) + ':' + CRLF + CRLF
     704                 + #9 + Copy(AStringList[0], 16, 99) + CRLF;
     705        if AStringList.Count > 1 then
     706        begin
     707          CancelText := CancelText + CRLF + CRLF +
     708                   TX_CX_FUT + #9 + Piece(AStringList[1], ':', 1) + ':' + CRLF + CRLF
     709                   + #9 + Copy(AStringList[1], 22, 99) + CRLF;
     710          if AStringList.Count > 2 then
     711          for i := 2 to AStringList.Count - 1 do
     712            CancelText := CancelText + #9 + TrimLeft(AStringList[i]) + CRLF;
     713        end;
     714      finally
     715        AStringList.Free;
     716      end;
     717    end;
     718  end
     719  else if Sender is TButton then     // delayed orders code here - on accept only
     720  begin
     721    //AResponse := Responses.FindResponseByName('STOP', 1);
     722    //if (AResponse <> nil) and (AResponse.EValue <> '') then exit;
     723    AList := TList.Create;
     724    try
     725      PtEvtIFN := IntToStr(frmOrders.TheCurrentView.EventDelay.PtEventIFN);
     726      PtEvtName := frmOrders.TheCurrentView.EventDelay.EventName;
     727      LoadOrdersAbbr(AList, frmOrders.TheCurrentView, PtEvtIFN);
     728      for i := AList.Count - 1 downto 0 do
     729      begin
     730        if TOrder(Alist.Items[i]).DGroup <> Self.DisplayGroup then
     731        begin
     732          TOrder(AList.Items[i]).Free;
     733          AList.Delete(i);
     734        end;
     735      end;
     736      if AList.Count > 0 then
     737      begin
     738        x := '';
     739        RetrieveOrderFields(AList, 0, 0);
     740        CancelText := TX_CX_DELAYED1 + CRLF + CRLF + 'Release event: ' + PtEvtName;
     741        for i := 0 to AList.Count - 1 do
     742          with TOrder(AList.Items[i]) do
     743          begin
     744            x := x + #9 + Text + CRLF;
     745(*            if StartTime <> '' then
     746              x := #9 + x + 'Start:   ' + StartTime + CRLF
     747            else
     748              x := #9 + x + 'Ordered: ' + FormatFMDateTime('mmm dd,yyyy@hh:nn', OrderTime) + CRLF;*)
     749(*          end;
     750        CancelText := CancelText + CRLF + CRLF + x;
     751        CancelText := CancelText + CRLF + CRLF + TX_CX_DELAYED2;
     752      end;
     753    finally
     754      with AList do for i := 0 to Count - 1 do TOrder(Items[i]).Free;
     755      AList.Free;
     756    end;
     757  end;
     758end;*)
     759
     760procedure TfrmODDiet.nbkDietChange(Sender: TObject);
     761var
     762  x: string ;
     763  CxMsg: string;
    680764begin
    681765  inherited;
     
    693777    AllowQuickOrder := True;
    694778    x := CurrentDietText;
    695     if Piece(x, #13, 1) <> 'Current Diet:  ' then
    696     begin
    697       AStringList := TStringList.Create;
    698       try
    699         AStringList.Text := x;
    700         CxMsg := TX_CX_CUR + #9 + Piece(AStringList[0], ':', 1) + ':' + CRLF + CRLF
    701                  + #9 + Copy(AStringList[0], 16, 99) + CRLF;
    702         if AStringList.Count > 1 then
    703         begin
    704           CxMsg := CxMsg + CRLF + CRLF +
    705                    TX_CX_FUT + #9 + Piece(AStringList[1], ':', 1) + ':' + CRLF + CRLF
    706                    + #9 + Copy(AStringList[1], 22, 99) + CRLF;
    707           if AStringList.Count > 2 then
    708           for i := 2 to AStringList.Count - 1 do
    709             CxMsg := CxMsg + #9 + TrimLeft(AStringList[i]) + CRLF;
    710         end;
    711       finally
    712         AStringList.Free;
    713       end;
    714     end;
     779    CheckForAutoDCDietOrders(Self.EvtID, Self.DisplayGroup, x, CxMsg, nbkDiet);
    715780    if CxMsg <> '' then
    716781    begin
     
    745810          end
    746811        else
    747           cboOPTFRecurringMeals.Items.Assign(uRecurringMealList);
     812          FastAssign(uRecurringMealList, cboOPTFRecurringMeals.Items);
    748813    end;
    749814    cboOPTFRecurringMeals.Visible := not OrderForInpatient;
     
    781846          end
    782847        else
    783           cboOPELRecurringMeals.Items.Assign(uRecurringMealList);
     848          FastAssign(uRecurringMealList, cboOPELRecurringMeals.Items);
    784849      end
    785850    else if (StrToIntDef(uDietParams.EarlyIEN, 0) = 0) or (StrToIntDef(uDietParams.LateIEN, 0) = 0) then
     
    828893        end
    829894      else
    830         cboOPAORecurringMeals.Items.Assign(uRecurringMealList);
     895        FastAssign(uRecurringMealList, cboOPAORecurringMeals.Items);
    831896    end;
    832897    cboOPAORecurringMeals.Visible := not OrderForInpatient;
     
    854919       AllowQuickOrder := False;
    855920       ResetControlsOP;
    856        cboOPDietAvail.Items.AddStrings(SubsetOfOPDiets);
     921       FastAddStrings(SubsetOfOPDiets, cboOPDietAvail.Items);
    857922       { TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? }
    858923       chkOPCancelTubefeeding.State := cbGrayed;
     
    873938       LoadDietQuickList(cboOPDietAvail.Items, 'MEAL');              // use D.G. short name here
    874939       cboOPDietAvail.InsertSeparator;
    875        cboOPDietAvail.Items.AddStrings(SubsetOfOPDiets);
     940       FastAddStrings(SubsetOfOPDiets, cboOPDietAvail.Items);
    876941       cboOPDietAvail.SelectByIEN(uDietParams.OPDefaultDiet);
    877942       { TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? }
     
    886951  Changing := False;                                       // Changing reset
    887952  StatusText('');
     953  if FGiveMultiTabMessage then  // CQ#15483
     954  begin
     955    FGiveMultiTabMessage := FALSE;
     956    GetScreenReader.Speak('Multi Tab Form');
     957  end;
    888958end;
    889959
     
    16151685        end
    16161686      else
    1617         cboOPELRecurringMeals.Items.Assign(uRecurringMealList);
     1687        FastAssign(uRecurringMealList, cboOPELRecurringMeals.Items);
    16181688    end;
    16191689  Changing := False;
     
    21422212var
    21432213  DCOrder: TOrder;
    2144   AResponse, AnotherResponse: TResponse;
    21452214  LateTrayFields: TLateTrayFields;
    2146   NewOrder: TOrder;
    2147   CanSign: Integer;
     2215  //CxMsg: string;
    21482216begin
    21492217  // these actions should be before inherited, so that InitDialog doesn't clear properties
     
    21512219  if nbkDiet.ActivePage = pgeDiet then
    21522220  begin
     2221(*    if Self.EvtID <> 0 then
     2222    begin
     2223      CheckForAutoDCDietOrders(Self.EvtID, Self.DisplayGroup, '', CxMsg, cmdAccept);
     2224      if CxMsg <> '' then
     2225      begin
     2226        if InfoBox(CxMsg + CRLF + CRLF +
     2227           'Have you done either of the above?', 'Possible delayed order conflict',
     2228           MB_ICONWARNING or MB_YESNO) = ID_NO
     2229           then exit;
     2230      end;
     2231    end;*)
    21532232    // create dc tubefeeding order
    21542233    if chkCancelTubeFeeding.State = cbChecked then
     
    21602239    end;
    21612240    // check if late tray should be ordered
    2162     AResponse := Responses.FindResponseByName('ORDERABLE', 1);
    2163     if (Self.EvtID = 0) and (AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then
    2164     begin
    2165       AResponse := Responses.FindResponseByName('START', 1);
    2166       if AResponse <> nil then CheckLateTray(AResponse.IValue, LateTrayFields, False);
    2167     end;
     2241    LateTrayCheck(Responses, Self.EvtID, FALSE, LateTrayFields);
    21682242  end;
    21692243{ TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? }
     
    21792253    end;
    21802254    // check if late tray should be ordered
    2181     AResponse := Responses.FindResponseByName('ORDERABLE', 1);
    2182     if (Self.EvtID = 0) and (AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then
    2183     begin
    2184       AResponse := Responses.FindResponseByName('START', 1);
    2185       AnotherResponse := Responses.FindResponseByName('MEAL', 1);
    2186       if (AResponse <> nil) and (AnotherResponse <> nil) then
    2187         CheckLateTray(AResponse.IValue, LateTrayFields, True, CharAt(AnotherResponse.IValue, 1));
    2188     end;
    2189   end;
    2190   inherited;
    2191   with LateTrayFields do if LateMeal <> #0 then
    2192   begin
    2193     NewOrder := TOrder.Create;
    2194     OrderLateTray(NewOrder, LateMeal, LateTime, IsBagged);
    2195     if NewOrder.ID <> '' then
    2196     begin
    2197       if OrderForInpatient then
    2198         begin
    2199           if (Encounter.Provider = User.DUZ) and User.CanSignOrders
    2200             then CanSign := CH_SIGN_YES
    2201             else CanSign := CH_SIGN_NA;
    2202         end
    2203       else
    2204         begin
    2205           CanSign := CH_SIGN_NA;
    2206         end;
    2207       Changes.Add(CH_ORD, NewOrder.ID, NewOrder.Text, '', CanSign);
    2208       SendMessage(Application.MainForm.Handle, UM_NEWORDER, ORDER_NEW, Integer(NewOrder))
    2209     end
    2210     else InfoBox(TX_EL_SAVE_ERR, TC_EL_SAVE_ERR, MB_OK);
    2211     NewOrder.Free;
    2212   end;
     2255    LateTrayCheck(Responses, Self.EvtID, TRUE, LateTrayFields);
     2256  end;
     2257  inherited;
     2258  with LateTrayFields do if LateMeal <> #0 then LateTrayOrder(LateTrayFields, OrderForInpatient);
    22132259end;
    22142260
Note: See TracChangeset for help on using the changeset viewer.