Module

fODChangeUnreleasedRenew

Path

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

Last Modified

7/15/2014 3:26:40 PM

Units Used in Interface

Name Comments
fAutoSz -
rODBase -
rODMeds -
rOrders -
uOrders -

Classes

Name Comments
TfrmODChangeUnreleasedRenew -

Procedures

Name Owner Declaration Scope Comments
btnCancelClick TfrmODChangeUnreleasedRenew procedure btnCancelClick(Sender: TObject); Public/Published -
btnOKClick TfrmODChangeUnreleasedRenew procedure btnOKClick(Sender: TObject); Public/Published -
ExecuteChangeRenewedOrder - procedure ExecuteChangeRenewedOrder(const AnID: string; var param1, param2: string; Category: integer; AnEvent: TOrderDelayEvent); Interfaced -
FormCreate TfrmODChangeUnreleasedRenew procedure FormCreate(Sender: TObject); Public/Published -

Global Variables

Name Type Declaration Comments
MaxRefills Integer MaxRefills: Integer; -

Constants

Name Declaration Scope Comments
TC_ERR_REFILL 'Refills' Global -
TC_INVALID_DATE 'Unable to interpret date/time entry.' Global -
TX_BAD_START 'The start date is not valid.' Global -
TX_BAD_STOP 'The stop date is not valid.' Global -
TX_ERR_REFILL 'The number of refills must be in the range of 0 through ' Global -
TX_STOPSTART 'The stop date must be after the start date.' Global -


Module Source

1     unit fODChangeUnreleasedRenew;
2     
3     interface
4     
5     uses
6       Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7       Dialogs, ExtCtrls, StdCtrls, ORCtrls, fAutoSz, uOrders, ORFn, ORDtTm, rOrders,
8       VA508AccessibilityManager, rODBase, rODMeds;
9     
10    type
11      TfrmODChangeUnreleasedRenew = class(TfrmAutoSz)
12        memOrder: TCaptionMemo;
13        Panel1: TPanel;
14        btnOK: TButton;
15        btnCancel: TButton;
16        Panel2: TPanel;
17        edtRefill: TCaptionEdit;
18        lblRefill: TLabel;
19        lblPickUp: TLabel;
20        cboPickup: TORComboBox;
21        Panel3: TPanel;
22        Label1: TLabel;
23        Label2: TLabel;
24        txtStart: TORDateBox;
25        txtStop: TORDateBox;
26        procedure FormCreate(Sender: TObject);
27        procedure btnCancelClick(Sender: TObject);
28        procedure btnOKClick(Sender: TObject);
29      private
30        OKPressed: boolean;
31        FCategory: integer;
32      public
33        { Public declarations }
34      end;
35    
36    procedure ExecuteChangeRenewedOrder(const AnID: string; var param1, param2: string; Category: integer; AnEvent: TOrderDelayEvent);
37    
38    implementation
39    
40    {$R *.dfm}
41    var
42     MaxRefills: Integer;
43    
44    const
45      TX_ERR_REFILL = 'The number of refills must be in the range of 0 through ';
46      TC_ERR_REFILL = 'Refills';
47      TC_INVALID_DATE = 'Unable to interpret date/time entry.';
48      TX_BAD_START   = 'The start date is not valid.';
49      TX_BAD_STOP    = 'The stop date is not valid.';
50      TX_STOPSTART   = 'The stop date must be after the start date.';
51    
52    procedure ExecuteChangeRenewedOrder(const AnID: string; var param1, param2: string; Category: integer; AnEvent: TOrderDelayEvent);
53    var
54      frmODChangeUnreleasedRenew: TfrmODChangeUnreleasedRenew;
55      theText: string;
56      tmpRefills: integer;
57      DestList: TList;
58      HasObject: Boolean;
59      i: Integer;
60      Drug, Days, OrID: string;
61    begin
62      //Get needed information
63      DestList := TList.Create();
64      try
65        LoadResponses(DestList, 'X' + AnID, HasObject);
66    
67        for I := 0 to DestList.Count - 1 do begin
68          if TResponse(DestList.Items[i]).PromptID = 'DRUG' then Drug := TResponse(DestList.Items[i]).IValue
69          else if TResponse(DestList.Items[i]).PromptID = 'SUPPLY' then Days := TResponse(DestList.Items[i]).IValue
70          else if TResponse(DestList.Items[i]).PromptID = 'ORDERABLE' then OrID := TResponse(DestList.Items[i]).IValue;
71        end;
72    
73        MaxRefills := CalcMaxRefills(Drug, StrToInt(Days), StrToInt(OrID), AnEvent.EventType = 'D');
74    
75      tmpRefills := 0;
76      theText := Trim(RetrieveOrderText(AnID));
77      if Pos('>> RENEW', UpperCase(theText)) = 1 then Delete(theText,1,length('>> RENEW'))
78      else if Pos('RENEW',UpperCase(theText))= 1 then Delete(theText,1,length('RENEW'));
79      frmODChangeUnreleasedRenew := TfrmODChangeUnreleasedRenew.Create(Application);
80      try
81        frmODChangeUnreleasedRenew.FCategory := Category;
82        ResizeFormToFont(TForm(frmODChangeUnreleasedRenew));
83        if Category = 0 then
84        begin
85          frmODChangeUnreleasedRenew.Panel3.Visible := False;
86          tmpRefills := StrToIntDef(param1,0);
87          frmODChangeUnreleasedRenew.edtRefill.Text := param1;
88          frmODChangeUnreleasedRenew.cboPickup.SelectByID(param2);
89          frmODChangeUnreleasedRenew.memOrder.SetTextBuf(PChar(theText));
90        end
91        else if Category = 1 then
92        begin
93          frmODChangeUnreleasedRenew.Panel2.Visible := false;
94          frmODChangeUnreleasedRenew.txtStart.Text := param1;
95          frmODChangeUnreleasedRenew.txtStop.Text  := param2;
96          frmODChangeUnreleasedRenew.memOrder.SetTextBuf(PChar(theText));
97        end;
98        frmODChangeUnreleasedRenew.ShowModal;
99        if frmODChangeUnreleasedRenew.OKPressed then
100       begin
101         if Category = 0 then
102         begin
103           tmpRefills := StrToIntDef(frmODChangeUnreleasedRenew.edtRefill.Text, tmpRefills);
104           param1 := IntToStr(tmpRefills);
105           param2 := frmODChangeUnreleasedRenew.cboPickup.ItemID;
106         end
107         else if Category = 1 then
108         begin
109           param1 := frmODChangeUnreleasedRenew.txtStart.Text;
110           param2 := frmODChangeUnreleasedRenew.txtStop.Text;
111         end;
112       end;
113     finally
114       frmODChangeUnreleasedRenew.Release;
115     end;
116     finally
117       DestList.Free;
118     end;
119   end;
120   
121   procedure TfrmODChangeUnreleasedRenew.FormCreate(Sender: TObject);
122   begin
123     inherited;
124     OKPressed := False;
125     with cboPickup.Items do
126     begin
127       Add('W^at Window');
128       Add('M^by Mail');
129       Add('C^in Clinic');
130     end;
131   end;
132   
133   procedure TfrmODChangeUnreleasedRenew.btnCancelClick(Sender: TObject);
134   begin
135     inherited;
136     Close;
137   end;
138   
139   procedure TfrmODChangeUnreleasedRenew.btnOKClick(Sender: TObject);
140   var
141     NumRefills: Integer;
142     x, ErrMsg: string;
143   begin
144     inherited;
145     if panel2.Visible then
146     begin
147       NumRefills := StrToIntDef(edtRefill.Text, -1);
148       if (NumRefills < 0) or (NumRefills > MaxRefills) then
149       begin
150         InfoBox(TX_ERR_REFILL + IntToStr(MaxRefills), TC_ERR_REFILL, MB_OK);
151         Exit;
152       end;
153     end
154     else if panel3.Visible then
155     begin
156       ErrMsg := '';
157       txtStart.Validate(x);
158       if Length(x) > 0   then ErrMsg := ErrMsg + TX_BAD_START + CRLF;
159       with txtStop do
160       begin
161         Validate(x);
162         if Length(x) > 0 then ErrMsg := ErrMsg + TX_BAD_STOP + CRLF;
163         if (Length(Text) > 0) and (FMDateTime <= txtStart.FMDateTime)
164                          then ErrMsg := ErrMsg + TX_STOPSTART;
165       end;
166       if Length(ErrMsg) > 0 then
167       begin
168         InfoBox(ErrMsg, TC_INVALID_DATE, MB_OK);
169         Exit;
170       end;
171     end;
172     OKPressed := True;
173     Close;
174   end;
175   
176   end.

