Function

ExecuteDCOrders

Module

fOrdersDC

Last Modified

7/15/2014 3:26:42 PM

Scope

Interfaced

Declaration

function ExecuteDCOrders(SelectedList: TList; var DelEvt: boolean): Boolean;

Calls Hierarchy


ExecuteDCOrders
 ├TfrmBase508Form.Create
 │ ├TfrmBase508Form.UpdateAccessibilityActions
 │ ├UnfocusableControlEnter
 │ └AdjustControls
 │   ├TfrmBase508Form.ModifyUnfocusableControl
 │   └..(rec)..
 ├SetFormPosition
 │ └TSizeHolder.GetSize
 ├DCOrder
 │ ├DeleteDCOrdersFromCopiedList
 │ └SetOrderFromResults
 │   └SetOrderFields
 │     ├TOrder.Clear
 │     ├SeqOfDGroup
 │     │ └LoadDGroupMap
 │     └TopNameOfDGroup
 │       └LoadDGroupMap
 ├TChanges.Add
 │ └TChangeItem.Create
 ├TChanges.Remove
 │ ├UnlockOrder
 │ └UnlockDocument
 ├UnlockOrder
 ├EventInfo
 ├isExistedEvent
 ├DeleteEmptyEvt
 │ ├PtEvtEmpty
 │ ├GetEventName
 │ └DeletePtEvent
 ├TfrmOrders.ChangesUpdate
 │ ├TheParentPtEvt
 │ └TChanges.Remove...
 ├TfrmOrders.InitOrderSheetsForEvtDelay
 │ ├TfrmOrders.InitOrderSheets
 │ │ ├TfrmOrders.ClearOrderSheets
 │ │ ├LoadOrderSheetsED
 │ │ ├DGroupAll
 │ │ └EventInfo
 │ └TfrmOrders.DfltViewForEvtDelay
 │   ├TfrmOrders.CanChangeOrderView
 │   │ └ActiveOrdering
 │   └LoadOrderViewDefault
 ├TfrmOrders.lstSheetsClick
 │ ├CloseOrdering
 │ ├TfrmOrders.PtEvtCompleted
 │ │ ├IsCompletedPtEvt
 │ │ ├TfrmOrders.GroupChangesUpdate
 │ │ │ ├TChanges.ChangeOrderGrp
 │ │ │ └TChanges.ReplaceODGrpName
 │ │ ├TfrmOrders.InitOrderSheetsForEvtDelay...
 │ │ ├TfrmOrders.lstSheetsClick...
 │ │ └TfrmOrders.RefreshOrderList
 │ │   ├LoadOrdersAbbr
 │ │   │ ├ClearOrders
 │ │   │ ├LoadDGroupMap
 │ │   │ ├ExpiredOrdersStartDT
 │ │   │ ├FMNow
 │ │   │ └SeqOfDGroup...
 │ │   ├ClearOrders
 │ │   ├LoadOrdersAbbr
 │ │   │ ├LoadDGroupMap
 │ │   │ ├FMNow
 │ │   │ └SeqOfDGroup...
 │ │   ├TfrmOrders.ExpandEventSection
 │ │   ├TfrmOrders.CompressEventSection
 │ │   ├SortOrders
 │ │   │ ├InverseByGroup
 │ │   │ │ └TChanges.Exist
 │ │   │ ├ForwardByGroup
 │ │   │ │ └TChanges.Exist
 │ │   │ ├InverseChrono
 │ │   │ └ForwardChrono
 │ │   ├TfrmOrders.AddToListBox
 │ │   │ └TfrmOrders.GetPlainText
 │ │   │   └TfrmOrders.GetOrderText
 │ │   │     ├LoadFlagReason
 │ │   │     ├TfrmOrders.GetStartStopText
 │ │   │     └NameOfStatus
 │ │   └DGroupAll
 │ ├DeleteEmptyEvt...
 │ ├TfrmOrders.ChangesUpdate...
 │ ├TfrmOrders.InitOrderSheetsForEvtDelay...
 │ ├..(rec)..
 │ ├LoadWriteOrdersED
 │ ├LoadWriteOrders
 │ ├TfrmOrders.RefreshOrderList...
 │ ├PtEvtEmpty
 │ └DeletePtEvent
 └SaveUserBounds
   └TSizeHolder.SetSize

