Module

fODLab

Path

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

Last Modified

7/15/2014 3:26:42 PM

Units Used in Interface

Name Comments
fODBase -
uConst -

Units Used in Implementation

Name Comments
fFrame -
fLabCollTimes -
fODLabImmedColl -
fODLabOthCollSamp -
fODLabOthSpec -
fRptBox -
rCore -
rODBase -
rODLab -
rOrders -
uCore -
uODBase -

Classes

Name Comments
TCollSamp -
TfrmODLab -
TLabTest -

Procedures

Name Owner Declaration Scope Comments
cboAvailTestExit TfrmODLab procedure cboAvailTestExit(Sender: TObject); Public/Published -
cboAvailTestNeedData TfrmODLab procedure cboAvailTestNeedData(Sender: TObject; const StartFrom: string; Direction, InsertAt: Integer); Public/Published -
cboAvailTestSelect TfrmODLab procedure cboAvailTestSelect(Sender: TObject); Public/Published -
cboCollSampChange TfrmODLab procedure cboCollSampChange(Sender: TObject); Public/Published -
cboCollSampKeyPause TfrmODLab procedure cboCollSampKeyPause(Sender: TObject); Public/Published -
cboCollSampMouseClick TfrmODLab procedure cboCollSampMouseClick(Sender: TObject); Public/Published -
cboCollTimeChange TfrmODLab procedure cboCollTimeChange(Sender: TObject); Public/Published -
cboCollTimeExit TfrmODLab procedure cboCollTimeExit(Sender: TObject); Public/Published -
cboCollTypeChange TfrmODLab procedure cboCollTypeChange(Sender: TObject); Public/Published -
cboFrequencyChange TfrmODLab procedure cboFrequencyChange(Sender: TObject); Public/Published -
cboSpecimenChange TfrmODLab procedure cboSpecimenChange(Sender: TObject); Public/Published -
cboSpecimenKeyPause TfrmODLab procedure cboSpecimenKeyPause(Sender: TObject); Public/Published -
cboSpecimenMouseClick TfrmODLab procedure cboSpecimenMouseClick(Sender: TObject); Public/Published -
cboUrgencyChange TfrmODLab procedure cboUrgencyChange(Sender: TObject); Public/Published -
ChangeCollSamp TLabTest procedure ChangeCollSamp(CollSampIEN: Integer); Public/Published -
ChangeComment TLabTest procedure ChangeComment(const CommentText: string); Public/Published -
ChangeSpecimen TLabTest procedure ChangeSpecimen(const SpecimenIEN: string); Public/Published -
ChangeUrgency TLabTest procedure ChangeUrgency(const UrgencyIEN: string); Public/Published -
cmdImmedCollClick TfrmODLab procedure cmdImmedCollClick(Sender: TObject); Public/Published -
ControlChange TfrmODLab procedure ControlChange(Sender: TObject); Public/Published End of TLabTest object
DetermineCollectionDefaults TfrmODLab procedure DetermineCollectionDefaults(Responses: TResponses); Public I: integer;
DisableCommentPanels TfrmODLab procedure DisableCommentPanels; Public/Published -
DisplayChangedOrders TfrmODLab procedure DisplayChangedOrders(ACollType: string); Private -
DoseDrawComment TfrmODLab procedure DoseDrawComment; Protected -
FillCollSampList TLabTest procedure FillCollSampList(LoadData: TStringList; DfltCollSamp: Integer); Public/Published
1  2        3         4       5         6          7         8          9               10   
n^IEN^CollSampName^SpecIEN^TubeTop^MinInterval^MaxPerDay^LabCollect^SampReqCommentIEN;name^SpecName
FormClose TfrmODLab procedure FormClose(Sender: TObject; var Action: TCloseAction); Public/Published -
FormCreate TfrmODLab procedure FormCreate(Sender: TObject); Public/Published Base form procedures shared by all dialogs ------------------------------------------------
GetAllCollSamples TfrmODLab procedure GetAllCollSamples(AComboBox: TORComboBox); Protected -
GetAllSpecimens TfrmODLab procedure GetAllSpecimens(AComboBox: TORComboBox); Protected -
grpPeakTroughClick TfrmODLab procedure grpPeakTroughClick(Sender: TObject); Public/Published -
InitDialog TfrmODLab procedure InitDialog; override; Protected -
LoadAllSamples TLabTest procedure LoadAllSamples; Public/Published -
LoadCollSamp TLabTest procedure LoadCollSamp(AComboBox: TORComboBox); Public/Published Loads the collection sample combo box, expects CollSamp to already be set to default
LoadCollType TfrmODLab procedure LoadCollType(AComboBox:TORComboBox); Protected -
LoadRequiredComment TfrmODLab procedure LoadRequiredComment(CmtType: integer); Public -
LoadSpecimen TLabTest procedure LoadSpecimen(AComboBox: TORComboBox); Public/Published Loads specimen combo box, if SpecimenList is empty, use 'E' xref on 61 ??
LoadUrgency TLabTest procedure LoadUrgency(CollType: string; AComboBox:TORComboBox); Public/Published -
pnlCollTimeButtonEnter TfrmODLab procedure pnlCollTimeButtonEnter(Sender: TObject); Public/Published -
pnlCollTimeButtonExit TfrmODLab procedure pnlCollTimeButtonExit(Sender: TObject); Public/Published -
ReadServerVariables TfrmODLab procedure ReadServerVariables; Private -
SetCollSampDflts TLabTest procedure SetCollSampDflts; Public/Published -
SetError - procedure SetError(const x: string); Local -
setup508Label TfrmODLab procedure setup508Label(text: string; lbl: TVA508StaticText; ctrl: TControl; lbl2: string); Private
TDP - CQ#19396 Added to address 508 related changes. I modified slightly to
       change lbl.Caption and retain lbl.Width
SetupCollTimes TfrmODLab procedure SetupCollTimes(CollType: string); Protected -
SetupDialog TfrmODLab procedure SetupDialog(OrderAction: Integer; const ID: string); override; Public -
txtAddlCommentExit TfrmODLab procedure txtAddlCommentExit(Sender: TObject); Public/Published -
txtAntiCoagulantExit TfrmODLab procedure txtAntiCoagulantExit(Sender: TObject); Public/Published -
txtDoseTimeExit TfrmODLab procedure txtDoseTimeExit(Sender: TObject); Public/Published -
txtDrawTimeExit TfrmODLab procedure txtDrawTimeExit(Sender: TObject); Public/Published -
txtOrderCommentExit TfrmODLab procedure txtOrderCommentExit(Sender: TObject); Public/Published -
txtUrineVolumeExit TfrmODLab procedure txtUrineVolumeExit(Sender: TObject); Public/Published -
Validate TfrmODLab procedure Validate(var AnErrMsg: string); override; Protected -
ViewinReportWindow1Click TfrmODLab procedure ViewinReportWindow1Click(Sender: TObject); Public/Published -

Functions

Name Owner Declaration Scope Comments
IndexOfCollSamp TLabTest function IndexOfCollSamp(CollSampIEN: Integer): Integer; Public/Published -
LabCanCollect TLabTest function LabCanCollect: Boolean; Public/Published -
NameOfCollSamp TLabTest function NameOfCollSamp: string; Public/Published -
NameOfSpecimen TLabTest function NameOfSpecimen: string; Public/Published -
NameOfUrgency TLabTest function NameOfUrgency: string; Public/Published -
ObtainCollSamp TLabTest function ObtainCollSamp: Boolean; Public/Published -
ObtainComment TLabTest function ObtainComment: Boolean; Public/Published -
ObtainSpecimen TLabTest function ObtainSpecimen: Boolean; Public/Published -
ObtainUrgency TLabTest function ObtainUrgency: Boolean; Public/Published -
ValidCollTime TfrmODLab function ValidCollTime(UserEntry: string): string; Protected -

Global Variables

Name Type Declaration Comments
ALabTest TLabTest ALabTest: TLabTest; -
LRFDATE UnicodeString LRFDATE : string; The default collection time (NOW,NEXT,AM,PM,T...)
LRFSAMP UnicodeString LRFSAMP : string; The default sample (ptr)
LRFSCH UnicodeString LRFSCH : string; The default schedule? (ONE TIME, QD, ...)
LRFSPEC UnicodeString LRFSPEC : string; The default specimen (ptr)
LRFURG UnicodeString LRFURG : string; The default urgency (number) TRY '2'
LRFZX UnicodeString LRFZX : string; The default collection type (LC,WC,SP,I)
uDfltCollType UnicodeString uDfltCollType: string; -
uDfltUrgency Integer uDfltUrgency: Integer; -
UserHasLRLABKey Boolean UserHasLRLABKey: boolean; -

Constants

