Procedure

TPCEData.SetDiagnoses

Module

uPCE

Last Modified

7/15/2014 3:26:36 PM

Comments

ICDcode^P|S^Category^Narrative^P|S Text
load diagnoses for this encounter into TPCEDiag records, assumes all diagnoses for the
  encounter will be listed in Src and marks those that are not in Src for deletion

Visibility

Public

Owner

TPCEData

Declaration

procedure SetDiagnoses(Src: TStrings; FromForm: boolean = TRUE);       // ICDcode^P|S^Category^Narrative^P|S Text

Calls Hierarchy


TPCEData.SetDiagnoses
 ├TPCEData.MarkDeletions
 │ ├TPCEItem.Match
 │ └TPCEItem.MatchProvider
 ├TPCEData.MatchItem
 │ ├TPCEItem.Match
 │ └TPCEItem.MatchProvider
 ├TPCEItem.SetComment
 └TPCEDiag.Assign
   └TPCEItem.Assign
     └TPCEItem.SetComment

Called-By Hierarchy


                  TPCEData.SetDiagnoses
                                  Add┤ 
          TfrmRemDlg.btnFinishClick┘ │ 
   TfrmEncounterFrame.UpdateEncounter┘ 
        TfrmEncounterFrame.SendData┤   
TfrmEncounterFrame.FormCloseQuery┘ │   
  TfrmEncounterFrame.FormCloseQuery┘   

Calls

Name Declaration Comments
TPCEDiag.Assign procedure Assign(Src: TPCEItem); override; -
TPCEData.MarkDeletions procedure MarkDeletions(PreList: TList; PostList: TStrings); -
TPCEData.MatchItem function MatchItem(AList: TList; AnItem: TPCEItem): Integer; -
TPCEItem.SetComment procedure SetComment(const Value: String); -

Called-By

Name Declaration Comments
Add procedure Add(PCEItemClass: TPCEItemClass); -
TfrmEncounterFrame.UpdateEncounter procedure UpdateEncounter(PCE: TPCEData); -


Source

2303  procedure TPCEData.SetDiagnoses(Src: TStrings; FromForm: boolean = TRUE);
2304  { load diagnoses for this encounter into TPCEDiag records, assumes all diagnoses for the
2305    encounter will be listed in Src and marks those that are not in Src for deletion }
2306  var
2307    i, MatchIndex: Integer;
2308    SrcDiagnosis, CurDiagnosis, PrimaryDiag: TPCEDiag;
2309  begin
2310    if FromForm then MarkDeletions(fDiagnoses, Src);
2311    PrimaryDiag := nil;
2312    for i := 0 to Src.Count - 1 do
2313    begin
2314      SrcDiagnosis := TPCEDiag(Src.Objects[i]);
2315      MatchIndex := MatchItem(fDiagnoses, SrcDiagnosis);
2316      if MatchIndex > -1 then    //found in fdiagnoses
2317      begin
2318        CurDiagnosis := TPCEDiag(fDiagnoses.Items[MatchIndex]);
2319        if ((SrcDiagnosis.Primary <> CurDiagnosis.Primary) or
2320         (SrcDiagnosis.Comment <> CurDiagnosis.Comment) or
2321         (SrcDiagnosis.AddProb <> CurDiagnosis.Addprob)) then
2322        begin
2323          CurDiagnosis.Primary    := SrcDiagnosis.Primary;
2324          CurDiagnosis.Comment    := SrcDiagnosis.Comment;
2325          CurDiagnosis.AddProb    := SrcDiagnosis.AddProb;
2326          CurDiagnosis.FSend := True;
2327        end;
2328      end
2329      else
2330      begin
2331        CurDiagnosis := TPCEDiag.Create;
2332        CurDiagnosis.Assign(SrcDiagnosis);
2333        CurDiagnosis.FSend := True;
2334        fDiagnoses.Add(CurDiagnosis);
2335      end; {if MatchIndex}
2336      if(CurDiagnosis.Primary and (not assigned(PrimaryDiag))) then
2337        PrimaryDiag := CurDiagnosis;
2338      if (CurDiagnosis.AddProb) then
2339        FProblemAdded := True;
2340    end; {for}
2341    if(assigned(PrimaryDiag)) then
2342    begin
2343      for i := 0 to fDiagnoses.Count - 1 do
2344      begin
2345        CurDiagnosis := TPCEDiag(fDiagnoses[i]);
2346        if(CurDiagnosis.Primary) and (CurDiagnosis <> PrimaryDiag) then
2347        begin
2348          CurDiagnosis.Primary := FALSE;
2349          CurDiagnosis.FSend := True;
2350        end;
2351      end;
2352    end;
2353  end;