Called-By Hierarchy


           ExecuteDCOrders
TfrmOrders.mnuActDCClick┤ 
  TfrmMeds.mnuActDCClick┘ 

Calls

Name Declaration Comments
TChanges.Add procedure Add(ItemType: Integer; const AnID, ItemText, GroupName: string; SignState: Integer; AParentID: string = ''; User: int64 = 0; OrderDG: String = ''; DCOrder: Boolean = False; Delay: Boolean = False; ProblemAdded: Boolean = False); -
TfrmOrders.ChangesUpdate procedure ChangesUpdate(APtEvtID: string); -
TfrmBase508Form.Create constructor Create(AOwner: TComponent); override; -
DCOrder procedure DCOrder(AnOrder: TOrder; AReason: Integer; NewOrder: boolean; var DCType: Integer); -
DeleteEmptyEvt function DeleteEmptyEvt(APtEvntID: string; var APtEvntName: string; Ask: boolean = True): boolean; -
EventInfo function EventInfo(APtEvtID: string): string; -
TfrmOrders.InitOrderSheetsForEvtDelay procedure InitOrderSheetsForEvtDelay; -
isExistedEvent function isExistedEvent(const APtDFN: string; const AEvtID: string; var APtEvtID: string): Boolean; -
TfrmOrders.lstSheetsClick procedure lstSheetsClick(Sender: TObject); -
TChanges.Remove procedure Remove(ItemType: Integer; const AnID: string); -
SaveUserBounds procedure SaveUserBounds(AControl: TControl); -
SetFormPosition procedure SetFormPosition(AForm: TForm); -
UnlockOrder procedure UnlockOrder(OrderID: string); -

Called-By

Name Declaration Comments
TfrmOrders.mnuActDCClick procedure mnuActDCClick(Sender: TObject); -
TfrmMeds.mnuActDCClick procedure mnuActDCClick(Sender: TObject); -


Source