Module Calls (2 levels)


fODChangeUnreleasedRenew
 ├fAutoSz
 │ └fBase508Form
 ├uOrders
 │ ├uConst
 │ ├rConsults
 │ ├rOrders
 │ ├fODBase
 │ ├XuDsigS
 │ ├fODDiet
 │ ├fODMisc
 │ ├fODGen
 │ ├fODMedIn
 │ ├fODMedOut
 │ ├fODText
 │ ├fODConsult
 │ ├fODProc
 │ ├fODRad
 │ ├fODLab
 │ ├fODBBank
 │ ├fODMeds
 │ ├fODMedIV
 │ ├fODVitals
 │ ├fODAuto
 │ ├fOMNavA
 │ ├rCore
 │ ├uCore
 │ ├fFrame
 │ ├fEncnt
 │ ├fOMVerify
 │ ├fOrderSaveQuick
 │ ├fOMSet
 │ ├rMisc
 │ ├uODBase
 │ ├rODMeds
 │ ├fLkUpLocation
 │ ├fOrdersPrint
 │ ├fOMAction
 │ ├fARTAllgy
 │ ├fOMHTML
 │ ├fOrders
 │ ├rODBase
 │ ├fODChild
 │ ├fMeds
 │ ├rMeds
 │ ├rPCE
 │ ├fRptBox
 │ ├fODMedNVA
 │ ├fODChangeUnreleasedRenew...
 │ ├rODAllergy
 │ ├UBAGlobals
 │ └uTemplateFields
 ├rOrders...
 ├rODBase...
 └rODMeds...

Module Called-By (2 levels)


       fODChangeUnreleasedRenew
                      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┘