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/Encounter/fDiagnoses.pas

    r829 r1679  
    2525  private
    2626    procedure EnsurePrimaryDiag;
    27 
     27    function isProblem(diagnosis: TPCEDiag): Boolean;
     28    function isEncounterDx(problem: string): Boolean;
    2829  protected
    2930    procedure UpdateNewItemStr(var x: string); override;
     
    3839                     'via the Problems tab.';
    3940  TC_INACTIVE_CODE = 'Problem Contains Inactive Code';
     41  TX_REDUNDANT_DX  = 'The problem that you''ve selected is already included in the list of diagnoses' + #13#10 +
     42                     'for this encounter. No need to select it again...';
     43  TC_REDUNDANT_DX  = 'Redundant Diagnosis: ';
    4044
    4145var
     
    6569    if not Primary and (Items.Count > 0) then
    6670    begin
    67       GridIndex := 0;
    68       TPCEDiag(Items.Objects[0]).Primary := True;
     71      GridIndex := Items.Count - 1;//0; vhaispbellc CQ 15836
     72      TPCEDiag(Items.Objects[Items.Count - 1]).Primary := True;
    6973      GridChanged;
    7074    end;
     
    101105      if(lbGrid.Selected[i]) then
    102106        TPCEDiag(lbGrid.Items.Objects[i]).AddProb := (ckbDiagProb.Checked) and
     107                                                     (not isProblem(TPCEDiag(lbGrid.Items.Objects[i]))) and
    103108                                                     (TPCEDiag(lbGrid.Items.Objects[i]).Category <> PL_ITEMS);
    104109    GridChanged;
     
    130135  else
    131136    x := x + U + '0';
     137end;
     138
     139function TfrmDiagnoses.isProblem(diagnosis: TPCEDiag): Boolean;
     140var
     141  i: integer;
     142  p, code, narr, sct: String;
     143begin
     144  result := false;
     145  for i := 0 to FProblems.Count - 1 do
     146  begin
     147    p := FProblems[i];
     148    code := piece(p, '^', 1);
     149    narr := piece(p, '^', 2);
     150    if (pos('SCT', narr) > 0) or (pos('SNOMED', narr) > 0) then
     151      sct := piece(piece(piece(narr, ')', 1), '(', 2), ' ', 2)
     152    else
     153      sct := '';
     154    narr := TrimRight(piece(narr, '(',1));
     155    if pos(diagnosis.Code, code) > 0 then
     156    begin
     157      result := true;
     158      break;
     159    end
     160    else if (sct <> '') and (pos(sct, diagnosis.Narrative) > 0) then
     161    begin
     162      result := true;
     163      break;
     164    end
     165    else if pos(narr, diagnosis.Narrative) > 0 then
     166    begin
     167      result := true;
     168      break;
     169    end;
     170  end;
     171end;
     172
     173function TfrmDiagnoses.isEncounterDx(problem: string): Boolean;
     174var
     175  i: integer;
     176  dx, code, narr, pCode, pNarrative, sct: String;
     177
     178function getSCT(narr: string): string;
     179begin
     180  if (pos('SNOMED CT ', narr) > 0) then
     181    result := copy(narr, pos('SNOMED CT ', narr) + 10, length(narr))
     182  else
     183    result := '';
     184end;
     185
     186begin
     187  result := false;
     188  pCode := piece(problem, U, 1);
     189  pNarrative := piece(problem, U, 2);
     190  for i := 0 to lbGrid.Items.Count - 1 do
     191  begin
     192    dx := lbGrid.Items[i];
     193    narr := piece(dx, U, 3);
     194    code := piece(piece(copy(narr, pos('ICD-9-CM', narr), length(narr)), ' ', 2), ')', 1);
     195    sct := getSCT(piece(narr, ':', 1));
     196    if pos(pCode, narr) > 0 then
     197    begin
     198      result := true;
     199      break;
     200    end
     201    else if (sct <> '') and (pos(sct, pNarrative) > 0) then
     202    begin
     203      result := true;
     204      break;
     205    end
     206    else if pos(narr, pNarrative) > 0 then
     207    begin
     208      result := true;
     209      break;
     210    end;
     211  end;
    132212end;
    133213
     
    149229      if OK then
    150230        for k := 0 to lbGrid.Items.Count - 1 do
    151           if (lbGrid.Selected[k]) and (TPCEDiag(lbGrid.Items.Objects[k]).Category = PL_ITEMS) then
    152             PLItemCount := PLItemCount + 1;
     231        begin
     232          if (lbGrid.Selected[k]) then
     233          begin
     234            if (TPCEDiag(lbGrid.Items.Objects[k]).Category = PL_ITEMS) or isProblem(TPCEDiag(lbGrid.Items.Objects[k])) then
     235              PLItemCount := PLItemCount + 1;
     236          end;
     237        end;
    153238      OK := OK and (PLItemCount < lbGrid.SelCount);
    154239      ckbDiagProb.Enabled := OK;
     
    180265begin
    181266  inherited;
    182   if lbxSection.width = 0 then Exit;
    183   FSectionTabs[0] := -(lbxSection.width - LBCheckWidthSpace - (8*MainFontWidth) - ScrollBarWidth);
     267  FSectionTabs[0] := -(lbxSection.width - LBCheckWidthSpace - (10 * MainFontWidth) - ScrollBarWidth);
    184268  FSectionTabs[1] := -FSectionTabs[0]+2;
    185269  FSectionTabs[2] := -FSectionTabs[0]+4;
     
    190274  Index: Integer);
    191275begin
    192   if not FUpdatingGrid then
    193     if (lbxSection.Checked[Index]) and (Piece(lbxSection.Items[Index], U, 5) = '#') then
    194       begin
    195         InfoBox(TX_INACTIVE_CODE, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK);
    196         lbxSection.Checked[Index] := False;
    197         exit;
    198       end;
     276  if (not FUpdatingGrid) and (lbxSection.Checked[Index]) then
     277  begin
     278    if (Piece(lbxSection.Items[Index], U, 5) = '#') then
     279    begin
     280      InfoBox(TX_INACTIVE_CODE, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK);
     281      lbxSection.Checked[Index] := False;
     282      exit;
     283    end
     284    else if isEncounterDx(lbxSection.Items[Index]) then
     285    begin
     286      InfoBox(TX_REDUNDANT_DX, TC_REDUNDANT_DX + piece(lbxSection.Items[Index], '^',2),
     287        MB_ICONWARNING or MB_OK);
     288      lbxSection.Checked[Index] := False;
     289      exit;
     290    end;
     291  end;
    199292  inherited;
    200293  EnsurePrimaryDiag;
     
    220313  ADiagnosis: TPCEItem;
    221314begin
    222    inherited;
     315  inherited;
    223316  UBAGlobals.BAPCEDiagList.Clear;
    224317  with lbGrid do for i := 0 to Items.Count - 1 do
Note: See TracChangeset for help on using the changeset viewer.