Module

fODAuto

Path

C:\CPRS\CPRS30\Orders\fODAuto.pas

Last Modified

7/15/2014 3:26:40 PM

Units Used in Interface

Name Comments
fODBase -

Units Used in Implementation

Name Comments
fFrame -
fTemplateDialog -
rConsults -
rODBase -
rODMeds -
rOrders -
rTemplates -
uConst -
uCore -
uODBase -
uTemplateFields -
uTemplates -

Classes

Name Comments
TfrmODAuto -

Procedures

Name Owner Declaration Scope Comments
InitDialog TfrmODAuto procedure InitDialog; override; Public -
SetupDialog TfrmODAuto procedure SetupDialog(OrderAction: Integer; const ID: string); override; Public -
Validate TfrmODAuto procedure Validate(var AnErrMsg: string); override; Public -

Global Variables

Name Type Declaration Comments
frmODAuto TfrmODAuto frmODAuto: TfrmODAuto; -


Module Source

1     unit fODAuto;
2     
3     interface
4     
5     uses
6       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7       fODBase, StdCtrls, ComCtrls, ExtCtrls, ORFn, ORCtrls,
8       VA508AccessibilityManager;
9     
10    type
11      TfrmODAuto = class(TfrmODBase)
12        Label1: TLabel;
13      public
14        procedure InitDialog; override;
15        procedure SetupDialog(OrderAction: Integer; const ID: string); override;
16        procedure Validate(var AnErrMsg: string); override;
17      end;
18    
19    var
20      frmODAuto: TfrmODAuto;
21    
22    implementation
23    
24    {$R *.DFM}
25    
26    uses rODBase, rOrders, fTemplateDialog, uTemplateFields, rTemplates, uConst, uTemplates,
27         rConsults, uCore, uODBase, rODMeds, fFrame;
28    
29    procedure TfrmODAuto.InitDialog;
30    begin
31      inherited;
32      // nothing for now
33    end;
34    
35    procedure TfrmODAuto.Validate(var AnErrMsg: string);
36    var
37      cptn, tmp, DocInfo: string;
38      TempSL: TStringList;
39      LType: TTemplateLinkType;
40      IEN: integer;
41      HasObjects: boolean;
42    
43    begin
44      inherited;
45      DocInfo := '';
46      LType := DisplayGroupToLinkType(Responses.DisplayGroup);
47      tmp := Responses.EValueFor('COMMENT', 1);
48      ExpandOrderObjects(tmp, HasObjects);
49      Responses.OrderContainsObjects := Responses.OrderContainsObjects or HasObjects;
50      if (LType <> ltNone) or HasTemplateField(tmp) then
51      begin
52        cptn := 'Reason for Request: ' + Responses.EValueFor('ORDERABLE', 1);
53        case LType of
54          ltConsult:   IEN := StrToIntDef(GetServiceIEN(Responses.IValueFor('ORDERABLE', 1)),0);
55          ltProcedure: IEN := StrToIntDef(GetProcedureIEN(Responses.IValueFor('ORDERABLE', 1)),0);
56          else         IEN := 0;
57        end;
58        if IEN <> 0 then
59          ExecuteTemplateOrBoilerPlate(tmp, IEN, LType, nil, cptn, DocInfo)
60        else
61          CheckBoilerplate4Fields(tmp, cptn);
62    
63    
64          if WasTemplateDialogCanceled then AnErrMsg := 'The Auto-Accept Quick Order cannot be saved since the template was cancelled.';
65    
66        if tmp <> '' then
67          Responses.Update('COMMENT', 1, TX_WPTYPE, tmp)
68        else
69        begin
70          TempSL := TStringList.Create;
71          try
72            TempSL.Text := Responses.EValueFor('COMMENT', 1);
73            Convert2LMText(TempSL);
74            Responses.Update('COMMENT', 1, TX_WPTYPE, TempSL.Text);
75          finally
76            TempSL.Free;
77          end;
78        end;
79      end;
80    end;
81    
82    procedure TfrmODAuto.SetupDialog(OrderAction: Integer; const ID: string);
83    var
84      DialogNames: TDialogNames;
85      DlgOI, AnInstance, IVDsGrp: integer;
86      DEAFailStr, TX_INFO: string;
87      InptDlg:  Boolean;
88    begin
89      inherited;  // Responses is already loaded here
90      DEAFailStr := '';
91      InptDlg := False;
92      IVDsGrp := DisplayGroupByName('IV RX');
93      if DisplayGroup = DisplayGroupByName('UD RX') then InptDlg := TRUE;
94      if DisplayGroup = DisplayGroupByName('O RX') then InptDlg := FALSE;
95      if DisplayGroup = DisplayGroupByName('NV RX') then InptDlg := FALSE;
96      if DisplayGroup = DisplayGroupByName('RX') then InptDlg := OrderForInpatient;
97      if (not Patient.Inpatient) and (DisplayGroup = IVDsGrp) then      //if auto-accept of IV med order on Outpatient (ex: from Copy to New order action)
98      begin
99        AnInstance := Responses.NextInstance('ORDERABLE', 0);
100       while AnInstance > 0 do     //perform DEA/schedule check on all solutions before auto-accepting
101         begin
102           DlgOI := StrtoIntDef(Responses.IValueFor('ORDERABLE',AnInstance),0);
103           DEAFailStr := DEACheckFailedForIVOnOutPatient(DlgOI,'S');
104           while StrToIntDef(Piece(DEAFailStr,U,1),0) in [1..5] do
105             begin
106               case StrToIntDef(Piece(DEAFailStr,U,1),0) of
107                 1:  TX_INFO := TX_DEAFAIL;  //prescriber has an invalid or no DEA#
108                 2:  TX_INFO := TX_SCHFAIL + Piece(DEAFailStr,U,2) + '.';  //prescriber has no schedule privileges in 2,2N,3,3N,4, or 5
109                 3:  TX_INFO := TX_NO_DETOX;  //prescriber has an invalid or no Detox#
110                 4:  TX_INFO := TX_EXP_DEA1 + Piece(DEAFailStr,U,2) + TX_EXP_DEA2;  //prescriber's DEA# expired and no VA# is assigned
111                 5:  TX_INFO := TX_EXP_DETOX1 + Piece(DEAFailStr,U,2) + TX_EXP_DETOX2;  //valid detox#, but expired DEA#
112               end;
113               if InfoBox(TX_INFO + TX_INSTRUCT, TC_DEAFAIL, MB_RETRYCANCEL) = IDRETRY then
114                 begin
115                   DEAContext := True;
116                   fFrame.frmFrame.mnuFileEncounterClick(self);
117                   DEAFailStr := '';
118                   DEAFailStr := DEACheckFailedForIVOnOutPatient(DlgOI,'S');
119                 end
120               else
121                 begin
122                   AbortOrder := True;
123                   Exit;
124                 end;
125             end;
126           AnInstance := Responses.NextInstance('ORDERABLE', AnInstance);
127         end;
128       AnInstance := Responses.NextInstance('ADDITIVE', 0);
129       while AnInstance > 0 do     //perform DEA/schedule check on all additives before auto-accepting
130         begin
131           DlgOI := StrtoIntDef(Responses.IValueFor('ADDITIVE',AnInstance),0);
132           DEAFailStr := DEACheckFailedForIVOnOutPatient(DlgOI,'A');
133           while StrToIntDef(Piece(DEAFailStr,U,1),0) in [1..5] do
134             begin
135               case StrToIntDef(Piece(DEAFailStr,U,1),0) of
136                 1:  TX_INFO := TX_DEAFAIL;  //prescriber has an invalid or no DEA#
137                 2:  TX_INFO := TX_SCHFAIL + Piece(DEAFailStr,U,2) + '.';  //prescriber has no schedule privileges in 2,2N,3,3N,4, or 5
138                 3:  TX_INFO := TX_NO_DETOX;  //prescriber has an invalid or no Detox#
139                 4:  TX_INFO := TX_EXP_DEA1 + Piece(DEAFailStr,U,2) + TX_EXP_DEA2;  //prescriber's DEA# expired and no VA# is assigned
140                 5:  TX_INFO := TX_EXP_DETOX1 + Piece(DEAFailStr,U,2) + TX_EXP_DETOX2;  //valid detox#, but expired DEA#
141               end;
142               if InfoBox(TX_INFO + TX_INSTRUCT, TC_DEAFAIL, MB_RETRYCANCEL) = IDRETRY then
143                 begin
144                   DEAContext := True;
145                   fFrame.frmFrame.mnuFileEncounterClick(self);
146                   DEAFailStr := '';
147                   DEAFailStr := DEACheckFailedForIVOnOutPatient(DlgOI,'A');
148                 end
149               else
150                 begin
151                   AbortOrder := True;
152                   Exit;
153                 end;
154             end;
155           AnInstance := Responses.NextInstance('ADDITIVE', AnInstance);
156         end;
157     end
158     else if DisplayGroup <> IVDsGrp then
159     begin          //if auto-accept of unit dose, NON-VA, or Outpatient meds
160       DlgOI := StrtoIntDef(Responses.IValueFor('ORDERABLE',1),0);
161       DEAFailStr := DEACheckFailed(DlgOI,InptDlg);
162       while StrToIntDef(Piece(DEAFailStr,U,1),0) in [1..5] do
163         begin
164           case StrToIntDef(Piece(DEAFailStr,U,1),0) of
165             1:  TX_INFO := TX_DEAFAIL;  //prescriber has an invalid or no DEA#
166             2:  TX_INFO := TX_SCHFAIL + Piece(DEAFailStr,U,2) + '.';  //prescriber has no schedule privileges in 2,2N,3,3N,4, or 5
167             3:  TX_INFO := TX_NO_DETOX;  //prescriber has an invalid or no Detox#
168             4:  TX_INFO := TX_EXP_DEA1 + Piece(DEAFailStr,U,2) + TX_EXP_DEA2;  //prescriber's DEA# expired and no VA# is assigned
169             5:  TX_INFO := TX_EXP_DETOX1 + Piece(DEAFailStr,U,2) + TX_EXP_DETOX2;  //valid detox#, but expired DEA#
170           end;
171           if InfoBox(TX_INFO + TX_INSTRUCT, TC_DEAFAIL, MB_RETRYCANCEL) = IDRETRY then
172             begin
173               DEAContext := True;
174               fFrame.frmFrame.mnuFileEncounterClick(self);
175               DEAFailStr := '';
176               DEAFailStr := DEACheckFailed(DlgOI,InptDlg);
177             end
178           else
179             begin
180               AbortOrder := True;
181               Exit;
182             end;
183         end;  //end while
184     end;  //end else
185     AutoAccept := True;
186     StatusText('Loading Dialog Definition');
187     FillerID := FillerIDForDialog(DialogIEN);
188     IdentifyDialog(DialogNames, DialogIEN);
189     Responses.Dialog := DialogNames.BaseName;                      // loads formatting info
190     Responses.DialogDisplayName := DialogNames.Display;
191     StatusText('');
192   end;
193   
194   end.

