1 | //kt -- Modified with SourceScanner on 8/8/2007
|
---|
2 | unit fOMSet;
|
---|
3 |
|
---|
4 | interface
|
---|
5 |
|
---|
6 | uses
|
---|
7 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
8 | StdCtrls, CheckLst, rOrders, uConst, ORFn, rODMeds, fODBase,uCore,fOrders, fframe,
|
---|
9 | DKLang;
|
---|
10 |
|
---|
11 | type
|
---|
12 | TSetItem = class
|
---|
13 | DialogIEN: Integer;
|
---|
14 | DialogType: Char;
|
---|
15 | OIIEN: string;
|
---|
16 | InPkg: string;
|
---|
17 | OwnedBy: TComponent;
|
---|
18 | RefNum: Integer;
|
---|
19 | end;
|
---|
20 |
|
---|
21 | TfrmOMSet = class(TForm)
|
---|
22 | lstSet: TCheckListBox;
|
---|
23 | cmdInterupt: TButton;
|
---|
24 | DKLanguageController1: TDKLanguageController;
|
---|
25 | procedure cmdInteruptClick(Sender: TObject);
|
---|
26 | procedure FormDestroy(Sender: TObject);
|
---|
27 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
28 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
29 | procedure FormCreate(Sender: TObject);
|
---|
30 | private
|
---|
31 | DoingNextItem : Boolean;
|
---|
32 | CloseRequested : Boolean;
|
---|
33 | FDelayEvent: TOrderDelayEvent;
|
---|
34 | FClosing: Boolean;
|
---|
35 | FRefNum: Integer;
|
---|
36 | FActiveMenus: Integer;
|
---|
37 | FClosebyDeaCheck: Boolean;
|
---|
38 | function IsCreatedByMenu(ASetItem: TSetItem): boolean;
|
---|
39 | function DeaCheckPassed(OIIens: string; APkg: string; AnEventType: Char): boolean;
|
---|
40 | procedure DoNextItem;
|
---|
41 | procedure UMDestroy(var Message: TMessage); message UM_DESTROY;
|
---|
42 | procedure UMDelayEvent(var Message: TMessage); message UM_DELAYEVENT;
|
---|
43 | public
|
---|
44 | procedure InsertList(SetList: TStringList; AnOwner: TComponent; ARefNum: Integer;
|
---|
45 | const KeyVarStr: string; AnEventType:Char =#0);
|
---|
46 | procedure SetEventDelay(AnEvent: TOrderDelayEvent);
|
---|
47 | property RefNum: Integer read FRefNum write FRefNum;
|
---|
48 | end;
|
---|
49 |
|
---|
50 | var
|
---|
51 | frmOMSet: TfrmOMSet;
|
---|
52 |
|
---|
53 | implementation
|
---|
54 |
|
---|
55 | {$R *.DFM}
|
---|
56 |
|
---|
57 | uses uOrders, fOMNavA, rMisc, uODBase;
|
---|
58 |
|
---|
59 | //const
|
---|
60 | //TX_STOP = 'Do you want to stop entering the current set of orders?'; <-- original line. //kt 8/8/2007
|
---|
61 | //TC_STOP = 'Interrupt Order Set'; <-- original line. //kt 8/8/2007
|
---|
62 |
|
---|
63 | var
|
---|
64 | TX_STOP : string; //kt
|
---|
65 | TC_STOP : string; //kt
|
---|
66 |
|
---|
67 | procedure SetupVars;
|
---|
68 | //kt Added entire function to replace constant declarations 8/8/2007
|
---|
69 | begin
|
---|
70 | TX_STOP := DKLangConstW('fOMSet_Do_you_want_to_stop_entering_the_current_set_of_ordersx');
|
---|
71 | TC_STOP := DKLangConstW('fOMSet_Interrupt_Order_Set');
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TfrmOMSet.SetEventDelay(AnEvent: TOrderDelayEvent);
|
---|
75 | begin
|
---|
76 | FDelayEvent := AnEvent;
|
---|
77 | end;
|
---|
78 |
|
---|
79 | procedure TfrmOMSet.InsertList(SetList: TStringList; AnOwner: TComponent; ARefNum: Integer;
|
---|
80 | const KeyVarStr: string; AnEventType: Char);
|
---|
81 | { expects SetList to be strings of DlgIEN^DlgType^DisplayName^OrderableItemIens }
|
---|
82 | //const
|
---|
83 | //TXT_DEAFAIL = 'You need have #DEA key to place the order '; <-- original line. //kt 8/8/2007
|
---|
84 | //TXT_INSTRUCT = #13 + 'Click OK to continue, Click Cancel to terminate the current order process.'; <-- original line. //kt 8/8/2007
|
---|
85 | var
|
---|
86 | i, InsertAt: Integer;
|
---|
87 | SetItem: TSetItem;
|
---|
88 | TXT_DEAFAIL : string; //kt
|
---|
89 | TXT_INSTRUCT : string; //kt
|
---|
90 |
|
---|
91 | begin
|
---|
92 | TXT_DEAFAIL := DKLangConstW('fOMSet_You_need_have_xDEA_key_to_place_the_order'); //kt added 8/8/2007
|
---|
93 | TXT_INSTRUCT := #13 + DKLangConstW('fOMSet_Click_OK_to_continuex_Click_Cancel_to_terminate_the_current_order_processx'); //kt added 8/8/2007
|
---|
94 | InsertAt := lstSet.ItemIndex + 1;
|
---|
95 | with SetList do for i := 0 to Count - 1 do
|
---|
96 | begin
|
---|
97 | SetItem := TSetItem.Create;
|
---|
98 | SetItem.DialogIEN := StrToIntDef(Piece(SetList[i], U, 1), 0);
|
---|
99 | SetItem.DialogType := CharAt(Piece(SetList[i], U, 2), 1);
|
---|
100 | SetItem.OIIEN := Piece(SetList[i], U, 4);
|
---|
101 | SetItem.InPkg := Piece(SetList[i], U, 5);
|
---|
102 | // put the Owner form and reference number in the last item
|
---|
103 | if i = Count - 1 then
|
---|
104 | begin
|
---|
105 | SetItem.OwnedBy := AnOwner;
|
---|
106 | SetItem.RefNum := ARefNum;
|
---|
107 | end;
|
---|
108 | if not DeaCheckPassed(SetItem.OIIEN, SetItem.InPkg, AnEventType) then
|
---|
109 | if InfoBox(TXT_DEAFAIL + Piece(SetList[i], U, 3) + TXT_INSTRUCT,
|
---|
110 | // 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDOK then <-- original line. //kt 8/8/2007
|
---|
111 | DKLangConstW('fOMSet_Warning'), MB_OKCANCEL or MB_ICONWARNING) = IDOK then //kt added 8/8/2007
|
---|
112 | Continue
|
---|
113 | else
|
---|
114 | begin
|
---|
115 | FClosebyDeaCheck := True;
|
---|
116 | Close;
|
---|
117 | Exit;
|
---|
118 | end;
|
---|
119 | lstSet.Items.InsertObject(InsertAt, Piece(SetList[i], U, 3), SetItem);
|
---|
120 | Inc(InsertAt);
|
---|
121 | end;
|
---|
122 | PushKeyVars(KeyVarStr);
|
---|
123 | DoNextItem;
|
---|
124 | end;
|
---|
125 |
|
---|
126 | procedure TfrmOMSet.DoNextItem;
|
---|
127 | var
|
---|
128 | SetItem: TSetItem;
|
---|
129 | theOwner: TComponent;
|
---|
130 |
|
---|
131 | procedure SkipToNext;
|
---|
132 | begin
|
---|
133 | lstSet.Checked[lstSet.ItemIndex] := True;
|
---|
134 | DoNextItem;
|
---|
135 | end;
|
---|
136 |
|
---|
137 | begin
|
---|
138 | DoingNextItem := true;
|
---|
139 | //frmFrame.UpdatePtInfoOnRefresh;
|
---|
140 | if FClosing then Exit;
|
---|
141 | if frmOrders <> nil then
|
---|
142 | begin
|
---|
143 | if (frmOrders.TheCurrentView<>nil) and (frmOrders.TheCurrentView.EventDelay.PtEventIFN>0)
|
---|
144 | and IsCompletedPtEvt(frmOrders.TheCurrentView.EventDelay.PtEventIFN) then
|
---|
145 | begin
|
---|
146 | FDelayEvent.EventType := #0;
|
---|
147 | FDelayEvent.EventIFN := 0;
|
---|
148 | FDelayEvent.TheParent := TParentEvent.Create;
|
---|
149 | FDelayEvent.EventName := '';
|
---|
150 | FDelayEvent.PtEventIFN := 0;
|
---|
151 | end;
|
---|
152 | end;
|
---|
153 | with lstSet do
|
---|
154 | begin
|
---|
155 | if ItemIndex >= Items.Count - 1 then
|
---|
156 | begin
|
---|
157 | Close;
|
---|
158 | Exit;
|
---|
159 | end;
|
---|
160 | ItemIndex := ItemIndex + 1;
|
---|
161 | SetItem := TSetItem(Items.Objects[ItemIndex]);
|
---|
162 | case SetItem.DialogType of
|
---|
163 | 'A': if not ActivateAction(IntToStr(SetItem.DialogIEN), Self, ItemIndex) then
|
---|
164 | begin
|
---|
165 | if IsCreatedByMenu(SetItem) and (lstSet.ItemIndex < lstSet.Items.Count - 1) then
|
---|
166 | lstSet.Checked[lstSet.ItemIndex] := True
|
---|
167 | else SkipToNext;
|
---|
168 | end;
|
---|
169 | 'D', 'Q': if not ActivateOrderDialog(IntToStr(SetItem.DialogIEN), FDelayEvent, Self, ItemIndex) then
|
---|
170 | begin
|
---|
171 | if IsCreatedByMenu(SetItem) and (lstSet.ItemIndex < lstSet.Items.Count - 1) then
|
---|
172 | lstSet.Checked[lstSet.ItemIndex] := True
|
---|
173 | else SkipToNext;
|
---|
174 | end;
|
---|
175 | 'M': if ActivateOrderMenu( IntToStr(SetItem.DialogIEN), FDelayEvent, Self, ItemIndex)
|
---|
176 | then Inc(FActiveMenus)
|
---|
177 | else
|
---|
178 | begin
|
---|
179 | if IsCreatedByMenu(SetItem) and (lstSet.ItemIndex < lstSet.Items.Count - 1) then
|
---|
180 | lstSet.Checked[lstSet.ItemIndex] := True
|
---|
181 | else
|
---|
182 | SkipToNext;
|
---|
183 | end;
|
---|
184 | 'O': begin
|
---|
185 | // if (Self.Owner.Name = 'frmOMNavA') then theOwner := Self.Owner else theOwner := self; <-- original line. //kt 8/8/2007
|
---|
186 | if (Self.Owner.Name = DKLangConstW('fOMSet_frmOMNavA')) then theOwner := Self.Owner else theOwner := self; //kt added 8/8/2007
|
---|
187 | if not ActivateOrderSet( IntToStr(SetItem.DialogIEN), FDelayEvent, theOwner, ItemIndex) then
|
---|
188 | begin
|
---|
189 | if IsCreatedByMenu(SetItem) and (lstSet.ItemIndex < lstSet.Items.Count - 1) then
|
---|
190 | lstSet.Checked[lstSet.ItemIndex] := True
|
---|
191 | else SkipToNext;
|
---|
192 | end;
|
---|
193 | end;
|
---|
194 | else begin
|
---|
195 | // InfoBox('Unsupported dialog type: ' + SetItem.DialogType, 'Error', MB_OK); <-- original line. //kt 8/8/2007
|
---|
196 | InfoBox(DKLangConstW('fOMSet_Unsupported_dialog_typex')+' ' + SetItem.DialogType, DKLangConstW('fOMSet_Error'), MB_OK); //kt added 8/8/2007
|
---|
197 | SkipToNext;
|
---|
198 | end;
|
---|
199 | end; {case}
|
---|
200 | end; {with lstSet}
|
---|
201 | DoingNextItem := false;
|
---|
202 | end;
|
---|
203 |
|
---|
204 | procedure TfrmOMSet.UMDelayEvent(var Message: TMessage);
|
---|
205 | begin
|
---|
206 | // ignore if delay from other than current itemindex
|
---|
207 | // (prevents completion of an order set from calling DoNextItem)
|
---|
208 | if Message.WParam = lstSet.ItemIndex then
|
---|
209 | if lstSet.ItemIndex < lstSet.Items.Count - 1 then DoNextItem else Close;
|
---|
210 | if CloseRequested then
|
---|
211 | Close;
|
---|
212 | end;
|
---|
213 |
|
---|
214 | procedure TfrmOMSet.UMDestroy(var Message: TMessage);
|
---|
215 | { Received whenever activated item is finished. Posts to Owner if last item in the set. }
|
---|
216 | var
|
---|
217 | SetItem: TSetItem;
|
---|
218 | RefNum: Integer;
|
---|
219 | begin
|
---|
220 | RefNum := Message.WParam;
|
---|
221 | lstSet.Checked[RefNum] := True;
|
---|
222 | SetItem := TSetItem(lstSet.Items.Objects[RefNum]);
|
---|
223 | if SetItem.DialogType = 'M' then Dec(FActiveMenus);
|
---|
224 | if (SetItem.OwnedBy <> nil) and (SetItem.DialogType <> 'O') then
|
---|
225 | begin
|
---|
226 | PopKeyVars;
|
---|
227 | if ((lstSet.ItemIndex = lstSet.Count - 1) and (lstSet.Checked[lstSet.ItemIndex] = True)) then Close;
|
---|
228 | if {(SetItem.OwnedBy <> Self) and} (SetItem.OwnedBy is TWinControl) then
|
---|
229 | begin
|
---|
230 | SendMessage(TWinControl(SetItem.OwnedBy).Handle, UM_DESTROY, SetItem.RefNum, 0);
|
---|
231 | //Exit;
|
---|
232 | end;
|
---|
233 | end;
|
---|
234 | // let menu or dialog finish closing before going on to next item in the order set
|
---|
235 | While RefNum <= lstSet.Items.Count - 2 do
|
---|
236 | begin
|
---|
237 | if not (lstSet.Checked[RefNum+1]) then Break
|
---|
238 | else
|
---|
239 | begin
|
---|
240 | RefNum := RefNum + 1;
|
---|
241 | lstSet.ItemIndex := RefNum;
|
---|
242 | end;
|
---|
243 | end;
|
---|
244 | PostMessage(Handle, UM_DELAYEVENT, RefNum, 0);
|
---|
245 | end;
|
---|
246 |
|
---|
247 | procedure TfrmOMSet.FormCreate(Sender: TObject);
|
---|
248 | begin
|
---|
249 | FActiveMenus := 0;
|
---|
250 | FClosing := False;
|
---|
251 | FClosebyDeaCheck := False;
|
---|
252 | NoFresh := True;
|
---|
253 | CloseRequested := false;
|
---|
254 | DoingNextItem := false;
|
---|
255 | end;
|
---|
256 |
|
---|
257 | procedure TfrmOMSet.FormDestroy(Sender: TObject);
|
---|
258 | var
|
---|
259 | i: Integer;
|
---|
260 | begin
|
---|
261 | with lstSet do for i := 0 to Items.Count - 1 do TSetItem(Items.Objects[i]).Free;
|
---|
262 | DestroyingOrderSet;
|
---|
263 | end;
|
---|
264 |
|
---|
265 | procedure TfrmOMSet.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
---|
266 | { if this is not the last item in the set, prompt whether to interrupt processing }
|
---|
267 | begin
|
---|
268 | SetupVars; //kt added 8/8/2007 to replace constants with vars.
|
---|
269 | if FClosebyDeaCheck then
|
---|
270 | CanClose := True
|
---|
271 | else if lstSet.ItemIndex < (lstSet.Items.Count - 1)
|
---|
272 | then CanClose := InfoBox(TX_STOP, TC_STOP, MB_YESNO) = IDYES;
|
---|
273 | end;
|
---|
274 |
|
---|
275 | procedure TfrmOMSet.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
276 | { Notify remaining owners that their item is done (or - really never completed) }
|
---|
277 | var
|
---|
278 | i: Integer;
|
---|
279 | SetItem: TSetItem;
|
---|
280 | begin
|
---|
281 | // do we need to iterate thru and send messages where OwnedBy <> nil?
|
---|
282 | FClosing := True;
|
---|
283 | for i := 1 to FActiveMenus do PopLastMenu;
|
---|
284 | if lstSet.Items.Count > 0 then
|
---|
285 | begin
|
---|
286 | if lstSet.ItemIndex < 0 then lstSet.ItemIndex := 0;
|
---|
287 | with lstSet do for i := ItemIndex to Items.Count - 1 do
|
---|
288 | begin
|
---|
289 | SetItem := TSetItem(lstSet.Items.Objects[i]);
|
---|
290 | if (SetItem.OwnedBy <> nil) and (SetItem.OwnedBy is TWinControl)
|
---|
291 | then SendMessage(TWinControl(SetItem.OwnedBy).Handle, UM_DESTROY, SetItem.RefNum, 0);
|
---|
292 | end;
|
---|
293 | end;
|
---|
294 | SaveUserBounds(Self);
|
---|
295 | NoFresh := False;
|
---|
296 | Action := caFree;
|
---|
297 | end;
|
---|
298 |
|
---|
299 | procedure TfrmOMSet.cmdInteruptClick(Sender: TObject);
|
---|
300 | begin
|
---|
301 | if DoingNextItem then
|
---|
302 | CloseRequested := true //Fix for CQ: 8297
|
---|
303 | else
|
---|
304 | Close;
|
---|
305 | end;
|
---|
306 |
|
---|
307 | function TfrmOMSet.DeaCheckPassed(OIIens: string; APkg: string; AnEventType: Char): boolean;
|
---|
308 | var
|
---|
309 | tmpIenList: TStringList;
|
---|
310 | i: integer;
|
---|
311 | isInpt: boolean;
|
---|
312 | begin
|
---|
313 | Result := True;
|
---|
314 | if Pos('PS',APkg) <> 1 then
|
---|
315 | Exit;
|
---|
316 | if Length(OIIens)=0 then Exit;
|
---|
317 | tmpIenList := TStringList.Create;
|
---|
318 | PiecesToList(OIIens,';',TStrings(tmpIenList));
|
---|
319 | case AnEventType of
|
---|
320 | 'A','T': isInpt := True;
|
---|
321 | 'D': isInpt := False;
|
---|
322 | else isInpt := Patient.Inpatient;
|
---|
323 | end;
|
---|
324 | for i := 0 to tmpIenList.Count - 1 do
|
---|
325 | if DEACheckFailed(StrToIntDef(tmpIenList[i],0), isInpt) then
|
---|
326 | begin
|
---|
327 | Result := False;
|
---|
328 | Break;
|
---|
329 | end;
|
---|
330 | end;
|
---|
331 |
|
---|
332 | function TfrmOMSet.IsCreatedByMenu(ASetItem: TSetItem): boolean;
|
---|
333 | begin
|
---|
334 | Result := False;
|
---|
335 | //if (AsetItem.OwnedBy <> nil) and (ASetItem.OwnedBy.Name = 'frmOMNavA') then <-- original line. //kt 8/8/2007
|
---|
336 | if (AsetItem.OwnedBy <> nil) and (ASetItem.OwnedBy.Name = DKLangConstW('fOMSet_frmOMNavA')) then //kt added 8/8/2007
|
---|
337 | Result := True;
|
---|
338 | end;
|
---|
339 |
|
---|
340 | end.
|
---|