Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/Consults/uConsults.pas

    r829 r1679  
    44
    55uses
    6     SysUtils, Windows, Messages, Controls, Classes, StdCtrls, ORfn, uTIU, ORCtrls;
     6    SysUtils, Windows, Messages, Controls, Classes, StdCtrls, ORfn, uTIU, ORCtrls,
     7    Contnrs, DateUtils;
    78
    89type
     
    3839    ProvDxCode: string;                     {  30.1}
    3940    RequestProcessingActivity: TStringList; {  40}
    40     //EarliestDate: TFMDateTime;
    41     //LatestDate: TFMDateTime;
     41    EarliestDate: TFMDateTime;
     42    //LatestDate: TFMDateTime; //dropped requirement WAT
    4243  end ;
    4344
     
    5354    Urgency: integer;
    5455    UrgencyName: string;
    55     //EarliestDate: TFMDateTime;
    56     //LatestDate: TFMDateTime;
     56    EarliestDate: TFMDateTime;
     57    //LatestDate: TFMDateTime; //dropped requirement WAT
    5758    Place: string;
    5859    PlaceName: string;
     
    259260procedure BuildServiceTree(Tree: TORTreeView; SvcList: TStrings; const Parent: string; Node: TORTreeNode);
    260261var
    261   MyID, MyParent, Name, temp: string;
    262   i: Integer;
    263   ChildNode, tmpNode: TORTreeNode;
     262  MyID, MyParent, Name, item: string;
     263  i, Idx: Integer;
     264  ParentNode, ChildNode: TORTreeNode;
     265//  tmpNode: TORTreeNode;
    264266  HasChildren: Boolean;
     267//  AllNodes: TStringList;
     268  ParentNodes: TStringList;
     269//  List: TList;
     270//  Lists: TObjectList;
     271//  bad: boolean;
     272
     273// Former code was only filtering out half the duplicates, depending on
     274// how they appeared in the tree.  Commented out code filters out all the duplicates,
     275// and still keeps the fast tree build.  However, CPRS Clinical Workgroup determined
     276// that no duplicates should be filtered out.  Code kept here in order to keep fast filter
     277// logic, in case duplicates are ever filtered out in the future.
     278
     279{
     280  procedure FilterOutDuplicates;
     281  var
     282    j: integer;
     283  begin
     284    bad := false;
     285    if AllNodes.Find(MyID, Idx) then
     286    begin
     287      if AllNodes.Objects[Idx] is TORTreeNode then
     288      begin
     289        tmpNode := TORTreeNode(AllNodes.Objects[Idx]);
     290        bad := tmpNode.HasAsParent(ParentNode);
     291        if (not bad) and assigned(tmpNode.Parent) then
     292          bad := ParentNode.HasAsParent(tmpNode.Parent);
     293      end
     294      else
     295      begin
     296        bad := False;
     297        List := TList(AllNodes.Objects[Idx]);
     298        for j := 0 to List.Count - 1 do
     299        begin
     300          tmpNode := TORTreeNode(List[j]);
     301          bad := TORTreeNode(List[j]).HasAsParent(ParentNode);
     302          if (not bad) and assigned(tmpNode.Parent) then
     303            bad := ParentNode.HasAsParent(tmpNode.Parent);
     304          if bad then break;
     305        end;
     306      end;
     307    end;
     308  end;
     309
     310  procedure AddNode;
     311  begin
     312    if AllNodes.Find(MyID, Idx) then
     313    begin
     314      if AllNodes.Objects[Idx] is TORTreeNode then
     315      begin
     316        List := TList.Create;
     317        Lists.Add(List);
     318        List.Add(AllNodes.Objects[Idx]);
     319        AllNodes.Objects[Idx] := List;
     320      end
     321      else
     322        List := TList(AllNodes.Objects[Idx]);
     323      List.Add(ChildNode);
     324    end
     325    else
     326      AllNodes.AddObject(MyId, ChildNode);
     327  end;
     328}
     329
    265330begin
    266331  Tree.Items.BeginUpdate;
    267   with SvcList do for i := 0 to Count - 1 do
    268     begin
    269       if Piece(Strings[i], U, 5) = 'S' then Continue;  // V19.4 {rv}
    270       //if Piece(Strings[i], U, 6) = 'S' then Continue;
    271       MyParent := Piece(Strings[i], U, 3);
    272       if (MyParent = Parent) then
    273         begin
    274           MyID := Piece(Strings[i], U, 1);
    275           Name := Piece(Strings[i], U, 2);
    276           temp  := Strings[i];
    277           tmpNode := nil;
    278           HasChildren := Piece(Strings[i], U, 4) = '+';
    279           if Node <> nil then if Node.HasChildren then
    280             tmpNode := Tree.FindPieceNode(MyID, 1, U, Node);
    281           if (tmpNode <> nil) and tmpNode.HasAsParent(Node) then
    282             Continue
    283           else
    284             begin
    285               ChildNode := TORTreeNode(Tree.Items.AddChild(Node, Name));
    286               ChildNode.StringData := temp;
    287               if HasChildren then BuildServiceTree(Tree, SvcList, MyID, ChildNode);
    288             end;
    289         end;
     332  ParentNodes := TStringList.Create;
     333//  AllNodes := TStringList.Create;
     334//  Lists := TObjectList.Create;
     335  try
     336    ParentNodes.Sorted := True;
     337//    AllNodes.Sorted := True;
     338    for i := 0 to SvcList.Count - 1 do
     339    begin
     340      item := SvcList[i];
     341      if Piece(item, U, 5) = 'S' then Continue;
     342      MyParent := Piece(item, U, 3);
     343      MyID := Piece(item, U, 1);
     344      if not ParentNodes.Find(MyParent, Idx) then
     345        ParentNode := nil
     346      else
     347      begin
     348        ParentNode := TORTreeNode(ParentNodes.Objects[Idx]);
     349//        FilterOutDuplicates;
     350//        if bad then Continue;
     351      end;
     352      Name := Piece(item, U, 2);
     353      HasChildren := Piece(item, U, 4) = '+';
     354      ChildNode := TORTreeNode(Tree.Items.AddChild(ParentNode, Name));
     355      ChildNode.StringData := item;
     356//      AddNode;
     357      if HasChildren then
     358        ParentNodes.AddObject(MyID, ChildNode);
    290359    end;
     360  finally
     361    ParentNodes.Free;
     362//    AllNodes.Free;
     363//    Lists.Free;
     364  end;
    291365  Tree.Items.EndUpdate;
    292366end;
Note: See TracChangeset for help on using the changeset viewer.