Module Calls (2 levels)


fODAuto
 ├fODBase
 │ ├fAutoSz
 │ ├uConst
 │ ├rOrders
 │ ├rODBase
 │ ├uCore
 │ ├UBAGlobals
 │ ├UBACore
 │ ├fOCAccept
 │ ├uODBase
 │ ├rCore
 │ ├rMisc
 │ ├fTemplateDialog
 │ ├uEventHooks
 │ ├uTemplates
 │ ├rConsults
 │ ├fOrders
 │ ├uOrders
 │ ├fFrame
 │ ├fODDietLT
 │ └rODDiet
 ├rODBase...
 ├rOrders...
 ├fTemplateDialog...
 ├uTemplateFields
 │ ├uDlgComponents
 │ ├rTemplates
 │ ├mTemplateFieldButton
 │ ├uConst
 │ ├uCore...
 │ └rCore...
 ├rTemplates...
 ├uConst
 ├uTemplates...
 ├rConsults...
 ├uCore...
 ├uODBase...
 ├rODMeds
 │ ├uCore...
 │ └uConst
 └fFrame...

Module Called-By (2 levels)


                     fODAuto
                   uOrders┘ 
                   uCore┤   
                 fODBase┤   
                 rODBase┤   
                  fFrame┤   
                 fOrders┤   
             fOrdersSign┤   
                   fMeds┤   
               fARTAllgy┤   
                  fNotes┤   
               fConsults┤   
         fReminderDialog┤   
                 fReview┤   
            fOrdersRenew┤   
               fOrdersCV┤   
                 fODMeds┤   
                 fOMNavA┤   
         fOrderSaveQuick┤   
                  fOMSet┤   
          fOrdersRelease┤   
                 fOMHTML┤   
               fODMedNVA┤   
fODChangeUnreleasedRenew┤   
          fOrdersOnChart┤   
         fODReleaseEvent┤   
               fODActive┘