1 | //kt -- Modified with SourceScanner on 7/7/2007
|
---|
2 | unit fActivateDeactivate;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, StrUtils, Variants, Classes, Graphics, Controls, Forms,
|
---|
8 | Dialogs, fAutoSz, StdCtrls, ExtCtrls, ORCtrls,ORFn, rCore, uCore, oRNet, Math, fOrders, ORClasses, rOrders,
|
---|
9 | fMeds, rMeds, DKLang;
|
---|
10 |
|
---|
11 | type
|
---|
12 | TfrmActivateDeactive = class(TfrmAutoSz)
|
---|
13 | TActivate: TButton;
|
---|
14 | TDeactive: TButton;
|
---|
15 | Memo1: TMemo;
|
---|
16 | TCancel: TButton;
|
---|
17 | DKLanguageController1: TDKLanguageController;
|
---|
18 | procedure TActivateClick(Sender: TObject);
|
---|
19 | procedure TDeactiveClick(Sender: TObject);
|
---|
20 | procedure TCancelClick(Sender: TObject);
|
---|
21 | private
|
---|
22 | { Private declarations }
|
---|
23 | procedure GetOriginalOrders(OrderID: TStringList; var OriginalOrder: TORStringList);
|
---|
24 | procedure BuildForm(Str1: String);
|
---|
25 | function PromptForm(Text: String): String;
|
---|
26 | public
|
---|
27 | { Public declarations }
|
---|
28 |
|
---|
29 | procedure fActivateDeactive(OrderID: TStringList); overload;
|
---|
30 | procedure fActivateDeactive(OrderID: TStringList; AList: TListBox); overload;
|
---|
31 | end;
|
---|
32 |
|
---|
33 | var
|
---|
34 | frmActivateDeactive: TfrmActivateDeactive;
|
---|
35 | Act: Boolean;
|
---|
36 | Deact: Boolean;
|
---|
37 | CancelProcess: Boolean;
|
---|
38 |
|
---|
39 | implementation
|
---|
40 |
|
---|
41 | {$R *.dfm}
|
---|
42 |
|
---|
43 | { TfrmActivateDeactive }
|
---|
44 |
|
---|
45 | procedure TfrmActivateDeactive.BuildForm(Str1: String);
|
---|
46 | var
|
---|
47 | str: string;
|
---|
48 | begin
|
---|
49 | with frmActivateDeactive do
|
---|
50 | begin
|
---|
51 | // str := 'This order ' + str1 +' is currently in a pending status. '; <-- original line. //kt 7/7/2007
|
---|
52 | str := DKLangConstW('fActivateDeactivate_This_order_') + str1 +DKLangConstW('fActivateDeactivate__is_currently_in_a_pending_status_'); //kt added 7/7/2007
|
---|
53 | // str := str + CRLF + 'If this order is discontinued, the original order status will be changed to active, unless it is discontinued.'; <-- original line. //kt 7/7/2007
|
---|
54 | str := str + CRLF + DKLangConstW('fActivateDeactivate_If_this_order_is_discontinued_the_original_order_status_will_be_changed_to_active_unless_it_is_discontinued'); //kt added 7/7/2007
|
---|
55 | // str := str + CRLF + CRLF + 'Click:'; <-- original line. //kt 7/7/2007
|
---|
56 | str := str + CRLF + CRLF + DKLangConstW('fActivateDeactivate_Click'); //kt added 7/7/2007
|
---|
57 | // str := str + CRLF + ' "Yes" to discontinue the original order'; <-- original line. //kt 7/7/2007
|
---|
58 | str := str + CRLF + DKLangConstW('fActivateDeactivate_Yes_to_discontinue_the_original_order'); //kt added 7/7/2007
|
---|
59 | // str := str + CRLF + ' "No" to change the status to active'; <-- original line. //kt 7/7/2007
|
---|
60 | str := str + CRLF + DKLangConstW('fActivateDeactivate_No_to_change_the_status_to_active'); //kt added 7/7/2007
|
---|
61 | // str := str + CRLF + ' "Cancel" to stop the discontinue process for this order'; <-- original line. //kt 7/7/2007
|
---|
62 | str := str + CRLF + DKLangConstW('fActivateDeactivate_Cancel_to_stop_the_discontinue_process_for_this_order'); //kt added 7/7/2007
|
---|
63 | Memo1.ReadOnly := False;
|
---|
64 | Memo1.Text := str;
|
---|
65 | Memo1.ReadOnly := True;
|
---|
66 | end;
|
---|
67 | ResizeAnchoredFormToFont(frmActivateDeactive);
|
---|
68 | frmActivateDeactive.ShowModal;
|
---|
69 | frmActivateDeactive.Release;
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TfrmActivateDeactive.fActivateDeactive(OrderID: TStringList);
|
---|
73 | var
|
---|
74 | i,j,Pos: integer;
|
---|
75 | tmpArr: TORStringList;
|
---|
76 | ActDeact: string;
|
---|
77 | AnOrder,AnOrder1: TOrder;
|
---|
78 | begin
|
---|
79 | //called from order tab
|
---|
80 | tmpArr := TORStringList.Create;
|
---|
81 | GetOriginalOrders(OrderID,tmpArr);
|
---|
82 | with forders.frmOrders.lstOrders do for i := 0 to items.Count-1 do if Selected[i] then
|
---|
83 | begin
|
---|
84 | AnOrder := TOrder(Items.Objects[i]);
|
---|
85 | Pos := tmpArr.IndexOfPiece(AnOrder.ID,U,1);
|
---|
86 | if Pos > -1 then
|
---|
87 | begin
|
---|
88 | ActDeact := PromptForm(AnOrder.Text);
|
---|
89 | if ActDeact = 'D' then
|
---|
90 | begin
|
---|
91 | for j := 0 to forders.frmOrders.lstOrders.Items.Count-1 do
|
---|
92 | begin
|
---|
93 | AnOrder1 := TOrder(forders.frmOrders.lstOrders.Items.Objects[j]);
|
---|
94 | if AnOrder1.ID = Piece(tmpArr.Strings[Pos],U,2) then
|
---|
95 | forders.frmOrders.lstOrders.Selected[j] := True;
|
---|
96 | end;
|
---|
97 | end;
|
---|
98 | if ActDeact = 'C' then Selected[i] := False;
|
---|
99 | end;
|
---|
100 | end;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TfrmActivateDeactive.fActivateDeactive(OrderID: TStringList; AList: TListBox);
|
---|
104 | var
|
---|
105 | i,j,Pos: integer;
|
---|
106 | tmpArr: TORStringList;
|
---|
107 | ActDeact: String;
|
---|
108 | AMed,AMed1: TMedListRec;
|
---|
109 | begin
|
---|
110 | //called from Med tab
|
---|
111 | tmpArr := TORStringList.Create;
|
---|
112 | GetOriginalOrders(OrderID,tmpArr);
|
---|
113 | with AList do for i := 0 to items.Count-1 do if Selected[i] then
|
---|
114 | begin
|
---|
115 | AMed := TMedListRec(Items.Objects[i]);
|
---|
116 | Pos := tmpArr.IndexOfPiece(AMed.OrderID,U,1);
|
---|
117 | if Pos > -1 then
|
---|
118 | begin
|
---|
119 | ActDeact := PromptForm(Alist.Items.Strings[i]);
|
---|
120 | if ActDeact = 'D' then
|
---|
121 | begin
|
---|
122 | for j := 0 to Alist.Items.Count-1 do
|
---|
123 | begin
|
---|
124 | AMed1 := TMedListRec(Alist.Items.Objects[j]);
|
---|
125 | if AMed1.OrderID = Piece(tmpArr.Strings[Pos],U,2) then
|
---|
126 | begin
|
---|
127 | Alist.Selected[j] := True;
|
---|
128 | break;
|
---|
129 | end;
|
---|
130 | //some med orders may not have an action defined tends to be renew order of orders that were renew from another
|
---|
131 | //order and outpatient orders
|
---|
132 | if (AMed1.OrderID = Piece(Piece(tmpArr.Strings[Pos],U,2),';',1)) then
|
---|
133 | begin
|
---|
134 | Alist.Selected[j] := True;
|
---|
135 | break;
|
---|
136 | end;
|
---|
137 |
|
---|
138 | end;
|
---|
139 | end;
|
---|
140 | if ActDeact = 'C' then Selected[i] := False;
|
---|
141 | end;
|
---|
142 | end;
|
---|
143 | end;
|
---|
144 |
|
---|
145 | procedure TfrmActivateDeactive.GetOriginalOrders(OrderID: TStringList; var OriginalOrder: TORStringList);
|
---|
146 | var
|
---|
147 | i: integer;
|
---|
148 | begin
|
---|
149 | CallV('ORWDX1 DCREN', [OrderID]);
|
---|
150 | for i := 0 to RPCBrokerV.Results.Count-1 do
|
---|
151 | OriginalOrder.Add(RPCBrokerV.Results.Strings[i]);
|
---|
152 | end;
|
---|
153 |
|
---|
154 | function TfrmActivateDeactive.PromptForm(Text: String): String;
|
---|
155 | begin
|
---|
156 | frmActivateDeactive := TfrmActivateDeactive.create(Application);
|
---|
157 | BuildForm(Text);
|
---|
158 | if Deact = True then Result := 'D';
|
---|
159 | if Act = True then Result := 'A';
|
---|
160 | if CancelProcess = True then Result := 'C';
|
---|
161 | end;
|
---|
162 |
|
---|
163 | procedure TfrmActivateDeactive.TActivateClick(Sender: TObject);
|
---|
164 | begin
|
---|
165 | inherited;
|
---|
166 | Act := True;
|
---|
167 | Deact := False;
|
---|
168 | CancelProcess := False;
|
---|
169 | frmActivateDeactive.Close;
|
---|
170 | end;
|
---|
171 |
|
---|
172 | procedure TfrmActivateDeactive.TDeactiveClick(Sender: TObject);
|
---|
173 | begin
|
---|
174 | inherited;
|
---|
175 | Act := False;
|
---|
176 | Deact := True;
|
---|
177 | CancelProcess := False;
|
---|
178 | frmActivateDeactive.Close;
|
---|
179 | end;
|
---|
180 |
|
---|
181 | procedure TfrmActivateDeactive.TCancelClick(Sender: TObject);
|
---|
182 | begin
|
---|
183 | inherited;
|
---|
184 | Act := False;
|
---|
185 | Deact := False;
|
---|
186 | CancelProcess := True;
|
---|
187 | frmActivateDeactive.Close;
|
---|
188 | end;
|
---|
189 |
|
---|
190 | end.
|
---|