Procedure

TfrmProblems.LoadPatientProblems

Module

fProbs

Last Modified

7/15/2014 3:26:38 PM

Comments

SCCond, tmpSCstr: string;

Visibility

Public

Owner

TfrmProblems

Declaration

procedure LoadPatientProblems(AList:TstringList;const status:char;init:boolean);

Calls Hierarchy


TfrmProblems.LoadPatientProblems
 ├TPLFilters.create
 ├TfrmProblems.ClearGrid
 ├FMNow
 ├ProblemList
 ├TfrmProblems.SetGridPieces
 │ └ForChars
 ├ReverseList
 ├TfrmProblems.RefreshList
 │ └TfrmProblems.PlainText
 ├TfrmProblems.NoRowSelected
 ├GetProblemComments
 ├SetViewFilters
 │ ├LoadFilterList
 │ └ShowFilterStatus
 ├InitViewFilters
 │ └SetViewFilters...
 ├TfrmProblems.ApplyViewFilters
 ├TfrmProblems.MString
 ├TfrmProblems.wgProbDataClick
 │ ├TfrmProblems.MString
 │ ├TfrmProblems.NoRowSelected
 │ └TfrmProblems.RowSelected
 │   └TfrmProblems.MString
 ├TfrmProblems.RowSelected...
 └TfrmProblems.pnlRightResize
   ├TfrmProblems.SetGridPieces...
   ├TfrmProblems.ApplyViewFilters
   ├TfrmProblems.RefreshList...
   └TfrmProblems.GetRowCount

Called-By Hierarchy


           TfrmProblems.LoadPatientProblems
            TfrmProblems.lstProbActsClick┤ 
        TfrmProblems.wgProbDataDblClick┤ │ 
              TfrmProblems.lstViewClick┘ │ 
      TfrmProblems.HighlightDuplicate┘   │ 
            TfrmProblems.AddProblem┤     │ 
 TfrmProblems.lstProbActsClick...┤ │     │ 
    TfrmProblems.lstProbPickClick┤ │     │ 
 TfrmProblems.lstProbPickDblClick┤ │     │ 
 TfrmProblems.edProbEntKeyPress┘ │ │     │ 
         TfrmProblems.UMPLLexicon┘ │     │ 
      TfrmdlgProb.bbChangeProbClick┘     │ 
                TfrmProblems.LoadProblems┤ 
               TfrmProblems.DisplayPage┤ │ 
TfrmProblems.mnuViewRestoreDefaultClick┤ │ 
                  TfrmProblems.FormShow┘ │ 
              TfrmProblems.RestoreProblem┤ 
       TfrmProblems.lstProbActsClick...┘ │ 
                    TfrmdlgProb.FormClose┘ 

Calls

Name Declaration Comments
TfrmProblems.ApplyViewFilters procedure ApplyViewFilters; -
TfrmProblems.ClearGrid procedure ClearGrid; -
TPLFilters.create constructor create; -
FMNow function FMNow: TFMDateTime; -
GetProblemComments function GetProblemComments(ProblemIFN: string): TStrings; -
InitViewFilters procedure InitViewFilters(Alist:TstringList); -
TfrmProblems.MString function MString( index: integer): string; -
TfrmProblems.NoRowSelected procedure NoRowSelected; -
TfrmProblems.pnlRightResize procedure pnlRightResize(Sender:TObject); -
ProblemList function ProblemList(const PatientDFN: string; Status:string; ADate: TFMDateTime): TStrings ; -
TfrmProblems.RefreshList procedure RefreshList; -
ReverseList procedure ReverseList(Alist:TstringList); -
TfrmProblems.RowSelected procedure RowSelected; -
TfrmProblems.SetGridPieces procedure SetGridPieces(Pieces: string); -
SetViewFilters procedure SetViewFilters(Alist:TStringList); -
TfrmProblems.wgProbDataClick procedure wgProbDataClick(Sender: TObject); -

Called-By

Name Declaration Comments
TfrmdlgProb.FormClose procedure FormClose(Sender: TObject; var Action: TCloseAction); -
TfrmProblems.LoadProblems procedure LoadProblems; -
TfrmProblems.lstProbActsClick procedure lstProbActsClick(Sender: TObject); -
TfrmProblems.RestoreProblem procedure RestoreProblem; -


Source

