Procedure

ExtractActiveMeds

Module

rCover

Last Modified

7/15/2014 3:26:44 PM

Scope

Global

Declaration

procedure ExtractActiveMeds(Dest: TStrings; Src: TStringList);

Calls Hierarchy


ExtractActiveMeds
 └MedStatusGroup

Called-By Hierarchy


                  ExtractActiveMeds
                      ListGeneric┤ 
             TfrmCover.LoadList┘ │ 
        TfrmCover.DisplayPage┤   │ 
   TfrmCover.CoverItemClick┘ │   │ 
TfrmCover.UpdateAllergiesList┘   │ 
      TfrmCover.NotifyOrder┤     │ 
     TfrmFrame.UMNewOrder┘ │     │ 
      TfrmCover.popNKAClick┤     │ 
 TfrmARTAllergy.FormDestroy┘     │ 
                   ListActiveMeds┤ 
                ListAllBackGround┘ 
         TfrmCover.timPollTimer┘   

Calls

Name Declaration Comments
MedStatusGroup function MedStatusGroup(const s: string): Integer; -

Called-By

Name Declaration Comments
ListActiveMeds procedure ListActiveMeds(Dest: TStrings); -
ListAllBackGround procedure ListAllBackGround(var Done: Boolean; DestProb, DestCWAD, DestMeds, DestRmnd, DestLabs, DestVitl, DestVsit: TStrings; const IPAddr: string; AHandle: HWND); -
ListGeneric procedure ListGeneric(Dest: TStrings; ARpc: String; ACase, AInvert: Boolean; ADatePiece: integer; ADateFormat, AParam1, ADetail, AID: String); -


Source

129   procedure ExtractActiveMeds(Dest: TStrings; Src: TStringList);
130   const
131     MED_TYPE: array[boolean] of string = ('INPT', 'OUTPT');
132   var
133     i: Integer;
134     MedType, NonVA, x: string;
135     MarkForDelete: Boolean;
136   begin
137     NonVA := 'N;';
138     if Patient.Inpatient then
139       begin
140         if Patient.WardService = 'D' then MedType := 'IO'     //  Inpatient - DOM - show both
141         else MedType := 'I';                                  //  Inpatient non-DOM
142       end
143     else
144       MedType := 'O';                                         //  Outpatient
145     for i := Src.Count - 1 downto 0 do
146     begin
147       MarkForDelete := False;
148       // clear outpt meds if inpt, inpt meds if outpt.  Keep all for DOM patients.
149       if (Pos(Piece(Piece(Src[i], U, 1), ';', 2), MedType) = 0)
150          and (Piece(Src[i], U, 5)<> 'C') then MarkForDelete := True;
151       if Pos(NonVA, Piece(Src[i], U, 1)) > 0 then    // Non-VA Med
152         begin
153           MarkForDelete := False;                    // always display non-VA meds
154           x := Src[i];
155           SetPiece(x, U, 2, 'Non-VA  ' + Piece(x, U, 2));
156           Src[i] := x;
157         end;
158       if (Piece(Src[i], U, 5)='C') then  // Clin Meds
159       begin
160          MarkForDelete := False;                    // always display non-VA meds
161          x := Src[i];
162          SetPiece(x, U, 2, 'Clin Meds  ' + Piece(x, U, 2));
163          Src[i] := x;
164       end;
165       // clear non-active meds   (SHOULD THIS INCLUDE PENDING ORDERS?)
166       if MedStatusGroup(Piece(Src[i], U, 4)) = MED_NONACTIVE then MarkForDelete := True;
167       if MarkForDelete then Src.Delete(i)
168       else if MedType = 'IO' then   // for DOM patients only, distinguish between inpatient/outpatient meds
169         begin
170           x := Src[i];
171           SetPiece(x, U, 2, MED_TYPE[Piece(Piece(x, U, 1), ';', 2)='O'] + ' - ' + Piece(x, U, 2));
172           Src[i] := x;
173         end;
174     end;
175     InvertStringList(Src);        // makes inverse chronological by order time
176     MixedCaseList(Src);
177     if Src.Count = 0 then Src.Add('0^No active medications found');
178     FastAssign(Src, Dest);
179   end;