Procedure

LoadActiveMedLists

Module

rMeds

Last Modified

7/15/2014 3:26:44 PM

Scope

Interfaced

Declaration

procedure LoadActiveMedLists(InPtMeds, OutPtMeds, NonVAMeds: TList; var view: integer; var DateRange: string);

Calls Hierarchy


LoadActiveMedLists
 ├ClearMedList
 └SetMedFields

Called-By Hierarchy


                                                        LoadActiveMedLists
                                                TfrmMeds.RefreshMedLists┘ 
                                                  TfrmMeds.DisplayPage┤   
                                                  TfrmMeds.NotifyOrder┤   
                                                TfrmFrame.UMNewOrder┘ │   
                                                  TfrmMeds.SetFontSize┤   
                                                TfrmFrame.ChangeFont┘ │   
                                        TfrmFrame.LoadSizesForUser┤   │   
                                   TfrmFrame.LoadUserPreferences┘ │   │   
                                          TfrmFrame.UMInitiate┘   │   │   
                                        TfrmFrame.mnuFontSizeClick┘   │   
                               TfrmMeds.SortbyStatusthenLocation1Click┤   
                TfrmMeds.SortbyClinicOrderthenStatusthenStopDate1Click┤   
TfrmMeds.SortbyDrugalphabeticallystatusactivestatusrecentexpired1Click┤   
                                           TfrmOptionsOther.btnOKClick┘   

Calls

Name Declaration Comments
ClearMedList procedure ClearMedList(AList: TList); -
SetMedFields procedure SetMedFields(AMed: TMedListRec; const x, y: string); -

Called-By

Name Declaration Comments
TfrmMeds.RefreshMedLists procedure RefreshMedLists; -


Source

158   procedure LoadActiveMedLists(InPtMeds, OutPtMeds, NonVAMeds: TList; var view: integer; var DateRange: string);
159   var
160     idx, ASeq: Integer;
161     x, y: string;
162     ClinMeds, tmpInPtMeds: TList;
163     AMed: TMedListRec;
164   begin
165     //Check for CQ 9814 this should prevent an M error is DFn is not defined.
166     if patient=nil then exit;
167     if patient.DFN='' then exit;
168     ClinMeds := TList.Create;           //IMO new
169     tmpInPtMeds := TList.Create;        //IMO new
170     ClearMedList(InPtMeds);
171     ClearMedList(OutPtMeds);
172     ClearMedList(NonVAMeds);
173     CallV('ORWPS ACTIVE', [Patient.DFN, User.DUZ, view, '1']);
174     ASeq := 0;
175     if (view = 0) and (RPCBrokerV.Results.Count > 0) then
176       view := StrToIntDef(Piece(RPCBrokerV.Results.Strings[0], U, 1), 0);
177     DateRange := Piece(RPCBrokerV.Results.Strings[0], U, 2);
178     with RPCBrokerV do while Results.Count > 0 do
179     begin
180       x := Results[0];
181       Results.Delete(0);
182       if CharAt(x, 1) <> '~' then Continue;        // only happens if out of synch
183       y := '';
184       while (Results.Count > 0) and (CharAt(Results[0], 1) <> '~') do
185       begin
186         if CharAt(Results[0], 1) = '\' then y := y + CRLF;
187         y := y + Copy(Results[0], 2, Length(Results[0])) + ' ';
188         Results.Delete(0);
189       end;
190       AMed := TMedListRec.Create;
191       SetMedFields(AMed, x, y);
192       Inc(ASeq);
193       AMed.SrvSeq := ASeq;
194       if (AMed.Inpatient) then
195       begin
196         tmpInPtMeds.Add(AMed);
197         //if (Copy(x,2,2)='CP') then tmpInPtMeds.Add(AMed);
198        // if (Copy(x,2,2)='CP') and ((view = 2) or (view = 0)) then ClinMeds.Add(AMed)
199        // else tmpInPtMeds.Add(AMed);
200       end
201       else
202       if  AMed.NonVAMed then
203           NonVAMeds.Add(AMed)
204       else
205          OutPtMeds.Add(AMed);
206     end;
207    // 12-4 if view <> 1 then ClinMeds.Sort(ByStatusThenStop);
208    // 12-4 if view = 1 then tmpInPtMeds.Sort(ByStatusThenLocation)
209    // 12-4 else tmpInPtMeds.Sort(ByStatusThenStop);
210     //tmpInPtMeds.Sort(ByStatusThenStop);                           //IMO
211    //12-4 if view <> 1 then InPtMeds.Assign(ClinMeds);
212     for idx := 0 to tmpInPtMeds.Count - 1 do
213       InPtMeds.Add(TMedListRec(tmpInPtMeds.Items[idx]));
214     //if view <> 1 then OutPtMeds.Sort(ByStatusThenStop)
215     //else OutPtMeds.Sort(ByStatusThenLocation);
216    //12-4 if view <> 1 then NonVAMeds.Sort(ByStatusThenStop)
217    //12-4 else NonVAMeds.Sort(ByStatusThenLocation);
218     if Assigned(ClinMeds) then FreeAndNil(ClinMeds);
219     if Assigned(tmpInPtMeds) then FreeAndNil(tmpInPtMeds);
220   end;