1000  procedure TfrmProblems.LoadPatientProblems(AList:TStringList; const Status:char; init:boolean);
1001  var {init should only be true when initializing a list for a new patient}
1002    x, line, ver, prio, comments, cs: String;
1003    i, j, inactI, inactS: Integer;
1004    st: char;
1005    CmtList: TStringList;
1006    DateOfInterest: TFMDateTime;
1007    //SCCond, tmpSCstr: string;
1008  
1009    procedure ReverseList(Alist:TstringList);
1010    var
1011      i,j:integer;
1012    begin
1013      i:=0;
1014      j:=pred(Alist.count);
1015      while i<j do
1016        begin
1017          alist.exchange(i,j);
1018          inc(i);
1019          dec(j);
1020        end;
1021    end;
1022  
1023  begin  {Body}
1024    FI10Active := (Piece(Encounter.GetICDVersion, U, 1) <> 'ICD');
1025    CmtList := TStringList.Create;
1026    if PLFilters=nil then {create view filter lists}
1027      PLFilters:=TPLFilters.create;
1028    try
1029      ClearGrid;
1030      inactI := 0;
1031      inactS := 0;
1032      if PLPt = nil then
1033        begin
1034          InfoBox(TX_INVALID_PATIENT, TC_NO_PATIENT, MB_OK or MB_ICONWARNING);
1035          AList.Clear;
1036          AList.Add('No data available');
1037        end
1038      else
1039        begin
1040          st:=status;
1041          if st= '' then st := 'A'; {default to active list}
1042          if Patient.Inpatient then   //CQ 21793
1043            DateOfInterest := FMNow
1044          else
1045            DateOfInterest := Encounter.DateTime;
1046          FastAssign(ProblemList(Patient.DFN, st, DateOfInterest), AList);
1047        end;
1048      if Status = 'R' then
1049        SetGridPieces('3,4,5,7,8,9')
1050      else
1051        SetGridPieces('2,3,4,5,7,8,9');
1052      if Alist.count > 1 then Alist.delete(0); {get rid of first element - it is a list count}
1053      SortByPiece(AList, u, 6); { Sort by FM date/time }
1054      SetListFMDateTime('MMM dd yyyy',AList, u, 6);      { Change FM date to MM/DD/YY  }
1055      SetListFMDateTime('MMM dd yyyy',AList, u, 5);      { Change FM date to MM/DD/YY  }
1056      if PLUser.usReverseChronDisplay then {reverse chron order if required}
1057        ReverseList(Alist);
1058      {populate the grid}
1059      if ((Alist.Count = 1) and (pos('No data available', Alist[0]) > 0))then
1060        begin
1061          FAllProblems.Add('^^No problems found.');
1062          FProblemsVisible.Add('Y');
1063          RefreshList;
1064          Alist.Clear ;
1065          NoRowSelected;
1066          exit ;
1067        end ;
1068      for i := 0 to pred(Alist.count) do
1069      begin
1070        FAllProblems.Add('');
1071        FProblemsVisible.Add('Y');
1072        comments := '';
1073        CmtList.Clear;
1074        x := AList[i];
1075        if (Piece(x, U, 18) = '#') and CharInSet(CharAt(UpperCase(Status), 1), ['A', 'B', 'I', 'R']) and (not FI10Active) then
1076          begin
1077            ver := '#';      // inactive ICD code flag takes precedence over unverified flag
1078            if (Piece(x, U, 2) = 'A') then inactI := inactI + 1;
1079          end
1080        else if (Piece(x, U, 18) = '$') and CharInSet(CharAt(UpperCase(Status), 1), ['A', 'B', 'I', 'R']) then
1081          begin
1082            ver := '#';      // inactive SNOMED CT code flag takes precedence over unverified flag
1083            if (Piece(x, U, 2) = 'A') then inactS := inactS + 1;
1084          end
1085        else if (PlUSer.usVerifyTranscribed) and
1086                (Piece(x, U, 9) = 'T') then
1087          ver := '(u)'
1088        else
1089          ver := '   ';
1090        if Piece(x, U, 14) = 'A' then prio   := ' * ' else prio   := '   ' ;
1091        Line := '';
1092        SetPiece(Line, U, 2, Piece(x, U, 2) + prio + ver);
1093        if Piece(x, U, 15) = '1' then  //problem has comments
1094          begin
1095            FastAssign(GetProblemComments(Piece(x, U, 1)), CmtList);
1096            if FAllProblems.Objects[i] = nil then FAllProblems.Objects[i]:= TStringList.Create;
1097            FastAssign(CmtList, TStringList(FAllProblems.Objects[i]));
1098          end;
1099  
1100        SetPiece(Line, U, 3, Piece(x, U, 3));
1101  
1102        if Piece(x, U, 19) <> '' then
1103        begin
1104          if Piece(x, U, 20) = 'ICD' then
1105            cs := 'ICD-9-CM'
1106          else if Piece(x, U, 20) = '10D' then
1107            cs := 'ICD-10-CM'
1108          else
1109            cs := Piece(x, U, 20);
1110          SetPiece(Line, U, 3, Piece(Line, U, 3) + #13#10 + cs + ' Text: ' + MixedCase(Piece(x, U, 19)));
1111        end;
1112        if PLUser.usViewComments = '1' then
1113          begin
1114            for j := 0 to CmtList.Count-1 do
1115              comments := comments + '         ' + CmtList.Strings[j] + #13#10;
1116            SetPiece(Line, U, 3, Piece(Line, U, 3) + #13#10 + comments);
1117          end;
1118        SetPiece(Line, U, 4, Trim(Piece(x, U, 5)));                        {onset date}
1119        SetPiece(Line, U, 5, Trim(Piece(x, U, 6)));                        {last updated}
1120        SetPiece(Line, U, 7, MixedCase(Piece(Piece(x, U, 10), ';', 2)));   {location name}
1121        SetPiece(Line, U, 8, MixedCase(Piece(Piece(x, U, 12), ';', 2)));   {provider name}
1122        SetPiece(Line, U, 9, MixedCase(Piece(Piece(x, U, 13), ';', 2)));   {service name}
1123        {hidden cells}
1124        SetPiece(Line, U, 1, Piece(x, U, 1));                              {problem IEN}
1125        SetPiece(Line, U, 6, Piece(x, U, 7));                              {service connected status}
1126        SetPiece(Line, U, 11, Piece(Piece(x, U, 10), ';', 1));              {location IEN}
1127        SetPiece(Line, U, 13, Piece(x, U, 11));                             {loc type}
1128        SetPiece(Line, U, 10, Piece(Piece(x, U, 12), ';', 1));              {responsible provider IEN}
1129        SetPiece(Line, U, 12, Piece(Piece(x, U, 13), ';', 1));              {service IEN}
1130        SetPiece(Line, U, 14, Piece(x, U, 4));                              {code}
1131        SetPiece(Line, U, 15, Piece(x, U, 17));                             {Service-connected conditions}
1132        SetPiece(Line, U, 16, Piece(x, U, 18));                             {# = inactive ICD code stored with problem}
1133        FAllProblems[i] := Line;
1134      end;
1135      Alist.clear;
1136      if not init then
1137        SetViewFilters(Alist)
1138      else
1139        InitViewFilters(Alist);
1140      ApplyViewFilters;
1141      RefreshList;
1142      lstProbPick.ItemIndex := -1;
1143      if (ProbRec <> nil) and (ProbRec.PIFN <> '') then
1144        begin
1145          for i := 0 to wgProbData.Items.count-1 do
1146            if (Piece(MString(i), U, 1) = ProbRec.PIFN) then
1147               wgProbData.ItemIndex := i ;
1148          wgProbDataClick(Self);
1149        end
1150      else
1151        wgProbData.ItemIndex := -1;
1152      if (wgProbData.Items.Count > 0) and (wgProbData.ItemIndex > -1) then
1153        RowSelected
1154      else
1155        NoRowSelected;
1156      pnlRightResize(Self);
1157      if (not FWarningShown) and (inactI > 0) and (inactS > 0) and CharInSet(CharAt(UpperCase(Status), 1), ['A', 'B']) then
1158        begin
1159         InfoBox('There are ' + IntToStr(inactI) + ' active problem(s) flagged with a "#" as having ' +
1160                 'inactive ICD codes as of the Encounter date. There are also ' + IntToStr(inactS) +
1161                 ' active problem(s) flagged with a "#" as having inactive SNOMED CT codes as of ' +
1162                 'the Encounter date. You may correct these problems using the "Change" option.',
1163                 'Inactive ICD & SNOMED CT Codes Found', MB_ICONWARNING or MB_OK);
1164         FWarningShown := True;
1165        end
1166      else if (not FWarningShown) and (inactI > 0) and CharInSet(CharAt(UpperCase(Status), 1), ['A', 'B']) then
1167        begin
1168         InfoBox('There are ' + IntToStr(inactI) + ' active problem(s) flagged with a "#" as having ' +
1169                 'inactive ICD codes as of the Encounter date. You may correct these problems using the "Change" option.',
1170                 'Inactive ICD Codes Found', MB_ICONWARNING or MB_OK);
1171         FWarningShown := True;
1172        end
1173      else if (not FWarningShown) and (inactS > 0) and CharInSet(CharAt(UpperCase(Status), 1), ['A', 'B']) then
1174        begin
1175         InfoBox('There are ' + IntToStr(inactS) + ' active problem(s) flagged with a "#" as having ' +
1176                 'inactive SNOMED CT codes as of the Encounter date. You may correct these problems ' +
1177                 'using the "Change" option.', 'Inactive SNOMED CT Codes Found', MB_ICONWARNING or MB_OK);
1178         FWarningShown := True;
1179        end;
1180    finally
1181      CmtList.Free;
1182    end;
1183  end;