44    function ExecuteDCOrders(SelectedList: TList; var DelEvt: boolean): Boolean;
45    const
46      DCT_NEWORDER  = 1;
47      DCT_DELETION  = 2;
48      DCT_NEWSTATUS = 3;
49    var
50      frmDCOrders: TfrmDCOrders;
51      AnOrder: TOrder;
52      i, j, CanSign, DCType: Integer;
53      NeedReason,NeedRefresh,OnCurrent, DCNewOrder: Boolean;
54      OriginalID,APtEvtID,APtEvtName,AnEvtInfo,tmpPtEvt:  string;
55      PtEvtList: TStringList;
56      DCChangeItem: TChangeItem;
57    begin
58      Result := False;
59      DelEvt := False;
60      OnCurrent := False;
61      NeedRefresh := False;
62      DCNewOrder := false;
63      PtEvtList := TStringList.Create;
64      if SelectedList.Count = 0 then Exit;
65      frmDCOrders := TfrmDCOrders.Create(Application);
66      try
67        SetFormPosition(frmDCOrders);
68        ResizeFormToFont(TForm(frmDCOrders));
69        NeedReason := False;
70        with SelectedList do for i := 0 to Count - 1 do
71        begin
72          AnOrder    := TOrder(Items[i]);
73          frmDCOrders.lstOrders.Items.Add(AnOrder.Text);
74          frmDCOrders.OrderIDArr.Add(AnOrder.ID);
75          if not ((AnOrder.Status = 11) and (AnOrder.Signature = 2)) then NeedReason := True;
76          if (NeedReason = True) and (AnOrder.Status = 10) and (AnOrder.Signature = 2) then  NeedReason := False;
77          
78        end;
79        if NeedReason then
80        begin
81          frmDCOrders.lblReason.Visible := True;
82          frmDCOrders.lstReason.Visible := True;
83          frmDCOrders.lstReason.ScrollWidth := 10;
84        end else
85        begin
86          frmDCOrders.lblReason.Visible := False;
87          frmDCOrders.lstReason.Visible := False;
88        end;
89        frmDCOrders.ShowModal;
90        if frmDCOrders.OKPressed then
91        begin
92          if (Encounter.Provider = User.DUZ) and User.CanSignOrders
93            then CanSign := CH_SIGN_YES
94            else CanSign := CH_SIGN_NA;
95          with SelectedList do for i := 0 to Count - 1 do
96          begin
97            AnOrder := TOrder(Items[i]);
98            OriginalID := AnOrder.ID;
99            PtEvtList.Add(AnOrder.EventPtr + '^' + AnOrder.EventName);
100           if Changes.Orders.Count = 0 then DCNewOrder := false
101           else
102             begin
103               for j := 0 to Changes.Orders.Count - 1 do
104                 begin
105                   DCChangeItem := TChangeItem(Changes.Orders.Items[j]);
106                   if DCChangeItem.ID = AnOrder.ID then
107                     begin
108                       if (Pos('DC', AnOrder.ActionOn) = 0) then
109                          DCNewOrder := True
110                       else DCNewOrder := False;
111                     end;
112                 end;
113             end;
114           DCOrder(AnOrder, frmDCOrders.DCReason, DCNewOrder, DCType);
115           case DCType of
116           DCT_NEWORDER:  begin
117                            Changes.Add(CH_ORD, AnOrder.ID, AnOrder.Text, '', CanSign, AnOrder.ParentID, user.DUZ, AnOrder.DGroupName, True);
118                            AnOrder.ActionOn := OriginalID + '=DC';
119                          end;
120           DCT_DELETION:  begin
121                            Changes.Remove(CH_ORD, OriginalID);
122                            if (AnOrder.ID = '0') or (AnOrder.ID = '')
123                              then AnOrder.ActionOn := OriginalID + '=DL'    // delete order
124                              else AnOrder.ActionOn := OriginalID + '=CA';   // cancel action
125                             {else AnOrder.ActionOn := AnOrder.ID + '=CA';  - caused cancel from meds to not update orders}
126                            UnlockOrder(OriginalID);  // for deletion of unsigned DC
127                          end;
128           DCT_NEWSTATUS: begin
129                            AnOrder.ActionOn := OriginalID + '=DC';
130                            UnlockOrder(OriginalID);
131                          end;
132           else UnlockOrder(OriginalID);
133           end;
134           SendMessage(Application.MainForm.Handle, UM_NEWORDER, ORDER_ACT, Integer(AnOrder));
135         end;
136         if frmOrders.lstSheets.ItemIndex > -1 then
137           if CharAt(frmOrders.lstSheets.Items[frmOrders.lstSheets.ItemIndex],1)='C' then
138             OnCurrent := True;
139         if not OnCurrent then
140         begin
141           for i := 0 to PtEvtList.Count - 1 do
142           begin
143             if Length(PtEvtList[i])>1  then
144             begin
145               APtEvtID   := Piece(PtEvtList[i],'^',1);
146               APtEvtName := Piece(PtEvtList[i],'^',2);
147               AnEvtInfo := EventInfo(APtEvtID);
148               if isExistedEvent(Patient.DFN,Piece(AnEvtInfo,'^',2),tmpPtEvt) and (DeleteEmptyEvt(APtEvtID,APtEvtName,False)) then
149               begin
150                 NeedRefresh := True;
151                 frmOrders.ChangesUpdate(APtEvtID);
152               end;
153             end;
154           end;
155           if NeedRefresh then
156           begin
157             frmOrders.InitOrderSheetsForEvtDelay;
158             frmOrders.lstSheets.ItemIndex := 0;
159             frmOrders.lstSheetsClick(nil);
160             DelEvt := True;
161           end;
162         end;
163         Result := True;
164       end
165       else with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
166       SaveUserBounds(frmDCOrders);
167     finally
168       frmDCOrders.Release;
169     end;
170   end;