Name Declaration Scope Comments
CmtType array[0..6] of string = ('ANTICOAGULATION','DOSE/DRAW TIMES','ORDER COMMENT', Interfaced -
TX_NO_IMMED 'Immediate collect is not available for this test/sample' Global -
TX_NO_IMMED_CAP 'Invalid Collection Type' Global -
TX_NO_TEST 'A Lab Test must be specified.' Global -


Module Source

1     unit fODLab;
2     
3     interface
4     
5     uses
6       SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
7       Forms, Dialogs, StdCtrls, ORCtrls, ORfn, fODBase, ExtCtrls, ComCtrls, uConst,
8       ORDtTm, Buttons, Menus, VA508AccessibilityManager, VA508AccessibilityRouter;
9     
10    type
11      TfrmODLab = class(TfrmODBase)
12        lblAvailTests: TLabel;
13        cboAvailTest: TORComboBox;
14        lblCollTime: TLabel;
15        cboFrequency: TORComboBox;
16        lblTestName: TLabel;
17        lblCollSamp: TLabel;
18        cboCollSamp: TORComboBox;
19        lblSpecimen: TLabel;
20        cboSpecimen: TORComboBox;
21        lblUrgency: TLabel;
22        cboUrgency: TORComboBox;
23        lblAddlComment: TLabel;
24        txtAddlComment: TCaptionEdit;
25        txtDays: TCaptionEdit;
26        bvlTestName: TBevel;
27        lblFrequency: TLabel;
28        pnlHide: TORAutoPanel;
29        pnlOrderComment: TORAutoPanel;
30        lblOrderComment: TOROffsetLabel;
31        pnlAntiCoagulation: TORAutoPanel;
32        lblAntiCoagulant: TOROffsetLabel;
33        txtAntiCoagulant: TCaptionEdit;
34        pnlUrineVolume: TORAutoPanel;
35        lblUrineVolume: TOROffsetLabel;
36        txtUrineVolume: TCaptionEdit;
37        pnlPeakTrough: TORAutoPanel;
38        lblPeakTrough: TOROffsetLabel;
39        grpPeakTrough: TRadioGroup;
40        lblReqComment: TOROffsetLabel;
41        pnlDoseDraw: TORAutoPanel;
42        lblDose: TOROffsetLabel;
43        lblDraw: TOROffsetLabel;
44        txtDoseTime: TCaptionEdit;
45        txtDrawTime: TCaptionEdit;
46        txtOrderComment: TCaptionEdit;
47        FLabCommonCombo: TORListBox;
48        lblHowManyDays: TLabel;
49        cboCollTime: TORComboBox;
50        lblCollType: TLabel;
51        pnlCollTimeButton: TKeyClickPanel;
52        cboCollType: TORComboBox;
53        calCollTime: TORDateBox;
54        dlgLabCollTime: TORDateTimeDlg;
55        txtImmedColl: TCaptionEdit;
56        cmdImmedColl: TSpeedButton;
57        MessagePopup: TPopupMenu;
58        ViewinReportWindow1: TMenuItem;
59        Frequencylbl508: TVA508StaticText;
60        HowManyDayslbl508: TVA508StaticText;
61        specimenlbl508: TVA508StaticText;
62        CollSamplbl508: TVA508StaticText;
63        procedure FormCreate(Sender: TObject);
64        procedure ControlChange(Sender: TObject);
65        procedure cboAvailTestNeedData(Sender: TObject;
66                  const StartFrom: string; Direction, InsertAt: Integer);
67        procedure cboAvailTestSelect(Sender: TObject);
68        procedure cboCollSampChange(Sender: TObject);
69        procedure cboUrgencyChange(Sender: TObject);
70        procedure cboSpecimenChange(Sender: TObject);
71        procedure txtAddlCommentExit(Sender: TObject);
72        procedure cboCollTimeChange(Sender: TObject);
73        procedure cboFrequencyChange(Sender: TObject);
74        procedure cboCollTypeChange(Sender: TObject);
75        procedure FormClose(Sender: TObject; var Action: TCloseAction);
76        procedure txtOrderCommentExit(Sender: TObject);
77        procedure txtAntiCoagulantExit(Sender: TObject);
78        procedure txtUrineVolumeExit(Sender: TObject);
79        procedure grpPeakTroughClick(Sender: TObject);
80        procedure txtDoseTimeExit(Sender: TObject);
81        procedure txtDrawTimeExit(Sender: TObject);
82        procedure DisableCommentPanels;
83        procedure cboAvailTestExit(Sender: TObject);
84        procedure cboCollSampKeyPause(Sender: TObject);
85        procedure cboCollSampMouseClick(Sender: TObject);
86        procedure cboCollTimeExit(Sender: TObject);
87        procedure cboSpecimenMouseClick(Sender: TObject);
88        procedure cboSpecimenKeyPause(Sender: TObject);
89        procedure cmdImmedCollClick(Sender: TObject);
90        procedure pnlCollTimeButtonEnter(Sender: TObject);
91        procedure pnlCollTimeButtonExit(Sender: TObject);
92        procedure ViewinReportWindow1Click(Sender: TObject);
93      protected
94        FCmtTypes: TStringList ;
95        procedure InitDialog; override;
96        procedure Validate(var AnErrMsg: string); override;
97        function  ValidCollTime(UserEntry: string): string;
98        procedure DoseDrawComment;
99        procedure GetAllCollSamples(AComboBox: TORComboBox);
100       procedure GetAllSpecimens(AComboBox: TORComboBox);
101       procedure SetupCollTimes(CollType: string);
102       procedure LoadCollType(AComboBox:TORComboBox);
103      private
104       FLastCollType: string;
105       FLastCollTime: string;
106       FLastLabCollTime: string;
107       FLastLabID: string;
108       FLastItemID: string;
109       FEvtDelayLoc: integer;
110       FEvtDivision: integer;
111       procedure ReadServerVariables;
112       procedure DisplayChangedOrders(ACollType: string);
113       procedure setup508Label(text: string; lbl: TVA508StaticText; ctrl: TControl; lbl2: string);
114     public
115       procedure SetupDialog(OrderAction: Integer; const ID: string); override;
116       procedure LoadRequiredComment(CmtType: integer);
117       procedure DetermineCollectionDefaults(Responses: TResponses);
118       property  EvtDelayLoc: integer   read FEvtDelayLoc   write FEvtDelayLoc;
119       property  EvtDivision: integer   read FEvtDivision   write FEvtDivision;
120     end;
121   
122     type
123     TCollSamp = class(TObject)
124       CollSampID: Integer;                  { IEN of CollSamp }
125       CollSampName: string;                 { Name of CollSamp }
126       SpecimenID: Integer;                  { IEN of default specimen }
127       SpecimenName: string;                 { Name of the specimen }
128       TubeColor: string;                    { TubeColor (text) }
129       MinInterval: Integer;                 { Minimum days between orders }
130       MaxPerDay: Integer;                   { Maximum orders per day }
131       LabCanCollect: Boolean;               { True if lab can collect }
132       SampReqComment: string;               { Name of required comment }
133       WardComment: TStringList;             { CollSamp specific comment }
134     end;
135   
136     TLabTest = class(TObject)
137       TestID: Integer;                      { IEN of Lab Test }
138       TestName: string;                     { Name of Lab Test }
139       LabSubscript: string ;                { which section of Lab? }
140       CollSamp: Integer;                    { index into CollSampList }
141       Specimen: Integer;                    { IEN of specimen }
142       Urgency: Integer;                     { IEN of urgency }
143       Comment: TStringList;                 { text of comment }
144       TestReqComment: string;               { Name of required comment }
145       CurReqComment: string;                { name of required comment }
146       CurWardComment: TStringList;          { WP of Ward Comment }
147       UniqueCollSamp: Boolean;              { true if not prompt CollSamp }
148       CollSampList: TList;                  { collection sample objects }
149       CollSampCount: integer;               { count of original contents of CollSampList}
150       SpecimenList: TStringList;            { Strings: IEN^Specimen Name }
151       SpecListCount: integer;               { count of original contents of SpecimenList}
152       UrgencyList: TStringList;             { Strings: IEN^Urgency Name }
153       ForceUrgency: Boolean;                { true if not prompt Urgency }
154       QuickOrderResponses: TResponses;      { if created as a result of a quick order selection}
155       { functions & procedures }
156       constructor Create(const LabTestIEN: string; Responses: TResponses);
157       destructor Destroy; override ;
158       function IndexOfCollSamp(CollSampIEN: Integer): Integer;
159       procedure FillCollSampList(LoadData: TStringList; DfltCollSamp: Integer);
160       procedure LoadAllSamples;
161       procedure SetCollSampDflts;
162       procedure ChangeCollSamp(CollSampIEN: Integer);
163       procedure ChangeSpecimen(const SpecimenIEN: string);
164       procedure ChangeUrgency(const UrgencyIEN: string);
165       procedure ChangeComment(const CommentText: string);
166       function  LabCanCollect: Boolean;
167       procedure LoadCollSamp(AComboBox: TORComboBox);
168       procedure LoadSpecimen(AComboBox: TORComboBox);
169       procedure LoadUrgency(CollType: string; AComboBox:TORComboBox);
170       function NameOfCollSamp: string;
171       function NameOfSpecimen: string;
172       function NameOfUrgency: string;
173       function ObtainCollSamp: Boolean;
174       function ObtainSpecimen: Boolean;
175       function ObtainUrgency: Boolean;
176       function ObtainComment: Boolean;
177     end;
178   
179   const
180     CmtType: array[0..6] of string = ('ANTICOAGULATION','DOSE/DRAW TIMES','ORDER COMMENT',
181                                       'ORDER COMMENT MODIFIED','TDM (PEAK-TROUGH)',
182                                       'TRANSFUSION','URINE VOLUME');
183   
184   implementation
185   
186   {$R *.DFM}
187   
188   uses rODBase, rODLab, uCore, rCore, fODLabOthCollSamp, fODLabOthSpec, fODLabImmedColl, fLabCollTimes,
189    rOrders, uODBase, fRptBox, fFrame;
190   
191   
192   var
193     uDfltUrgency: Integer;
194     uDfltCollType: string;
195     ALabTest: TLabTest;
196     UserHasLRLABKey: boolean;
197     LRFZX     : string;  //the default collection type  (LC,WC,SP,I)
198     LRFSAMP   : string;  //the default sample           (ptr)
199     LRFSPEC   : string;  //the default specimen         (ptr)
200     LRFDATE   : string;  //the default collection time  (NOW,NEXT,AM,PM,T...)
201     LRFURG    : string;  //the default urgency          (number)		TRY '2'
202     LRFSCH    : string;  //the default schedule?        (ONE TIME, QD, ...)
203   
204   const
205     TX_NO_TEST          = 'A Lab Test must be specified.'    ;
206     TX_NO_IMMED = 'Immediate collect is not available for this test/sample';
207     TX_NO_IMMED_CAP = 'Invalid Collection Type';
208   
209   { base form procedures shared by all dialogs ------------------------------------------------ }
210   
211   procedure TfrmODLab.FormCreate(Sender: TObject);
212   var
213     i, n, HMD508: integer;
214     AList: TStringList;
215   begin
216     frmFrame.pnlVisit.Enabled := false;
217     AutoSizeDisabled := True;
218     inherited;
219     AList := TStringList.Create;
220     try
221       LRFZX    := '';
222       LRFSAMP  := '';
223       LRFSPEC  := '';
224       LRFDATE  := '';
225       LRFURG   := '';
226       LRFSCH   := '';
227       FLastColltime := '';
228       FLastLabCollTime := '';
229       FLastItemID := '';
230       uDfltCollType := '';
231       FillerID := 'LR';
232       FEvtDelayLoc := 0;
233       FEvtDivision := 0;
234       UserHasLRLABKey := User.HasKey('LRLAB');
235       AllowQuickOrder := True;
236       StatusText('Loading Dialog Definition');
237       pnlHide.BringToFront;
238       lblReqComment.Visible := False ;
239       FCmtTypes := TStringList.Create;
240       for i := 0 to 6 do FCmtTypes.Add(CmtType[i]) ;
241       Responses.Dialog := 'LR OTHER LAB TESTS';        // loads formatting info
242       StatusText('Loading Default Values');
243       if Self.EvtID > 0 then
244       begin
245         EvtDelayLoc := StrToIntDef(GetEventLoc1(IntToStr(Self.EvtID)),0);
246         EvtDivision := StrToIntDef(GetEventDiv1(IntToStr(Self.EvtID)),0);
247         if EvtDelayLoc>0 then
248           FastAssign(ODForLab(EvtDelayLoc, EvtDivision), AList)
249         else
250           FastAssign(ODForLab(Encounter.Location, EvtDivision), AList);
251       end else
252         FastAssign(ODForLab(Encounter.Location), AList); // ODForLab returns TStrings with defaults
253       CtrlInits.LoadDefaults(AList);
254       InitDialog;
255       with CtrlInits do
256       begin
257         SetControl(cboCollType, 'Collection Types');
258         uDfltCollType := ExtractDefault(AList, 'Collection Types');
259         if uDfltCollType <> '' then
260           cboCollType.SelectByID(uDfltCollType)
261         else if OrderForInpatient then
262           cboCollType.SelectByID('LC')
263         else
264           cboCollType.SelectByID('SP');
265         SetupCollTimes(cboCollType.ItemID);
266         StatusText('Initializing List of Tests');
267         SetControl(cboAvailTest, 'ShortList');
268         if cboAvailTest.Items.Count > 0 then cboAvailTest.InsertSeparator;
269         cboAvailTest.InitLongList('');
270         //TDP - CQ#19396 HMD508 added to guarantee 508 label did not change width
271         HMD508 := HowManyDayslbl508.Width;
272         SetControl(cboFrequency, 'Schedules');
273         HowManydayslbl508.Width := HMD508;
274         with cboFrequency do
275           begin
276             if ItemIndex < 0 then ItemIndex := Items.IndexOf('ONE TIME');
277             if ItemIndex < 0 then ItemIndex := Items.IndexOf('ONCE');
278           end;
279         lblHowManyDays.Enabled := False;                 { have this call change event in case }
280         txtDays.Enabled := False;                         { the default is not 'one time'?      }
281         //TDP - CQ#19396 Following line does not appear to be needed
282         //setup508Label(HowManyText, HowManyDayslbl508, txtDays, lblHowManyDays.Caption);
283       end;
284       if EvTDelayLoc>0 then
285         n := MaxDays(EvtDelayLoc, 0)
286       else
287         n := MaxDays(Encounter.Location, 0);
288       if n < 0 then with cboFrequency do
289         begin
290           ItemIndex := Items.IndexOf('ONE TIME');
291           if ItemIndex = -1 then ItemIndex := Items.IndexOf('ONCE');
292           Enabled := False;
293           Font.Color := clGrayText;
294           lblFrequency.Enabled := False;
295           setup508Label(Text, Frequencylbl508, cboFrequency, lblFrequency.Caption);
296         end;
297       PreserveControl(cboAvailTest);
298       PreserveControl(cboCollType);
299       PreserveControl(cboCollTime);
300       PreserveControl(calCollTime);
301       PreserveControl(cboFrequency);
302       PreserveControl(txtDays);
303       StatusText('');
304     finally
305       AList.Free;
306     end;
307   end;
308   
309   {TDP - CQ#19396 Added to address 508 related changes. I modified slightly to
310          change lbl.Caption and retain lbl.Width}
311   procedure TfrmODLab.setup508Label(text: string; lbl: TVA508StaticText; ctrl: TControl; lbl2: string);
312   var
313   Width: integer;
314   begin
315     if ScreenReaderSystemActive and not ctrl.Enabled then begin
316       lbl.Enabled := True;
317       lbl.Visible := True;
318       Width := lbl.Width;
319       lbl.Caption := lbl2 +'. Read Only. Value is ' + Text;
320       lbl.Width := Width;
321     end else
322       lbl.Visible := false;
323   end;
324   
325   procedure TfrmODLab.InitDialog;
326   begin
327     inherited;
328     Changing := True;
329     if ALabTest <> nil then
330       begin
331         ALabTest.Destroy;
332         ALabTest := nil;
333       end;
334     with CtrlInits do
335       begin
336         SetControl(cboUrgency, 'Default Urgency') ;
337         uDfltUrgency := StrToInt(Piece(cboUrgency.Items[0],U,1));
338       end;
339     lblTestName.Caption := '';
340     DisableCommentPanels;
341     cboAvailTest.SelectByID(FLastItemID);
342     ActiveControl := cboAvailTest;
343     cboAvailTest.ItemIndex := -1;
344     StatusText('');
345     Changing := False ;
346   end;
347   
348   procedure TfrmODLab.SetupDialog(OrderAction: Integer; const ID: string);
349   var
350     tmpResp: TResponse;
351     i: integer;
352   begin
353     inherited;
354     ReadServerVariables;
355     if LRFZX <> '' then
356       begin
357         cboCollType.SelectByID(LRFZX);
358         if cboCollType.ItemIndex > -1 then SetupCollTimes(LRFZX);
359       end;
360     if (LRFSCH <> '') and (cboFrequency.Enabled) then
361       begin
362         cboFrequency.ItemIndex := cboFrequency.Items.IndexOf(LRFSCH);
363         cboFrequencyChange(Self);
364       end;
365     if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses, ALabTest do
366      begin
367         SetControl(cboAvailTest,       'ORDERABLE', 1);
368         cboAvailTestSelect(Self);
369         if ALabTest = nil then Exit;  // Causes access violation in FillCollSampleList
370         Changing := True;
371         SetControl(cboFrequency,       'SCHEDULE', 1);
372         SetControl(txtDays,            'DAYS', 1);
373         tmpResp := FindResponseByName('SAMPLE'  ,1);
374         if (tmpResp <> nil) and (tmpResp.IValue <> '') then with cboCollSamp do
375           begin
376             SelectByID(tmpResp.IValue);
377             if ItemIndex < 0 then
378               begin
379                 LoadAllSamples;
380                 Items.Insert(0, tmpResp.IValue + U + tmpResp.EValue);
381                 ItemIndex := 0  ;
382               end;
383           end;
384         cboCollSampChange(Self);
385         DetermineCollectionDefaults(Responses);
386         tmpResp := FindResponseByName('SPECIMEN'  ,1);
387         if (tmpResp <> nil) and (tmpResp.IValue <> '') then with cboSpecimen do
388           begin
389             SelectByID(tmpResp.IValue);
390             if ItemIndex < 0 then
391               begin
392                 if ALabTest <> nil then
393                   ALabTest.SpecimenList.Add(tmpResp.IValue + U + tmpResp.EValue);
394                 Items.Insert(0, tmpResp.IValue + U + tmpResp.EValue);
395                 ItemIndex := 0  ;
396               end;
397           end
398         else
399           if (LRFSPEC <> '') then cboSpecimen.SelectByID(LRFSPEC);
400         if ALabTest <> nil then Specimen := cboSpecimen.ItemIEN;
401         if ALabTest <> nil then AlabTest.LoadUrgency(cboCollType.ItemID, cboUrgency);
402         SetControl(cboUrgency,         'URGENCY', 1);
403         if cboUrgency.ItemIEN = 0 then
404           begin
405             if StrToIntDef(LRFURG, 0) > 0 then
406               cboUrgency.SelectByID(LRFURG)
407             else if (ALabTest <> nil) and (Urgency = 0) and (cboUrgency.Items.Count = 1) then
408               cboUrgency.ItemIndex := 0;
409           end;
410         if ALabTest <> nil then Urgency := cboUrgency.ItemIEN;
411         i := 1 ;
412         tmpResp := Responses.FindResponseByName('COMMENT',i);
413         while tmpResp <> nil do
414           begin
415             Comment.Add(tmpResp.EValue);
416             Inc(i);
417             tmpResp := Responses.FindResponseByName('COMMENT',i);
418           end ;
419         with cboFrequency do
420           if not Enabled then
421             begin
422               ItemIndex := Items.IndexOf('ONE TIME');
423               if ItemIndex = -1 then ItemIndex := Items.IndexOf('ONCE');
424             end;
425         cboFrequencyChange(Self);
426         Changing := False;
427         ControlChange(Self);
428      end;
429   end;
430   
431   { dialog specific event procedures follow here ---------------------------------------------- }
432   
433   constructor TLabTest.Create(const LabTestIEN: string; Responses: TResponses);
434   var
435     LoadData, OneSamp: TStringList;
436     DfltCollSamp: Integer;
437     x: string;
438     tmpResp: TResponse;
439   begin
440     LoadData := TStringList.Create;
441     try
442       LoadLabTestData(LoadData, LabTestIEN) ;
443       with LoadData do
444       begin
445         QuickOrderResponses := Responses;
446         TestID := StrToInt(LabTestIEN);
447         TestName := Piece(ExtractDefault(LoadData, 'Test Name'),U,1);
448         LabSubscript := Piece(ExtractDefault(LoadData, 'Item ID'),U,2);
449         TestReqComment := ExtractDefault(LoadData, 'ReqCom');
450         if Length(ExtractDefault(LoadData, 'Unique CollSamp')) > 0 then UniqueCollSamp := True;
451         x := ExtractDefault(LoadData, 'Unique CollSamp');                            
452         if Length(x) = 0 then x := ExtractDefault(LoadData, 'Lab CollSamp');
453         if Length(x) = 0 then x := ExtractDefault(LoadData, 'Default CollSamp');
454         if Length(x) = 0 then x := '-1';
455         DfltCollSamp := StrToInt(x);
456         SpecimenList := TStringList.Create;
457         ExtractItems(SpecimenList, LoadData, 'Specimens');
458         if LRFSPEC <> '' then SpecimenList.Add(GetOneSpecimen(StrToInt(LRFSPEC)));
459         UrgencyList := TStringList.Create;
460         if Length(ExtractDefault(LoadData, 'Default Urgency')) > 0 then  { forced urgency }
461           begin
462             ForceUrgency := True;
463             UrgencyList.Add(ExtractDefault(LoadData, 'Default Urgency'));
464             Urgency := StrToInt(Piece(ExtractDefault(LoadData, 'Default Urgency'), '^', 1));
465             uDfltUrgency := Urgency;
466           end
467         else
468           begin                 { list of urgencies }
469             ExtractItems(UrgencyList, LoadData, 'Urgencies');
470             if StrToIntDef(LRFURG, 0) > 0 then
471               Urgency := StrToInt(LRFURG)
472             else
473               Urgency := uDfltUrgency;
474           end;
475         Comment := TStringList.Create ;
476         CurWardComment := TStringList.Create;
477         ExtractText(CurWardComment, LoadData, 'GenWardInstructions');
478         CollSamp := 0;
479         CollSampList := TList.Create;
480         FillCollSampList(LoadData, DfltCollSamp);
481         with QuickOrderResponses do tmpResp := FindResponseByName('SAMPLE'  ,1);
482         if (LRFSAMP <> '') and (IndexOfCollSamp(StrToInt(LRFSAMP)) < 0) and
483            (not UniqueCollSamp) and (tmpResp = nil) then
484           begin
485             OneSamp := TStringList.Create;
486             try
487               FastAssign(GetOneCollSamp(StrToInt(LRFSAMP)), OneSamp);
488               FillCollSampList(OneSamp, CollSampList.Count);
489             finally
490               OneSamp.Free;
491             end;
492           end;
493         if (not UniqueCollSamp) and (CollSampList.Count = 0) then LoadAllSamples;
494         CollSampCount := CollSampList.Count;
495       end;
496     finally
497       LoadData.Free;
498     end;
499     SetCollSampDflts;
500   end;
501   
502   destructor TLabTest.Destroy;
503   var
504     i: Integer;
505   begin
506     if CollSampList <> nil then
507       with CollSampList do for i := 0 to Count - 1 do
508        with TCollSamp(Items[i]) do
509         begin
510           WardComment.Free;
511           Free;
512         end;
513     CollSampList.Free;
514     SpecimenList.Free;
515     UrgencyList.Free;
516     CurWardComment.Free;
517     Comment.Free;
518     inherited Destroy;
519   end;
520   
521   function TLabTest.IndexOfCollSamp(CollSampIEN: Integer): Integer;
522   var
523     i: Integer;
524   begin
525     Result := -1;
526     with CollSampList do for i := 0 to Count - 1 do with TCollSamp(Items[i]) do
527       if CollSampIEN = CollSampID then
528       begin
529         Result := i;
530         break;
531       end;
532   end;
533   
534   procedure TLabTest.LoadAllSamples;
535   var
536     LoadList, SpecList: TStringList;
537     i: Integer;
538   begin
539     LoadList := TStringList.Create;
540     SpecList := TStringList.Create;
541     try
542       LoadSamples(LoadList) ;
543       FillCollSampList(LoadList, 0);
544       ExtractItems(SpecList, LoadList, 'Specimens');
545       with SpecList do for i := 0 to Count - 1 do
546         if SpecimenList.IndexOf(Strings[i]) = -1 then SpecimenList.Add(Strings[i]);
547     finally
548       LoadList.Free;
549       SpecList.Free;
550     end;
551   end;
552   
553   procedure TLabTest.FillCollSampList(LoadData: TStringList; DfltCollSamp: Integer);
554   {1  2        3         4       5         6          7         8          9               10   }
555   {n^IEN^CollSampName^SpecIEN^TubeTop^MinInterval^MaxPerDay^LabCollect^SampReqCommentIEN;name^SpecName}
556   var
557     i, LastListItem, AnIndex: Integer;
558     ACollSamp: TCollSamp;
559     LabCollSamp: Integer;
560   begin
561     i := -1;
562     if CollSampList = nil then CollSampList := TList.Create;
563     LastListItem := CollSampList.Count ;
564     LabCollSamp := StrToIntDef(ExtractDefault(LoadData, 'Lab CollSamp'), 0);
565     repeat Inc(i) until (i = LoadData.Count) or (LoadData[i] = '~CollSamp');
566     Inc(i);
567     if i < LoadData.Count then repeat
568       if LoadData[i][1] = 'i' then
569         begin
570           ACollSamp := TCollSamp.Create;
571           with ACollSamp do
572             begin
573               AnIndex         := StrToIntDef(Copy(Piece(LoadData[i], '^', 1), 2, 999), -1);
574               CollSampID      := StrToInt(Piece(LoadData[i], '^', 2));
575               CollSampName    := Piece(LoadData[i], '^', 3);
576               SpecimenID      := StrToIntDef(Piece(LoadData[i], '^', 4), 0);
577               SpecimenName    := Piece(LoadData[i], '^', 10);
578               TubeColor       := Piece(LoadData[i], '^', 5);
579               MinInterval     := StrToIntDef(Piece(LoadData[i], '^', 6), 0);
580               MaxPerDay       := StrToIntDef(Piece(LoadData[i], '^', 7), 0);
581               LabCanCollect   := AnIndex = LabCollSamp;
582               SampReqComment  := Piece(LoadData[i], '^', 9);
583               WardComment     := TStringList.Create;
584               if CollSampID  = StrToIntDef(LRFSAMP, 0) then
585                 CollSamp := CollSampID
586               else if AnIndex = DfltCollSamp then
587                 CollSamp := CollSampID;
588             end; {with}
589           LastListItem := CollSampList.Add(ACollSamp);
590         end; {if}
591       if (LoadData[i][1] = 't') then
592         TCollSamp(CollSampList.Items[LastListItem]).WardComment.Add(Copy(LoadData[i], 2, 255));
593       Inc(i);
594     until (i = LoadData.Count) or (LoadData[i][1] = '~');
595   end;
596   
597   procedure TLabTest.SetCollSampDflts;
598   var
599     tmpResp: TResponse;
600   begin
601     Specimen := 0;
602     Comment.Clear;
603     CurReqComment := TestReqComment;
604     if CollSamp = 0 then Exit;
605     with QuickOrderResponses do tmpResp := FindResponseByName('SPECIMEN'  ,1);
606     if (LRFSPEC <> '') and (tmpResp = nil) then
607       ChangeSpecimen(LRFSPEC)
608     else with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
609       begin
610         Specimen := SpecimenID;
611         if SampReqcomment <> '' then CurReqComment := SampReqComment;
612       end;
613   end;
614   
615   procedure TLabTest.ChangeCollSamp(CollSampIEN: Integer);
616   begin
617     CollSamp := CollSampIEN;
618     SetCollSampDflts;
619   end;
620   
621   procedure TLabTest.ChangeSpecimen(const SpecimenIEN: string);
622   begin
623     Specimen := StrToIntDef(SpecimenIEN,0);
624   end;
625   
626   procedure TLabTest.ChangeUrgency(const UrgencyIEN: string);
627   begin
628     Urgency := StrToIntDef(UrgencyIEN,0);
629   end;
630   
631   procedure TLabTest.ChangeComment(const CommentText: string);
632   begin
633     Comment.Add(CommentText);
634   end;
635   
636   function TLabTest.LabCanCollect: Boolean;
637   var
638     i: Integer;
639   begin
640     Result := False;
641     i := IndexOfCollSamp(CollSamp);
642     if i > -1 then with TCollSamp(CollSampList.Items[i]) do Result := LabCanCollect;
643   end;
644   
645   procedure TLabTest.LoadCollSamp(AComboBox: TORComboBox);
646   { loads the collection sample combo box, expects CollSamp to already be set to default }
647   var
648     i: Integer;
649     x: string;
650   begin
651     AComboBox.Clear;
652     with CollSampList do for i := 0 to Count - 1 do with TCollSamp(Items[i]) do
653     begin
654       x := IntToStr(CollSampID) + '^' + CollSampName;
655       if Length(TubeColor) <> 0 then x := x + ' (' + TubeColor + ')';
656       AComboBox.Items.Add(x);
657       if CollSamp = CollSampID then AComboBox.ItemIndex := i;
658     end;
659     if ((ALabTest.LabSubscript = 'CH') and (not UserHasLRLABKey)) then
660       begin
661         // do not add 'Other'   (coded this way for clarity)
662       end
663     else
664       with AComboBox do
665         begin
666           Items.Add('0^Other...');
667           if ItemIndex < 0 then ItemIndex := Items.IndexOf('Other...');
668         end;
669   end;
670   
671   procedure TLabTest.LoadSpecimen(AComboBox: TORComboBox);
672   { loads specimen combo box, if SpecimenList is empty, use 'E' xref on 61 ?? }
673   var
674     i: Integer;
675     tmpResp: TResponse;
676   begin
677     AComboBox.Clear;
678     if ObtainSpecimen then
679       begin
680         if SpecimenList.Count = 0 then LoadSpecimens(SpecimenList) ;
681         FastAssign(SpecimenList, AComboBox.Items);
682         AComboBox.Items.Add('0^Other...');
683         with QuickOrderResponses do tmpResp := FindResponseByName('SPECIMEN'  ,1);
684         if (LRFSPEC <> '') and (tmpResp = nil) then
685           AComboBox.SelectByID(LRFSPEC)
686         else if Specimen > 0 then
687           AComboBox.SelectByIEN(Specimen)
688         else
689           AComboBox.ItemIndex := AComboBox.Items.IndexOf('Other...');
690       end
691     else
692       begin
693         i := IndexOfCollSamp(CollSamp);
694         if i < CollSampList.Count then with TCollSamp(CollSampList.Items[i]) do
695           begin
696             AComboBox.Items.Add(IntToStr(SpecimenID) + '^' + SpecimenName);
697             AComboBox.ItemIndex := 0;
698           end;
699         with QuickOrderResponses do tmpResp := FindResponseByName('SPECIMEN'  ,1);
700         if (LRFSPEC <> '') and (tmpResp = nil) then
701           begin
702             AComboBox.Items.Add(GetOneSpecimen(StrToInt(LRFSPEC)));
703             AComboBox.SelectByID(LRFSPEC);
704           end;
705       end;
706     ChangeSpecimen(AComboBox.ItemID);
707   end;
708   
709   procedure TfrmODLab.LoadCollType(AComboBox:TORComboBox);
710   var
711     i: integer;
712   begin
713     with CtrlInits, cboCollType do
714       begin
715         SetControl(cboCollType, 'Collection Types');
716         if not ALabTest.LabCanCollect then
717           begin
718             i := SelectByID('LC');
719             if i > -1 then Items.Delete(i);
720             i := SelectByID('I');
721             if i > -1 then Items.Delete(i);
722           end ;
723         if LRFZX <> '' then
724           begin
725             if (LRFZX = 'LC') or (LRFZX = 'I') then
726               begin
727                 if ALabTest.LabCanCollect then
728                   cboCollType.SelectByID(LRFZX)
729                 else
730                   cboCollType.SelectByID('WC');
731               end
732             else
733               cboCollType.SelectByID(LRFZX);
734           end
735         else if FLastCollType <> '' then
736           begin
737             if (FLastCollType = 'LC') or (FLastCollType = 'I') then
738               begin
739                 if ALabTest.LabCanCollect then
740                   cboCollType.SelectByID(FLastCollType)
741                 else
742                   cboCollType.SelectByID('WC');
743               end
744             else
745               cboCollType.SelectByID(FLastCollType);
746           end
747         else if uDfltCollType <> '' then
748           begin
749             if (uDfltCollType = 'LC') or (uDfltCollType = 'I') then
750               begin
751                 if ALabTest.LabCanCollect then
752                   cboCollType.SelectByID(uDfltCollType)
753                 else
754                   cboCollType.SelectByID('WC');
755               end
756             else
757               cboCollType.SelectByID(uDfltCollType);
758           end
759         else if OrderForInpatient then
760           begin
761             if ALabTest.LabCanCollect then
762               cboCollType.SelectByID('LC')
763             else
764               SelectByID('WC');
765           end
766         else
767           cboCollType.SelectByID('SP');
768       end;
769     SetupCollTimes(cboCollType.ItemID);
770   end;
771   
772   procedure TLabTest.LoadUrgency(CollType: string; AComboBox:TORComboBox);
773   var
774     i, PreviousSelectionIndex: integer;
775     PreviousSelectionString: String;
776   begin
777     with AComboBox do
778       begin
779       PreviousSelectionIndex := -1;
780       PreviousSelectionString := SelText;
781   
782         Clear;
783         for i := 0 to UrgencyList.Count - 1 do begin
784            if (CollType = 'LC') and (Piece(UrgencyList[i], U, 3) = '') then
785              Continue
786            else
787              Items.Add(UrgencyList[i]);
788            if (PreviousSelectionString <> '') and (PreviousSelectionString = Piece(UrgencyList[i], U, 2)) then
789              PreviousSelectionIndex := i;
790         end;
791   
792         if (LRFURG <> '') and (ALabTest.ObtainUrgency) then
793           SelectByID(LRFURG)
794         else if PreviousSelectionIndex > -1 then
795           ItemIndex := PreviousSelectionIndex
796         else
797           SelectByIEN(uDfltUrgency);
798         Urgency := AComboBox.ItemIEN;
799       end;
800   end;
801   
802   function TLabTest.NameOfCollSamp: string;
803   var
804     i: Integer;
805   begin
806     Result := '';
807     i := IndexOfCollSamp(CollSamp);
808     if i > -1 then with TCollSamp(CollSampList.Items[i]) do Result := CollSampName;
809   end;
810   
811   function TLabTest.NameOfSpecimen: string;
812   var
813     i: Integer;
814   begin
815     Result := '';
816     if CollSamp > 0 then with TCollSamp(CollSampList[IndexOfCollSamp(CollSamp)]) do
817       if (Specimen > 0) and (Specimen = SpecimenID) then Result := SpecimenName;
818     if (Length(Result) = 0) and (Specimen > 0) then with SpecimenList do
819       for i := 0 to Count - 1 do if Specimen = StrToInt(Piece(Strings[i], '^', 1)) then
820       begin
821         Result := Piece(Strings[i], '^', 2);
822         break;
823       end;
824   end;
825   
826   function TLabTest.NameOfUrgency: string;
827   var
828     i: Integer;
829   begin
830     Result := '';
831     with UrgencyList do for i := 0 to Count - 1 do
832     begin
833       if StrToInt(Piece(Strings[i], '^', 1)) = Urgency
834         then Result := Piece(Strings[i], '^', 2);
835       break;
836     end;
837   end;
838   
839   function TLabTest.ObtainCollSamp: Boolean;
840   begin
841     Result := (not UniqueCollSamp);
842   end;
843   
844   function TLabTest.ObtainSpecimen: Boolean;
845   var
846     i: Integer;
847   begin
848     Result := True;
849     i := IndexOfCollSamp(CollSamp);
850     if (i > -1) and (i < CollSampList.Count) then with TCollSamp(CollSampList.Items[i]) do
851       if SpecimenID > 0 then Result := False;
852   end;
853   
854   function TLabTest.ObtainUrgency: Boolean;
855   begin
856     Result := not ForceUrgency;
857   end;
858   
859   function TLabTest.ObtainComment: Boolean;
860   begin
861     Result := Length(CurReqComment) > 0;
862   end;
863   
864   { end of TLabTest object }
865   
866   procedure TfrmODLab.ControlChange(Sender: TObject);
867   var
868     AResponse: TResponse;
869     AVisitStr: string;
870   begin
871     inherited;
872     if Changing or (ALabTest = nil) then Exit;
873     AResponse := Responses.FindResponseByName('VISITSTR', 1);
874     if AResponse <> nil then
875       AVisitStr := AResponse.EValue;
876     Responses.Clear;
877     with ALabTest do
878     begin
879       if TestID > 0 then Responses.Update('ORDERABLE', 1, IntToStr(TestID), TestName);
880       if CollSamp > 0 then Responses.Update('SAMPLE', 1, IntToStr(CollSamp), NameOfCollSamp)
881         else Responses.Update('SAMPLE', 1, '', '');
882       if Specimen > 0 then Responses.Update('SPECIMEN', 1, IntToStr(Specimen), NameOfSpecimen)
883         else Responses.Update('SPECIMEN', 1, '', '');
884       if Urgency > 0 then Responses.Update('URGENCY', 1, IntToStr(Urgency), NameOfUrgency);
885       if Length(Comment.Text) > 0 then Responses.Update('COMMENT', 1, TX_WPTYPE, Comment.Text);
886       with cboCollType do if Length(ItemID) > 0 then
887         begin
888           Responses.Update('COLLECT', 1, ItemID, ItemID) ;
889           FLastCollType := ItemID;
890         end;
891     end;
892     if cboCollType.ItemID = 'LC' then
893       begin
894         with cboCollTime do
895           if Length(ItemID) > 0 then
896             begin
897               Responses.Update('START', 1, Copy(ItemID, 2, 999), Copy(ItemID, 2, 999));
898               FLastLabCollTime := ItemID + U + Text;
899             end
900           else if Length(Text) > 0 then
901             begin
902               Responses.Update('START', 1, ValidCollTime(Text), Text) ;
903               FLastLabCollTime := ValidCollTime(Text);
904             end;
905       end
906     else
907       begin
908         with calCollTime do
909           if FMDateTime > 0 then
910             begin
911               Responses.Update('START', 1, ValidCollTime(Text), Text);
912               FLastColltime := ValidCollTime(Text);
913             end
914           else
915             begin
916               Responses.Update('START', 1, '', '') ;
917               FLastCollTime := '';
918             end;
919       end;
920     with cboFrequency do if Length(ItemID) > 0
921       then Responses.Update('SCHEDULE', 1, ItemID, Text);
922     with txtDays do if Enabled then Responses.Update('DAYS', 1, Text, Text);
923     { worry about stop date later }
924     if AVisitStr <> '' then Responses.Update('VISITSTR', 1, AVisitStr, AVisitStr);
925     memOrder.Text := Responses.OrderText;
926   end;
927   
928   procedure TfrmODLab.Validate(var AnErrMsg: string);
929   
930     procedure SetError(const x: string);
931     begin
932       if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
933       AnErrMsg := AnErrMsg + x;
934     end;
935   
936   var
937     CmtType,DaysofFuturePast, y: integer;
938     (*Hours, *)DayMax, (*Daily, *)NoOfTimes, (*DayFreq,*) Minutes: integer;
939     d1, d2: TDateTime;
940     Days, MsgTxt: Double;
941     x: string;
942     ACollType: string;
943   const
944     TX_NO_TIME        = 'Collection Time is required.' ;
945     TX_NO_TCOLLTYPE   = 'Collection Type is required.' ;
946     TX_NO_TESTS       = 'A Lab Test or tests must be selected.' ;
947     TX_BAD_TIME       = 'Collection times must be chosen from the drop down list or entered as valid' +
948                         ' Fileman date/times (T@1700, T+1@0800, etc.).' ;
949     TX_PAST_TIME      = 'Collection times in the past are not allowed.';
950     TX_NO_DAYS        = 'A number of days must be entered for continuous orders.';
951     TX_NO_TIMES       = 'A number of times must be entered for continuous orders.';
952     TX_NO_STOP_DATE   = 'Could not calculate the stop date for the order.  Check "for n Days".';
953     TX_TOO_MANY_DAYS  = 'Maximum number of days allowed is ';
954     TX_TOO_MANY_TIMES = 'For this frequency, the maximum number of times allowed is:  X';
955     //TX_NO_COMMENT     = 'A comment is required for this test and collection sample.';
956     TX_NUMERIC_REQD   = 'A numeric value is required for urine volume.';
957     TX_DOSEDRAW_REQD  = 'Both DOSE and DRAW times are required for this order.';
958     TX_TDM_REQD       = 'A value for LEVEL is required for this order.';
959     //TX_ANTICOAG_REQD  = 'You must specify an anticoagulant on this order.' ;
960     TX_NO_COLLSAMPLE  = 'A collection sample MUST be specified.';
961     TX_NO_SPECIMEN    = 'A specimen MUST be specified.';
962     TX_NO_URGENCY     = 'An urgency MUST be specified.';
963     TX_NO_FREQUENCY   = 'A collection frequency MUST be specified.';
964     TX_NOT_LAB_COLL_TIME = ' is not a routine lab collection time.';
965     TX_NO_ALPHA       = 'For continuous orders, enter a number of days, or an "X" followed by a number of times.';
966     TX_BADTIME_CAP    = 'Invalid Immediate Collect Time';
967   
968   begin
969     inherited;
970     { need to go thru list and make sure everything is filled in }
971     with cboAvailTest do if ItemIEN <= 0 then SetError(TX_NO_TESTS);
972   
973     if ALabTest <> nil then
974       if (cboCollType.ItemID = 'I') and (not ALabTest.LabCanCollect) then
975         begin
976           SetError(TX_NO_IMMED);
977           cboCollType.ItemIndex := -1;
978         end;
979   
980     if cboCollType.ItemID = '' then
981       SetError(TX_NO_TCOLLTYPE)
982     else if cboCollType.ItemID = 'LC' then
983      begin
984        if Length(cboCollTime.Text) = 0 then SetError(TX_NO_TIME);
985        with cboCollTime do if (Length(Text) > 0) and (ItemIndex = -1) then
986          begin
987            if StrToFMDateTime(Text) < 0 then
988              SetError(TX_BAD_TIME)
989            else if StrToFMDateTime(Text) < FMNow then
990              SetError(TX_PAST_TIME)
991            else if OrderForInpatient then
992              begin
993                d1 := FMDateTimeToDateTime(Trunc(StrToFMDateTime(cboColltime.Text)));
994                d2 := FMDateTimeToDateTime(FMToday);
995                if EvtDelayLoc > 0 then
996                  DaysofFuturePast := LabCollectFutureDays(EvtDelayLoc,EvtDivision)
997                else
998                  DaysofFuturePast := LabCollectFutureDays(Encounter.Location);
999                if DaysofFuturePast = 0 then DaysofFuturePast := 7;
1000               if ((d1 - d2) > DaysofFuturePast) then
1001                 SetError('A lab collection cannot be ordered more than '
1002                   + IntToStr(DaysofFuturePast) + ' days in advance');
1003             end
1004           else if EvtDelayLoc > 0 then
1005             begin
1006               if (not IsLabCollectTime(StrToFMDateTime(cboCollTime.Text), EvtDelayLoc)) then
1007                 SetError(cboCollTime.Text + TX_NOT_LAB_COLL_TIME);
1008             end
1009           else if EvtDelayLoc <= 0 then
1010             begin
1011               if (not IsLabCollectTime(StrToFMDateTime(cboCollTime.Text), Encounter.Location)) then
1012                 SetError(cboCollTime.Text + TX_NOT_LAB_COLL_TIME);
1013             end;
1014         end;
1015     end
1016    else
1017      begin
1018        if cboCollType.ItemID = 'I' then
1019          begin
1020            calCollTime.Text := txtImmedColl.Text;
1021            x := ValidImmCollTime(calCollTime.FMDateTime);
1022            if (Piece(x, U, 1) <> '1') then
1023              SetError(Piece(x, U, 2));
1024          end;
1025  
1026        with calColltime do
1027          begin
1028            if FMDateTime = 0 then SetError(TX_BAD_TIME)
1029            else
1030              begin
1031                // date only was entered
1032                if (FMDateTime - Trunc(FMDateTime) = 0) then
1033                  begin
1034                    if (Trunc(FMDateTime) < FMToday) then SetError(TX_PAST_TIME);
1035                  end
1036                // date/time was entered
1037                else
1038                  begin
1039                    if (UpperCase(Text) <> 'NOW') and (FMDateTime < FMNow) then SetError(TX_PAST_TIME);
1040                  end;
1041              end;
1042          end;
1043      end;
1044  
1045    with cboCollSamp  do
1046      if ItemIndex < 0 then
1047        SetError(TX_NO_COLLSAMPLE)
1048      else if (ItemIndex >= 0) and (ItemIEN = 0) then
1049        begin
1050          if ALabTest <> nil then
1051            GetAllCollSamples(cboCollSamp);
1052          if ItemIEN = 0 then SetError(TX_NO_COLLSAMPLE);
1053        end;
1054  
1055    with cboSpecimen  do
1056      if ItemIndex < 0 then
1057        SetError(TX_NO_SPECIMEN)
1058      else if (ItemIndex >= 0) and (ItemIEN = 0) then
1059        begin
1060          if (ALabTest <> nil) and (cboCollSamp.ItemIEN > 0) then
1061            GetAllSpecimens(cboSpecimen);
1062          if ItemIEN = 0 then SetError(TX_NO_SPECIMEN);
1063        end;
1064        
1065    If ALabTest.Urgency <= 0 then begin
1066      with ALabTest do
1067      ChangeUrgency(cboUrgency.ItemID);
1068     ControlChange(Self);
1069    end;
1070  
1071    with cboUrgency   do if ItemIEN  <= 0 then SetError(TX_NO_URGENCY);
1072    with cboFrequency do if ItemIEN  <= 0 then SetError(TX_NO_FREQUENCY);
1073  
1074    if ALabTest <> nil then
1075      begin
1076        CmtType := FCmtTypes.IndexOf(ALabTest.CurReqComment) ;
1077        with ALabTest do
1078        case CmtType of
1079          0 : {ANTICOAGULATION}         {if (Pos('ANTICOAGULANT',Comment.Text)=0) then
1080                                       SetError(TX_ANTICOAG_REQD)};
1081          1 : {DOSE/DRAW TIMES}         if (Pos('Last dose:',Comment.Text)=0) or
1082                                        (Pos('draw time:',Comment.Text)=0) then
1083                                       SetError(TX_DOSEDRAW_REQD);
1084          2 : {ORDER COMMENT}           {if (Length(Comment.Text)=0) then
1085                                       SetError(TX_NO_COMMENT)};
1086          3 : {ORDER COMMENT MODIFIED}  {if (Length(Comment.Text)=0) then
1087                                       SetError(TX_NO_COMMENT)};
1088          4 : {TDM (PEAK-TROUGH}        if (Pos('Dose is expected',Comment.Text)=0) then
1089                                       SetError(TX_TDM_REQD);
1090          5 : {TRANSFUSION}             {if (Length(Comment.Text)=0) then
1091                                       SetError(TX_NO_COMMENT)};
1092          6 : {URINE VOLUME}            if (Length(Comment.Text)>0) and
1093                                     (ExtractInteger(Comment.Text)<=0) then
1094                                        Comment.Text := '?';
1095                                       {SetError(TX_NUMERIC_REQD);}
1096          {   else
1097                if (Length(CurReqComment)>0) and (Length(Comment.Text)=0) then
1098                  SetError(TX_NO_COMMENT); }
1099        end;
1100      end;
1101  
1102    with txtDays do if Enabled then
1103      begin
1104        DayMax := 0;
1105        if (cboCollType.ItemID = 'LC') or (cboCollType.ItemID = 'I') then
1106        begin
1107          if EvtDelayLoc > 0 then
1108            DayMax := LabCollectFutureDays(EvtDelayLoc,EvtDivision)
1109          else
1110            DayMax := LabCollectFutureDays(Encounter.Location);
1111        end;
1112        if DayMax = 0 then
1113        begin
1114           if EvtDelayLoc > 0 then
1115             DayMax := MaxDays(EvtDelayLoc, cboFrequency.ItemIEN)
1116           else
1117             DayMax := MaxDays(Encounter.Location, cboFrequency.ItemIEN);
1118        end;
1119        x := Piece(cboFrequency.Items[cboFrequency.ItemIndex], U, 3);
1120        if (x = 'C') or (x = 'D') then
1121          begin
1122            Minutes := StrToIntDef(Piece(cboFrequency.Items[cboFrequency.ItemIndex], U, 4), 0);
1123            Days := Minutes / 1440;
1124            if (Days = 0) then Days := 1;
1125            if Pos('X', UpperCase(txtDays.Text)) > 0 then
1126              begin
1127                x := Trim(Copy(txtDays.Text, 1, Pos('X', UpperCase(txtDays.Text)) - 1)) +
1128                     Trim(Copy(txtDays.Text, Pos('X', UpperCase(txtDays.Text)) + 1, 99));
1129                NoOfTimes := ExtractInteger(x);
1130                Days := NoOfTimes * Days;                                      // # days requested
1131                if FloatToStr(NoOfTimes) <> x then
1132                  SetError(TX_NO_ALPHA)
1133                else if NoOfTimes = 0 then
1134                  SetError(TX_NO_TIMES)
1135                else if (Days > DayMax) then
1136                  begin
1137                    MsgTxt := Minutes / 60;
1138                    x := ' hour';
1139                    if MsgTxt > 24 then
1140                      begin
1141                        MsgTxt := MsgTxt / 24;
1142                        x := ' day';
1143                      end;
1144                    if MsgTxt > 1 then x := x + 's';
1145                    y := 0;
1146                    if Minutes > 0 then y := (DayMax * 1440) div Minutes;
1147                    if y = 0 then y := 1;
1148                    //if y > 0 then
1149                      SetError(TX_TOO_MANY_TIMES + IntToStr(y) + CRLF +
1150                        '     (Every ' + FloatToStr(MsgTxt) + x + ' for a maximum of ' + IntToStr(DayMax) + ' days.)')
1151                    //else
1152                    //  Responses.Update('DAYS', 1, 'X1', 'X1');
1153                  end
1154                else
1155                  begin
1156                    x := 'X' + IntToStr(NoOfTimes);
1157                    Responses.Update('DAYS', 1, x, x);
1158                  end;
1159              end
1160            else
1161              begin
1162                Days := ExtractInteger(txtDays.Text);
1163                if FloatToStr(Days) <> Trim(txtDays.Text) then
1164                  SetError(TX_NO_ALPHA)
1165                  //SetError(TX_NO_DAYS)    v18.6  (RV)
1166                else if (Days > DayMax) then
1167                  SetError(TX_TOO_MANY_DAYS + IntToStr(DayMax))
1168                else
1169                  Responses.Update('DAYS', 1, txtDays.Text, txtDays.Text);
1170              end;
1171          end;
1172      end;
1173  
1174    if (AnErrMsg <> '') or (Self.EvtID > 0) then exit;
1175      
1176    // add check and display for auto-change from LC to WC - v27.1 - CQ #10226
1177    ACollType := Responses.FindResponseByName('COLLECT', 1).EValue;
1178    if ((ACollType = 'LC') or (ACollType = 'I')) then DisplayChangedOrders(ACollType);
1179  end;
1180  
1181  procedure TfrmODLab.DisplayChangedOrders(ACollType: string);
1182  var
1183    AStartDate, ASchedule, ADuration: string;
1184    ChangedOrdersList, AList: TStringlist;
1185    i, j, k: integer;
1186  begin
1187    ChangedOrdersList := TStringList.Create;
1188    try
1189      AStartDate := Responses.FindResponseByName('START', 1).IValue;
1190      ASchedule  := Responses.FindResponseByName('SCHEDULE', 1).IValue;
1191      if txtDays.Enabled then ADuration := Responses.FindResponseByName('DAYS', 1).EValue else ADuration := '';
1192      CheckForChangeFromLCtoWCOnAccept(ChangedOrdersList, Encounter.Location, AStartDate, ACollType, ASchedule, ADuration);
1193      if ChangedOrdersList.Text <> '' then
1194      begin
1195        AList := TStringList.Create;
1196        try
1197          AList.Text := Responses.OrderText;
1198          with ChangedOrdersList do
1199          begin
1200            Insert(5, 'Order   :' + #9 + AList[0]);
1201            k := Length(ChangedOrdersList[5]);
1202            i := 0;
1203            if AList.Count > 1 then
1204              for j := 1 to AList.Count - 1 do
1205              begin
1206                Insert(5 + j, StringOfChar(' ', 9) + #9 + AList[j]);
1207                k := HigherOf(k, Length(ChangedOrdersList[5 + j]));
1208                i := j;
1209              end;
1210            Insert(5 + i + 1, StringOfChar('-', k + 4));
1211          end;
1212          ReportBox(ChangedOrdersList, 'Changed Orders', TRUE);
1213        finally
1214          AList.Free;
1215        end;
1216      end;
1217    finally
1218      ChangedOrdersList.Free;
1219    end;
1220  end;
1221  
1222  procedure TfrmODLab.cboAvailTestNeedData(Sender: TObject;
1223                const StartFrom: string; Direction, InsertAt: Integer);
1224  begin
1225    cboAvailTest.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.LAB'));
1226  end;
1227  
1228  procedure TfrmODLab.cboAvailTestExit(Sender: TObject);
1229  begin
1230    inherited;
1231    if (Length(cboAvailTest.ItemID) = 0) or (cboAvailTest.ItemID = '0') then Exit;
1232    if cboAvailTest.ItemID = FLastLabID then Exit;
1233    cboAvailTestSelect(cboAvailTest);
1234    cboAvailTest.SetFocus;
1235    PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
1236  end;
1237  
1238  procedure TfrmODLab.cboAvailTestSelect(Sender: TObject);
1239  var
1240    x: string;
1241    i: integer;
1242    tmpResp: TResponse;
1243  begin
1244    with cboAvailTest do
1245      begin
1246        if (Length(ItemID) = 0) or (ItemID = '0') then Exit;
1247        FLastLabID := ItemID ;
1248        FLastItemID := ItemID;
1249        Changing := True;
1250        if Sender <> Self then
1251          Responses.Clear;       // Sender=Self when called from SetupDialog
1252        if CharAt(ItemID, 1) = 'Q' then
1253          with Responses do
1254            begin
1255              FLastItemID := ItemID;
1256              QuickOrder := ExtractInteger(ItemID);
1257              SetControl(cboAvailTest, 'ORDERABLE', 1);
1258              if (Length(ItemID) = 0) or (ItemID = '0') then Exit;
1259              FLastLabID := ItemID;
1260            end;
1261        ALabTest := TLabTest.Create(ItemID, Responses);
1262      end;
1263    with ALabTest do
1264    begin
1265      lblTestName.Caption := TestName;
1266      LoadCollSamp(cboCollSamp);
1267      cboCollSampChange(Self);
1268      LoadSpecimen(cboSpecimen);
1269      LoadUrgency(cboCollType.ItemID, cboUrgency);
1270      with Responses do if QuickOrder > 0 then
1271       begin
1272        StatusText('Initializing Quick Order');
1273        Changing := True;
1274        SetControl(cboAvailTest,       'ORDERABLE', 1);
1275        SetControl(cboFrequency,       'SCHEDULE', 1);
1276        SetControl(txtDays,            'DAYS', 1);
1277        tmpResp := FindResponseByName('SAMPLE'  ,1);
1278        if (tmpResp <> nil) and (tmpResp.IValue <> '') then with cboCollSamp do
1279          begin
1280            SelectByID(tmpResp.IValue);
1281            if ItemIndex < 0 then
1282              begin
1283                LoadAllSamples;
1284                Items.Insert(0, tmpResp.IValue + U + tmpResp.EValue);
1285                ItemIndex := 0  ;
1286              end;
1287          end
1288        else if LRFSAMP <> '' then
1289          cboCollSamp.SelectByID(LRFSAMP);
1290        if (cboCollSamp.ItemIndex < 0) and (cboCollSamp.Items.IndexOf('Other...') >= 0) then cboCollSamp.SelectByID('0');
1291        cboCollSampChange(Self);
1292        DetermineCollectionDefaults(Responses);
1293        LoadUrgency(cboCollType.ItemID, cboUrgency);
1294        SetControl(cboUrgency,         'URGENCY', 1);
1295        Urgency := cboUrgency.ItemIEN;
1296        if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
1297          begin
1298            cboUrgency.ItemIndex := 0;
1299            Urgency := cboUrgency.ItemIEN;
1300          end;
1301        tmpResp := FindResponseByName('SPECIMEN'  ,1);
1302        if (tmpResp <> nil) and (tmpResp.IValue <> '') then with cboSpecimen do
1303          begin
1304            SelectByID(tmpResp.IValue);
1305            if ItemIndex < 0 then
1306              begin
1307                if ALabTest <> nil then
1308                  ALabTest.SpecimenList.Add(tmpResp.IValue + U + tmpResp.EValue);
1309                Items.Insert(0, tmpResp.IValue + U + tmpResp.EValue);
1310                ItemIndex := 0  ;
1311              end;
1312          end
1313        else if LRFSPEC <> '' then
1314          cboSpecimen.SelectByID(LRFSPEC);
1315        if (cboSpecimen.ItemIndex < 0) and (cboSpecimen.Items.IndexOf('Other...') >= 0) then cboSpecimen.SelectByID('0');
1316        Specimen := cboSpecimen.ItemIEN;
1317        i := 1 ;
1318        tmpResp := Responses.FindResponseByName('COMMENT',i);
1319        while tmpResp <> nil do
1320          begin
1321            Comment.Add(tmpResp.EValue);
1322            Inc(i);
1323            tmpResp := Responses.FindResponseByName('COMMENT',i);
1324          end ;
1325        with cboFrequency do
1326          if not Enabled then
1327            begin
1328              ItemIndex := Items.IndexOf('ONE TIME');
1329              if ItemIndex = -1 then ItemIndex := Items.IndexOf('ONCE');
1330            end;
1331        cboFrequencyChange(Self);
1332       end;  //  Quick Order
1333      if ObtainCollSamp then
1334        begin
1335          lblCollSamp.Enabled := True;
1336          cboCollSamp.Enabled := True;
1337          //TDP - CQ#19396 Added cboCollSamp 508 changes
1338          setup508Label(cboCollSamp.Text, collsamplbl508, cboCollSamp, lblCollSamp.Caption);
1339        end
1340      else
1341        begin
1342          with ALabTest do
1343            with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
1344              begin
1345                x := '' ;
1346                for i := 0 to WardComment.Count-1 do
1347                  x := x + WardComment.strings[i]+#13#10 ;
1348                pnlMessage.TabOrder := cboAvailTest.TabOrder + 1;
1349                OrderMessage(x) ;
1350              end ;
1351          lblCollSamp.Enabled := False;
1352          cboCollSamp.Enabled := False;
1353          //TDP - CQ#19396 Added cboCollSamp 508 changes
1354          setup508Label(cboCollSamp.Text, collsamplbl508, cboCollSamp, lblCollSamp.Caption);
1355        end;
1356      if ObtainSpecimen then
1357      begin
1358        lblSpecimen.Enabled:= True;
1359        cboSpecimen.Enabled:= True;
1360        setup508Label(cboSpecimen.Text, specimenlbl508, cboSpecimen, lblSpecimen.Caption);
1361      end else
1362      begin
1363        lblSpecimen.Enabled:= False;
1364        cboSpecimen.Enabled:= False;
1365        setup508Label(cboSpecimen.Text, specimenlbl508, cboSpecimen, lblSpecimen.Caption);
1366      end;
1367      if ObtainUrgency then
1368      begin
1369        lblUrgency.Enabled := True;
1370        cboUrgency.Enabled := True;
1371      end else
1372      begin
1373        lblUrgency.Enabled := False;
1374        cboUrgency.Enabled := False;
1375      end;
1376      if ObtainComment then
1377        LoadRequiredComment(FCmtTypes.IndexOf(CurReqComment))
1378      else
1379        DisableCommentPanels;
1380      x := '' ;
1381      for i := 0 to CurWardComment.Count-1 do
1382        x := x + CurWardComment.strings[i]+#13#10 ;
1383      i :=  IndexOfCollSamp(CollSamp);
1384      if i > -1 then with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
1385         for i := 0 to WardComment.Count-1 do
1386           x := x + WardComment.strings[i]+#13#10 ;
1387      pnlMessage.TabOrder := cboAvailTest.TabOrder + 1;
1388      OrderMessage(x) ;
1389     end; { with }
1390    StatusText('');
1391    Changing := False;
1392    if Sender <> Self then ControlChange(Self);
1393  end;
1394  
1395  procedure TfrmODLab.cboCollSampChange(Sender: TObject);
1396  var
1397    i: integer;
1398    x: string;
1399  begin
1400    if (ALabTest = nil) or (cboCollSamp.ItemIEN = 0) then exit;
1401    with ALabTest do
1402    begin
1403      ChangeCollSamp(cboCollSamp.ItemIEN);
1404      LoadSpecimen(cboSpecimen);
1405      LoadCollType(cbocollType);
1406      LoadUrgency(cboCollType.ItemID, cboUrgency);
1407      if ObtainSpecimen then
1408       begin
1409        lblSpecimen.Enabled:= True;
1410        cboSpecimen.Enabled:= True;
1411        setup508Label(cboSpecimen.Text, specimenlbl508, cboSpecimen, lblSpecimen.Caption);
1412       end else
1413       begin
1414        lblSpecimen.Enabled:= False;
1415        cboSpecimen.Enabled:= False;
1416        setup508Label(cboSpecimen.Text, specimenlbl508, cboSpecimen, lblSpecimen.Caption);
1417       end;
1418      if ObtainComment then
1419         LoadRequiredComment(FCmtTypes.IndexOf(CurReqComment))
1420      else
1421         DisableCommentPanels;
1422      if not Changing then with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
1423        begin
1424            x := '' ;
1425            for i := 0 to WardComment.Count-1 do
1426              x := x + WardComment.strings[i]+#13#10 ;
1427            pnlMessage.TabOrder := cboCollSamp.TabOrder + 1;
1428            OrderMessage(x) ;
1429        end ;
1430    end;
1431    ControlChange(Self);
1432  end;
1433  
1434  procedure TfrmODLab.cboUrgencyChange(Sender: TObject);
1435  begin
1436    if ALabTest = nil then exit;
1437    with ALabTest do
1438      ChangeUrgency(cboUrgency.ItemID);
1439    ControlChange(Self);
1440  end;
1441  
1442  procedure TfrmODLab.cboSpecimenChange(Sender: TObject);
1443  begin
1444    if ALabTest = nil then exit;
1445    with cboSpecimen do if Text = 'Other...' then
1446      if (ItemIndex >= 0) and (ItemIEN = 0) then
1447        GetAllSpecimens(cboSpecimen);
1448    with ALabTest do
1449      ChangeSpecimen(cboSpecimen.ItemID);
1450    ControlChange(Self);
1451  end;
1452  
1453  procedure TfrmODLab.cboCollTimeChange(Sender: TObject);
1454  var
1455    CollType: string;
1456  const
1457    TX_BAD_TIME         = ' is not a routine lab collection time.' ;
1458    TX_BAD_TIME_CAP     = 'Invalid Time';
1459  begin
1460    CollType := 'LC';
1461    with cboCollTime do if ItemID = 'LO' then
1462      begin
1463        ItemIndex := -1;
1464        Text := GetFutureLabTime(FMToday);
1465      end;
1466    //cboCollType.SelectByID(CollType);
1467    ControlChange(Self);
1468  end;
1469  
1470  procedure TfrmODLab.cboFrequencyChange(Sender: TObject);
1471  var
1472    x, HowManyText: string;
1473  const
1474    HINT_TEXT1 = 'Enter a number of days';
1475    HINT_TEXT2 = ', or an "X" followed by a number of times.';
1476  begin
1477    with cboFrequency do if ItemIndex > -1 then x := Items[ItemIndex];
1478    with cboFrequency do
1479      if (ItemIndex > -1) and (Piece(Items[ItemIndex], U, 3) <> 'O') then
1480        begin
1481          lblHowManyDays.Enabled := True;
1482          if Piece(Items[ItemIndex], U, 3) = 'C' then
1483            txtDays.Hint := HINT_TEXT1 + HINT_TEXT2
1484          else
1485            txtDays.Hint := '';
1486          txtDays.Enabled := True;
1487          //TDP - txtDays 508 changes
1488          if txtDays.Text = '' then HowManyText := 'no value'
1489          else HowManyText := txtDays.Text;
1490          setup508Label(HowManyText, HowManyDayslbl508, txtDays, lblHowManyDays.Caption);
1491          txtDays.Showhint := True;
1492        end
1493      else
1494        begin
1495          txtDays.Text := '';
1496          lblHowManyDays.Enabled := False;
1497          txtDays.Enabled := False;
1498          //TDP - txtDays 508 changes
1499          HowManyText := 'no value';
1500          setup508Label(HowManyText, HowManyDayslbl508, txtDays, lblHowManyDays.Caption);
1501          txtDays.ShowHint := False;
1502        end;
1503    ControlChange(Self);
1504  end;
1505  
1506  procedure TfrmODLab.cboCollTypeChange(Sender: TObject);
1507  begin
1508    if (ALabTest = nil) or Changing or (cboCollType.ItemID = '') then exit;
1509    if (cboCollType.ItemID = 'I') and (not ALabTest.LabCanCollect) then
1510      begin
1511        InfoBox(TX_NO_IMMED, TX_NO_IMMED_CAP, MB_OK or MB_ICONWARNING);
1512        cboCollType.ItemIndex := -1;
1513        Exit;
1514      end;
1515    SetupCollTimes(cboCollType.ItemID);
1516    ALabTest.LoadUrgency(cboCollType.ItemID, cboUrgency);
1517    ControlChange(Self);
1518  end;
1519  
1520  procedure TfrmODLab.SetupCollTimes(CollType: string);
1521  var
1522    tmpImmTime, tmpTime: TFMDateTime;
1523    x, tmpORECALLType, tmpORECALLTime: string;
1524  begin
1525    x := GetLastCollectionTime;
1526    tmpORECALLType := Piece(x, U, 1);
1527    tmpORECALLTime := Piece(x, U, 2);
1528    if CollType = 'SP' then
1529      begin
1530        cboColltime.Visible    := False;
1531        txtImmedColl.Visible   := False;
1532        pnlCollTimeButton.Visible   := False;
1533        pnlCollTimeButton.TabStop := False;
1534        calCollTime.Visible    := True;
1535        calColltime.Enabled    := True;
1536        if FLastCollTime <> '' then
1537          begin
1538            calCollTime.Text := ValidCollTime(FLastColltime);
1539            if IsFMDateTime(calCollTime.Text) then
1540              begin
1541                calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
1542                calColltime.FMDateTime := StrToFMDateTime(FLastCollTime);
1543              end;
1544          end
1545        else if tmpORECALLTime <> '' then
1546          begin
1547            calCollTime.Text := ValidCollTime(tmpORECALLTime);
1548            if IsFMDateTime(calCollTime.Text) then
1549              begin
1550                calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
1551                calColltime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
1552              end;
1553          end
1554        else if LRFDATE <> '' then
1555          calCollTime.Text     := LRFDATE
1556        else
1557          calCollTime.Text     := 'TODAY';
1558      end
1559    else if CollType = 'WC' then
1560      begin
1561        cboColltime.Visible    := False;
1562        txtImmedColl.Visible   := False;
1563        pnlCollTimeButton.Visible   := False;
1564        pnlCollTimeButton.TabStop := False;
1565        calCollTime.Visible    := True;
1566        calColltime.Enabled    := True;
1567        if FLastCollTime <> '' then
1568          begin
1569            calCollTime.Text := ValidCollTime(FLastColltime);
1570            if IsFMDateTime(calCollTime.Text) then
1571              begin
1572                calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
1573                calColltime.FMDateTime := StrToFMDateTime(FLastCollTime);
1574              end;
1575          end
1576        else if tmpORECALLTime <> '' then
1577          begin
1578            calCollTime.Text := ValidCollTime(tmpORECALLTime);
1579            if IsFMDateTime(calCollTime.Text) then
1580              begin
1581                calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
1582                calColltime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
1583              end;
1584          end
1585        else if LRFDATE <> '' then
1586          calCollTime.Text     := LRFDATE
1587        else
1588          calCollTime.Text     := 'NOW';
1589      end
1590    else if CollType = 'LC' then
1591      begin
1592        cboColltime.Visible    := True;
1593        calCollTime.Visible    := False;
1594        calColltime.Enabled    := False;
1595        txtImmedColl.Visible   := False;
1596        pnlCollTimeButton.Visible   := False;
1597        pnlCollTimeButton.TabStop := False;
1598        with CtrlInits do SetControl(cboCollTime, 'Lab Collection Times');
1599        if Pos(U, FLastLabCollTime) > 0 then
1600          cboColltime.SelectByID(Piece(FLastLabCollTime, U, 1))
1601        else if FLastLabCollTime <> '' then
1602          cboCollTime.Text     := FLastLabCollTime
1603        else if (tmpORECALLTime <> '') and (tmpORECALLType = 'LC') then
1604          cboCollTime.Text     := MakeRelativeDateTime(StrToFMDateTime(tmpORECALLTime))
1605        else if LRFDATE <> '' then
1606          cboCollTime.Text     := LRFDATE
1607        else
1608          cboCollTime.ItemIndex := 0;
1609      end
1610    else if CollType = 'I' then
1611      begin
1612        cboColltime.Visible    := False;
1613        calCollTime.Visible    := False;
1614        calColltime.Enabled    := False;
1615        txtImmedColl.Visible   := True;
1616        pnlCollTimeButton.Visible   := True;
1617        pnlCollTimeButton.TabStop := True;
1618        tmpImmTime := GetDefaultImmCollTime;
1619        tmpTime := 0;
1620        if (FLastColltime <> '') then
1621          tmpTime := StrToFMDateTime(FLastColltime)
1622        else if (tmpORECALLTime <> '') then
1623          tmpTime := StrToFMDateTime(tmpORECALLTime)
1624        else if LRFDATE <> '' then
1625          tmpTime := StrToFMDateTime(LRFDATE);
1626  
1627        if tmpTime > tmpImmTime then
1628          begin
1629            calCollTime.FMDateTime := tmpTime;
1630            txtImmedColl.Text      := FormatFMDateTime('mmm dd,yy@hh:nn', tmpTime);
1631          end
1632        else
1633          begin
1634            calCollTime.FMDateTime := GetDefaultImmCollTime;
1635            txtImmedColl.Text      := FormatFMDateTime('mmm dd,yy@hh:nn', calCollTime.FMDateTime);
1636          end;
1637      end;
1638  end;
1639  
1640  procedure TfrmODLab.FormClose(Sender: TObject; var Action: TCloseAction);
1641  begin
1642    inherited;
1643    if FCmtTypes <> nil then FCmtTypes.Free;
1644    frmFrame.pnlVisit.Enabled := true;
1645  end;
1646  
1647  procedure TfrmODLab.LoadRequiredComment(CmtType: integer);
1648  begin
1649    DisableCommentPanels;
1650    pnlHide.SendToBack;
1651    lblReqComment.Visible := True ;
1652    case CmtType of
1653       0 : {ANTICOAGULATION}         pnlAntiCoagulation.Show ;
1654       1 : {DOSE/DRAW TIMES}         pnlDoseDraw.Show ;
1655       2 : {ORDER COMMENT}           pnlOrderComment.Show ;
1656       3 : {ORDER COMMENT MODIFIED}  pnlOrderComment.Show ; // DIFFERENT ???
1657       4 : {TDM (PEAK-TROUGH}        begin
1658                                       pnlPeakTrough.Show ;
1659                                       grpPeakTrough.ItemIndex := -1;
1660                                       txtAddlComment.Show;
1661                                       lblAddlComment.Show;
1662                                     end;
1663       5 : {TRANSFUSION}             pnlOrderComment.Show ;
1664       6 : {URINE VOLUME}            pnlUrineVolume.Show ;
1665     else
1666       pnlOrderComment.Show ;
1667     end;
1668  end;
1669  
1670  procedure TfrmODLab.txtOrderCommentExit(Sender: TObject);
1671  begin
1672    inherited;
1673    if (not pnlOrderComment.Visible) or (ALabTest = nil) then exit;
1674    with ALabTest do
1675        if Length(txtOrderComment.Text)>0 then
1676         begin
1677          Comment.Clear;
1678          ChangeComment('~For Test: ' + TestName);
1679          ChangeComment('~' + txtOrderComment.Text) ;
1680         end
1681        else
1682          Comment.Clear;
1683    ControlChange(Self);
1684  end;
1685  
1686  procedure TfrmODLab.txtAntiCoagulantExit(Sender: TObject);
1687  begin
1688    inherited;
1689    if (not pnlAntiCoagulation.Visible) or (ALabTest = nil) then exit;
1690    with ALabTest do
1691        if Length(txtAntiCoagulant.Text)>0 then
1692         begin
1693          Comment.Clear;
1694          ChangeComment('~For Test: ' + TestName);
1695          ChangeComment('~ANTICOAGULANT: ' + txtAntiCoagulant.Text);
1696         end
1697        else
1698          Comment.Clear;
1699    ControlChange(Self);
1700  end;
1701  
1702  procedure TfrmODLab.txtUrineVolumeExit(Sender: TObject);
1703  begin
1704    inherited;
1705    if (not pnlUrineVolume.Visible) or (ALabTest = nil) then exit;
1706    with ALabTest do
1707     begin
1708      Comment.Clear;
1709      ChangeComment(txtUrineVolume.Text) ;
1710     end;
1711    ControlChange(Self);
1712  end;
1713  
1714  procedure TfrmODLab.grpPeakTroughClick(Sender: TObject);
1715  begin
1716    inherited;
1717    if (not pnlPeakTrough.Visible) or (ALabTest = nil) then exit;
1718    with ALabTest,grpPeakTrough do
1719      if ItemIndex > -1 then
1720        begin
1721          Comment.Clear;
1722          ChangeComment('~For Test: ' + TestName);
1723          ChangeComment('~Dose is expected to be at ' + UpperCase(Items[ItemIndex]) + ' level.');
1724          ChangeComment(txtAddlComment.Text) ;
1725        end
1726      else
1727        Comment.Clear;
1728    ControlChange(Self);
1729  end;
1730  
1731  procedure TfrmODLab.txtDoseTimeExit(Sender: TObject);
1732  begin
1733    inherited;
1734    if (not pnlDoseDraw.Visible) or (ALabTest = nil) then exit;
1735    with txtDoseTime do
1736      if Length(Text)>0 then
1737        Text := FormatFMDateTime('mm/dd/yy hh:nn', StrToFMDateTime(Text))
1738      else
1739        Text := 'UNKNOWN';
1740    DoseDrawComment;
1741    ControlChange(Self);
1742  end;
1743  
1744  procedure TfrmODLab.txtDrawTimeExit(Sender: TObject);
1745  begin
1746    inherited;
1747    if (not pnlDoseDraw.Visible) or (ALabTest = nil) then exit;
1748    with txtDrawTime do
1749      if Length(Text)>0 then
1750        Text := FormatFMDateTime('mm/dd/yy hh:nn', StrToFMDateTime(Text))
1751      else
1752        Text := 'UNKNOWN';
1753    DoseDrawComment;
1754    ControlChange(Self);
1755  end;
1756  
1757  procedure TfrmODLab.DoseDrawComment;
1758  begin
1759    if ALabTest = nil then exit;
1760    with ALabTest do
1761     begin
1762       Comment.Clear;
1763       ChangeComment('~For Test: ' + TestName);
1764       ChangeComment('~Last dose: ' + txtDoseTime.Text +
1765                     '   draw time: '+txtDrawTime.Text);
1766     end;
1767  end;
1768  
1769  procedure TfrmODLab.txtAddlCommentExit(Sender: TObject);
1770  begin
1771    if (not pnlPeakTrough.Visible) or (ALabTest = nil) then exit;
1772    grpPeakTroughClick(Sender);
1773  end;
1774  
1775  procedure TfrmODLab.DisableCommentPanels;
1776  begin
1777    pnlHide.BringToFront;
1778    lblReqComment.Visible := False;
1779    pnlAntiCoagulation.Visible := False;
1780    pnlOrderComment.Visible := False;
1781    pnlDoseDraw.Visible := False;
1782    pnlPeakTrough.Visible := False;
1783    pnlUrineVolume.Visible := False;
1784    lblAddlComment.Visible := False;
1785    txtAddlComment.Visible := False;
1786    //pnlTransfusion.Visible := False;
1787  end;
1788  
1789  procedure TfrmODLab.cboCollSampKeyPause(Sender: TObject);
1790  begin
1791    inherited;
1792    if ALabTest = nil then exit;
1793    with cboCollSamp do
1794      if (ItemIndex >= 0) and (ItemIEN = 0) then GetAllCollSamples(cboCollSamp);
1795    if (cboCollSamp.ItemIEN = 0) then
1796      begin
1797        ALabTest.Specimen := 0;
1798        ALabTest.CollSamp := 0;
1799        cboCollSamp.ItemIndex := -1;
1800        cboSpecimen.ItemIndex := -1;
1801      end
1802    else
1803      ALabTest.LoadSpecimen(cboSpecimen);
1804    ControlChange(Self);
1805  end;
1806  
1807  procedure TfrmODLab.cboCollSampMouseClick(Sender: TObject);
1808  begin
1809    inherited;
1810    if ALabTest = nil then exit;
1811    with cboCollSamp do
1812      begin
1813        if (ItemIndex >= 0) and (ItemIEN = 0) then
1814          GetAllCollSamples(cboCollSamp);
1815        if (ItemIEN = 0) then
1816          begin
1817            ALabTest.Specimen := 0;
1818            ALabTest.CollSamp := 0;
1819            ItemIndex := -1;
1820            cboSpecimen.ItemIndex := -1;
1821          end
1822        else
1823          ALabTest.LoadSpecimen(cboSpecimen);
1824      end;
1825    ControlChange(Self);
1826  end;
1827  
1828  function TfrmODLab.ValidCollTime(UserEntry: string): string;
1829  var
1830    i: integer;
1831  const
1832    FMDateResponses: array[0..3] of string = ('TODAY','NOW','NOON','MID');
1833  begin
1834    Result := '';
1835    UserEntry := UpperCase(UserEntry);
1836    if StrToFMDateTime(UserEntry) < 0 then exit;
1837    if (UserEntry = 'T') or
1838       (UserEntry = 'N') or
1839       (Copy(UserEntry,1,2)='T+') or
1840       (Copy(UserEntry,1,2)='T@') or
1841       (Copy(UserEntry,1,2)='T-') or
1842       (Copy(UserEntry,1,2)='N+') then Result := UserEntry
1843    else
1844       for i := 0 to 3 do if Pos(FMDateResponses[i],UserEntry)>0 then Result := UserEntry ;
1845    if Result = '' then Result := FloatToStr(StrToFMDateTime(UserEntry));
1846  end;
1847  
1848  procedure TfrmODLab.cboCollTimeExit(Sender: TObject);
1849  var
1850    ADateTime: TFMDateTime;
1851    CollType: string;
1852    isTrue: boolean;
1853  const
1854    TX_BAD_TIME         = ' is not a routine lab collection time.' ;
1855    TX_BAD_TIME_CAP     = 'Invalid Time';
1856  begin
1857    inherited;
1858    if (ALabTest = nil) or (cboColltime.Text = '') then Exit;
1859    Changing := True;
1860    CollType := 'LC';
1861    with cboCollTime do if (ItemIndex < 0) or (ITEMID = 'LO') then
1862      if ALabTest.LabCanCollect then
1863        begin
1864          ADateTime := StrToFMDateTime(cboCollTime.Text);
1865          if EvtDelayLoc > 0 then
1866            isTrue := IsLabCollectTime(ADateTime, EvtDelayLoc)
1867          else
1868            isTrue := IsLabCollectTime(ADateTime, Encounter.Location);
1869          if isTrue then
1870            begin
1871              calCollTime.Clear;
1872              cboCollTime.Visible := True;
1873              calCollTime.Visible := False;
1874              calCollTime.Enabled := False;
1875            end {if IsLabCollectTime}
1876          else
1877            begin
1878              InfoBox(cboCollTime.Text + TX_BAD_TIME, TX_BAD_TIME_CAP, MB_OK or MB_ICONWARNING) ;
1879              ItemIndex := -1;
1880              Text := GetFutureLabTime(ADateTime);
1881            end ;
1882        end {if (LabCanCollect...}
1883      else
1884       begin
1885         if OrderForInpatient then CollType := 'WC' else CollType := 'SP';
1886         calCollTime.Text := cboCollTime.Text;
1887         cboCollTime.Clear;
1888         cboCollTime.Visible := False;
1889         calCollTime.Visible := True;
1890         calCollTime.Enabled := True;
1891       end;
1892    cboCollType.SelectByID(CollType);
1893    Changing := False;                                           //v16.3  RV
1894    ControlChange(Self);                                         //v16.3  RV
1895    //Responses.Update('COLLECT', 1, CollType, CollType) ;       //v16.3  RV
1896    //memOrder.Text := Responses.OrderText;                      //v16.3  RV
1897  end;
1898  
1899  procedure TfrmODLab.cboSpecimenMouseClick(Sender: TObject);
1900  begin
1901    inherited;
1902    if ALabTest = nil then exit;
1903    with cboSpecimen do
1904      begin
1905        if (ItemIndex >= 0) and (ItemIEN = 0) then
1906          GetAllSpecimens(cboSpecimen);
1907        if (ItemIEN = 0) then
1908          begin
1909            ALabTest.Specimen := 0;
1910            ItemIndex := -1;
1911          end;
1912      end;
1913    ControlChange(Self);
1914  end;
1915  
1916  procedure TfrmODLab.GetAllCollSamples(AComboBox: TORComboBox);
1917  var
1918    OtherSamp: string;
1919  begin
1920    with ALabTest, AComboBox do
1921      begin
1922        if ((CollSampList.Count + 1) <= AComboBox.Items.Count) then LoadAllSamples;
1923        OtherSamp := SelectOtherCollSample(Font.Size, CollSampCount, CollSampList);
1924        if OtherSamp = '-1' then exit;
1925        if SelectByID(Piece(OtherSamp, U, 1)) = -1 then
1926          if Items.Count > CollSampCount + 1 then
1927            Items[0] := OtherSamp
1928          else
1929            Items.Insert(0, OtherSamp) ;
1930        SelectByID(Piece(OtherSamp, U, 1));
1931        AComboBox.OnChange(Self);
1932        ActiveControl := cmdAccept;
1933      end;
1934  end;
1935  
1936  procedure TfrmODLab.GetAllSpecimens(AComboBox: TORComboBox);
1937  var
1938    OtherSpec: string;
1939  begin
1940    inherited;
1941    if ALabTest <> nil then
1942      with ALabTest, AComboBox do
1943        begin
1944          AComboBox.DroppedDown := False;
1945          OtherSpec := SelectOtherSpecimen(Font.Size, SpecimenList);
1946          if OtherSpec = '-1' then exit;
1947          if SelectByID(Piece(OtherSpec, U, 1)) = -1 then
1948            if Items.Count > SpecListCount + 1 then
1949              Items[0] := OtherSpec
1950            else
1951              Items.Insert(0, OtherSpec) ;
1952          SpecimenList.Add(OtherSpec);
1953          SelectByID(Piece(OtherSpec, U, 1));
1954          AComboBox.OnChange(Self);
1955        end;
1956  end;
1957  
1958  procedure TfrmODLab.cboSpecimenKeyPause(Sender: TObject);
1959  begin
1960    inherited;
1961    if ALabTest = nil then exit;
1962    with cboSpecimen do
1963      if (ItemIndex >= 0) and (ItemIEN = 0) then
1964        GetAllSpecimens(cboSpecimen);
1965    if (cboSpecimen.ItemIEN = 0) then
1966      begin
1967        ALabTest.Specimen := 0;
1968        cboSpecimen.ItemIndex := -1;
1969      end ;
1970    ControlChange(Self);
1971  end;
1972  
1973  procedure TfrmODLab.cmdImmedCollClick(Sender: TObject);
1974  var
1975    ImmedCollTime: string;
1976  begin
1977    inherited;
1978    ImmedCollTime := SelectImmediateCollectTime(Font.Size, txtImmedColl.Text);
1979    if ImmedCollTime <> '-1' then
1980      begin
1981        txtImmedColl.Text := ImmedCollTime;
1982        calCollTime.FMDateTime := StrToFMDateTime(ImmedCollTime);
1983      end
1984    else
1985      begin
1986        txtImmedColl.Clear;
1987        calCollTime.Clear;
1988      end;
1989  end;
1990  
1991  procedure  TfrmODLab.ReadServerVariables;
1992  begin
1993    LRFZX   := KeyVariable['LRFZX'];
1994    LRFSAMP := KeyVariable['LRFSAMP'];
1995    LRFSPEC := KeyVariable['LRFSPEC'];
1996    LRFDATE := KeyVariable['LRFDATE'];
1997    LRFURG  := KeyVariable['LRFURG'];
1998    LRFSCH  := KeyVariable['LRFSCH'];
1999  end;
2000  
2001  procedure TfrmODLab.DetermineCollectionDefaults(Responses: TResponses);
2002  var
2003    RespCollect, RespStart: TResponse;
2004    //i: integer;
2005  begin
2006    if ALabTest = nil then exit;
2007    calCollTime.Clear;
2008    cboCollTime.Clear;
2009    calCollTime.Enabled := True;
2010    lblCollTime.Enabled := True;
2011    cboColltime.Enabled := True;
2012    with Responses, ALabTest do
2013      begin
2014        RespCollect := FindResponseByName('COLLECT',1);
2015        RespStart   := FindResponseByName('START'  ,1);
2016        if (RespCollect <> nil) then with RespCollect do
2017          begin
2018            if IValue = 'LC' then
2019              begin
2020                if not LabCanCollect then
2021                  begin
2022                   cboCollType.SelectByID('WC');
2023                   SetupCollTimes('WC');
2024                  end
2025                else   //  if LabCanCollect
2026                  begin
2027                   cboCollType.SelectByID('LC');
2028                   SetupCollTimes('LC');
2029                   CtrlInits.SetControl(cboCollTime, 'Lab Collection Times') ;
2030                   if RespStart <> nil then
2031                     begin
2032                       cboCollTime.SelectByID('L' + RespStart.IValue);
2033                       if cboCollTime.ItemIndex < 0 then
2034                         cboCollTime.Text := RespStart.IValue;
2035                     end;
2036                  end;
2037              end
2038            else    //  if IValue <> 'LC'
2039              begin
2040                cboCollType.SelectByID(IValue) ;
2041                SetupCollTimes(IValue);
2042                if RespStart <> nil then
2043                  begin
2044                    if ContainsAlpha(RespStart.IValue) then
2045                      calColltime.Text := RespStart.IValue
2046                    else
2047                      calColltime.FMDateTime := StrToFMDateTime(RespStart.IValue);
2048                  end;
2049              end ;
2050            if IValue = 'I' then
2051              if not LabCanCollect then
2052                begin
2053                 cboCollType.SelectByID('WC');
2054                 SetupCollTimes('WC');
2055                end
2056              else
2057                begin
2058                  calCollTime.Enabled := False;
2059                  if RespStart <> nil then txtImmedColl.Text := RespStart.EValue;
2060                end;
2061          end
2062        else   // if (RespCollect = nil)
2063          LoadCollType(cbocollType);
2064      end;
2065  end;
2066  procedure TfrmODLab.pnlCollTimeButtonEnter(Sender: TObject);
2067  begin
2068    inherited;
2069    (Sender as TPanel).BevelOuter := bvRaised;
2070  end;
2071  
2072  procedure TfrmODLab.pnlCollTimeButtonExit(Sender: TObject);
2073  begin
2074    inherited;
2075    (Sender as TPanel).BevelOuter := bvNone;
2076  end;
2077  
2078  procedure TfrmODLab.ViewinReportWindow1Click(Sender: TObject);
2079  begin
2080    inherited;
2081    ReportBox(memMessage.Lines, 'Lab Procedure', True);
2082  end;
2083  
2084  end.

Module Calls (2 levels)


fODLab
 ├fODBase
 │ ├fAutoSz
 │ ├uConst
 │ ├rOrders
 │ ├rODBase
 │ ├uCore
 │ ├UBAGlobals
 │ ├UBACore
 │ ├fOCAccept
 │ ├uODBase
 │ ├rCore
 │ ├rMisc
 │ ├fTemplateDialog
 │ ├uEventHooks
 │ ├uTemplates
 │ ├rConsults
 │ ├fOrders
 │ ├uOrders
 │ ├fFrame
 │ ├fODDietLT
 │ └rODDiet
 ├uConst
 ├rODBase...
 ├rODLab
 │ └uCore...
 ├uCore...
 ├rCore...
 ├fODLabOthCollSamp
 │ ├fBase508Form
 │ └fODLab...
 ├fODLabOthSpec
 │ ├fBase508Form...
 │ └rODLab...
 ├fODLabImmedColl
 │ ├fBase508Form...
 │ └rODLab...
 ├fLabCollTimes
 │ ├fBase508Form...
 │ ├uCore...
 │ └rODLab...
 ├rOrders...
 ├fRptBox
 │ ├fFrame...
 │ ├fBase508Form...
 │ ├uReports
 │ └rReports
 └fFrame...

Module Called-By (2 levels)


                      fODLab
                   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┘ │ 
         fODLabOthCollSamp┘ 
               fODLab...┤   
                fODBBank┘