Function

SaveAsQuickOrder

Module

fOrderSaveQuick

Last Modified

7/15/2014 3:26:42 PM

Scope

Interfaced

Declaration

function SaveAsQuickOrder(ResponseSet: TResponses): Boolean;

Calls Hierarchy


SaveAsQuickOrder
 ├TResponses.OrderCRC
 ├TfrmBase508Form.Create
 │ ├TfrmBase508Form.UpdateAccessibilityActions
 │ ├UnfocusableControlEnter
 │ └AdjustControls
 │   ├TfrmBase508Form.ModifyUnfocusableControl
 │   └..(rec)..
 ├NameOfDGroup
 │ └LoadDGroupMap
 ├GetQuickName
 ├TResponses.GetOrderText
 │ ├TResponses.NextInstance
 │ ├TResponses.FindResponseByName
 │ ├TResponses.FormatResponse
 │ │ └TResponses.FindResponseByIEN
 │ └TResponses.AppendChildren
 │   ├TResponses.FindPromptByIEN
 │   ├TResponses.FindResponseByIEN
 │   └TResponses.FormatResponse...
 ├LoadQuickListForOD
 ├TResponses.SaveQuickOrder
 │ ├PutQuickOrder
 │ │ └SetupORDIALOG
 │ └TResponses.OrderCRC
 └SaveQuickListForOD

Called-By Hierarchy


                   SaveAsQuickOrder
                   QuickOrderSave┘ 
TfrmOrders.mnuOptSaveQuickClick┘   

Calls

Name Declaration Comments
TfrmBase508Form.Create constructor Create(AOwner: TComponent); override; -
TResponses.GetOrderText function GetOrderText: string; -
GetQuickName function GetQuickName(const CRC: string): string; -
LoadQuickListForOD procedure LoadQuickListForOD(Dest: TStrings; DGroup: Integer); -
NameOfDGroup function NameOfDGroup(IEN: Integer): string; -
TResponses.OrderCRC function OrderCRC: string; -
SaveQuickListForOD procedure SaveQuickListForOD(Src: TStrings; DGroup: Integer); -
TResponses.SaveQuickOrder procedure SaveQuickOrder(var ANewIEN: Integer; const ADisplayName: string); -

Called-By

Name Declaration Comments
QuickOrderSave procedure QuickOrderSave; -


Source

105   function SaveAsQuickOrder(ResponseSet: TResponses): Boolean;
106   const
107     EMPTY_CRC = 'FFFFFFFF';
108   var
109     frmSaveQuickOrder: TfrmSaveQuickOrder;
110     DGroupName, QuickName, CRC: string;
111     NewIEN, AnIndex, i: Integer;
112     IsClinicOrder: boolean;
113   begin
114     Result := False;
115     CRC := ResponseSet.OrderCRC;
116     IsClinicOrder := False;
117     if CRC = EMPTY_CRC then
118     begin
119       InfoBox(TX_NO_TEXT, TC_NO_TEXT, MB_OK);
120       Exit;
121     end;
122     frmSaveQuickOrder := TfrmSaveQuickOrder.Create(Application);
123     try
124       ResizeFormToFont(TForm(frmSaveQuickOrder));
125       with frmSaveQuickOrder do
126       begin
127         if (ResponseSet.DisplayGroup = ClinDisp) and (ResponseSet.Dialog = 'PSJI OR PAT FLUID OE') then
128           begin
129             ResponseSet.DisplayGroup := IVDisp;
130             IsClinicOrder := True;
131           end;
132         if ResponseSet.DisplayGroup = ClinDisp then
133           DGroupName := NameOfDGroup(InptDisp)
134         else
135           DGroupName := NameOfDGroup(ResponseSet.DisplayGroup);
136         if DGroupName = 'Inpt. Meds' then
137           begin
138             ResponseSet.DisplayGroup := InptDisp;
139             DGroupName := NameOfDGroup(InptDisp);
140           end;
141         Caption := 'Add Quick Order (' + DGroupName + ')';
142         lblQuickList.Caption := 'Common List for ' + DGroupName;
143         lstQuickList.Caption := lblQuickList.Caption;
144         QuickName := GetQuickName(CRC);
145         memOrder.Text := ResponseSet.OrderText;
146         txtDisplayName.Text := QuickName;
147         with lstQuickList do
148         begin
149           if ResponseSet.DisplayGroup = ClinDisp then
150             LoadQuickListForOD(Items, InptDisp)
151           else
152             LoadQuickListForOD(Items, ResponseSet.DisplayGroup);
153           if Length(QuickName) > 0
154             then Items.Insert(0, '-1^' + QuickName)
155             else Items.Insert(0, '-1^<New Quick Order>');
156           ItemIndex := 0;
157         end;
158         ActiveControl := txtDisplayName;
159         ShowModal;
160         if OKPressed then
161         begin
162           Result := True;
163           // save reponses as quick order
164           ResponseSet.SaveQuickOrder(NewIEN, txtDisplayName.Text);
165           // find the new quick order and set the new IEN
166           AnIndex := -1;
167           with lstQuickList do for i := 0 to Items.Count - 1 do
168             if GetIEN(i) = -1 then AnIndex := i;
169           if AnIndex > -1 then lstQuickList.Items[AnIndex] := IntToStr(NewIEN) + U +
170                                                               txtDisplayName.Text;
171           // replace the user's quick list with this new quick list
172           if ResponseSet.DisplayGroup = ClinDisp then
173             SaveQuickListForOD(lstQuickList.Items, InptDisp)
174           else
175             SaveQuickListForOD(lstQuickList.Items, ResponseSet.DisplayGroup);
176         end; {if OKPressed}
177         if IsClinicOrder = True then ResponseSet.DisplayGroup := ClinDisp;
178       end; {with frmSaveQuickOrder}
179     finally
180       frmSaveQuickOrder.Release;
181     end;
182   end;