| [459] | 1 | unit fDiagnoses; | 
|---|
|  | 2 |  | 
|---|
|  | 3 | interface | 
|---|
|  | 4 |  | 
|---|
|  | 5 | uses | 
|---|
|  | 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, | 
|---|
|  | 7 | fPCEBase, StdCtrls, CheckLst, ORCtrls, ORNet, ExtCtrls, Buttons, uPCE, rPCE, ORFn, | 
|---|
|  | 8 | ComCtrls, fPCEBaseMain, UBAGlobals, UBAConst, UCore; | 
|---|
|  | 9 |  | 
|---|
|  | 10 | type | 
|---|
|  | 11 | TfrmDiagnoses = class(TfrmPCEBaseMain) | 
|---|
|  | 12 | cmdDiagPrimary: TButton; | 
|---|
|  | 13 | ckbDiagProb: TCheckBox; | 
|---|
|  | 14 | lblAdd2PL: TLabel; | 
|---|
|  | 15 | procedure cmdDiagPrimaryClick(Sender: TObject); | 
|---|
|  | 16 | procedure ckbDiagProbClicked(Sender: TObject); | 
|---|
|  | 17 | procedure FormCreate(Sender: TObject); | 
|---|
|  | 18 | procedure btnRemoveClick(Sender: TObject); | 
|---|
|  | 19 | procedure FormResize(Sender: TObject); override; | 
|---|
|  | 20 | procedure lbxSectionClickCheck(Sender: TObject; Index: Integer); | 
|---|
|  | 21 | procedure btnOKClick(Sender: TObject);  override; | 
|---|
|  | 22 | procedure lbSectionClick(Sender: TObject); | 
|---|
|  | 23 | procedure GetEncounterDiagnoses; | 
|---|
|  | 24 | procedure lbSectionDrawItem(Control: TWinControl; Index: Integer; | 
|---|
|  | 25 | Rect: TRect; State: TOwnerDrawState); | 
|---|
|  | 26 | private | 
|---|
|  | 27 | procedure EnsurePrimaryDiag; | 
|---|
|  | 28 |  | 
|---|
|  | 29 | protected | 
|---|
|  | 30 | procedure UpdateNewItemStr(var x: string); override; | 
|---|
|  | 31 | procedure UpdateControls; override; | 
|---|
|  | 32 | public | 
|---|
|  | 33 | end; | 
|---|
|  | 34 |  | 
|---|
|  | 35 | const | 
|---|
|  | 36 | TX_INACTIVE_CODE = 'The "#" character next to the code for this problem indicates that the problem' + #13#10 + | 
|---|
|  | 37 | 'references an ICD code that is not active as of the date of this encounter.' + #13#10 + | 
|---|
|  | 38 | 'Before you can select this problem, you must update the ICD code it contains' + #13#10 + | 
|---|
|  | 39 | 'via the Problems tab.'; | 
|---|
|  | 40 | TC_INACTIVE_CODE = 'Problem Contains Inactive Code'; | 
|---|
|  | 41 |  | 
|---|
|  | 42 | var | 
|---|
|  | 43 | frmDiagnoses: TfrmDiagnoses; | 
|---|
|  | 44 | dxList : TStringList; | 
|---|
|  | 45 |  | 
|---|
|  | 46 | implementation | 
|---|
|  | 47 |  | 
|---|
|  | 48 | {$R *.DFM} | 
|---|
|  | 49 |  | 
|---|
|  | 50 | uses | 
|---|
|  | 51 | fEncounterFrame, uConst, UBACore; | 
|---|
|  | 52 |  | 
|---|
|  | 53 | procedure TfrmDiagnoses.EnsurePrimaryDiag; | 
|---|
|  | 54 | var | 
|---|
|  | 55 | i: Integer; | 
|---|
|  | 56 | Primary: Boolean; | 
|---|
|  | 57 |  | 
|---|
|  | 58 | begin | 
|---|
|  | 59 | with lbGrid do | 
|---|
|  | 60 | begin | 
|---|
|  | 61 | Primary := False; | 
|---|
|  | 62 | for i := 0 to Items.Count - 1 do | 
|---|
|  | 63 | if TPCEDiag(Items.Objects[i]).Primary then | 
|---|
|  | 64 | Primary := True; | 
|---|
|  | 65 |  | 
|---|
|  | 66 | if not Primary and (Items.Count > 0) then | 
|---|
|  | 67 | begin | 
|---|
|  | 68 | GridIndex := 0; | 
|---|
|  | 69 | TPCEDiag(Items.Objects[0]).Primary := True; | 
|---|
|  | 70 | GridChanged; | 
|---|
|  | 71 | end; | 
|---|
|  | 72 | end; | 
|---|
|  | 73 | end; | 
|---|
|  | 74 |  | 
|---|
|  | 75 | procedure TfrmDiagnoses.cmdDiagPrimaryClick(Sender: TObject); | 
|---|
|  | 76 | var | 
|---|
|  | 77 | gi, i: Integer; | 
|---|
|  | 78 | ADiagnosis: TPCEDiag; | 
|---|
|  | 79 |  | 
|---|
|  | 80 | begin | 
|---|
|  | 81 | inherited; | 
|---|
|  | 82 | gi := GridIndex; | 
|---|
|  | 83 | with lbGrid do for i := 0 to Items.Count - 1 do | 
|---|
|  | 84 | begin | 
|---|
|  | 85 | ADiagnosis := TPCEDiag(Items.Objects[i]); | 
|---|
|  | 86 | ADiagnosis.Primary := (gi = i); | 
|---|
|  | 87 | end; | 
|---|
|  | 88 | GridChanged; | 
|---|
|  | 89 | end; | 
|---|
|  | 90 |  | 
|---|
|  | 91 | procedure TfrmDiagnoses.ckbDiagProbClicked(Sender: TObject); | 
|---|
|  | 92 | var | 
|---|
|  | 93 | i: integer; | 
|---|
|  | 94 | const | 
|---|
|  | 95 | PL_ITEMS = 'Problem List Items'; | 
|---|
|  | 96 |  | 
|---|
|  | 97 | begin | 
|---|
|  | 98 | inherited; | 
|---|
|  | 99 | if(NotUpdating) then | 
|---|
|  | 100 | begin | 
|---|
|  | 101 | for i := 0 to lbGrid.Items.Count-1 do | 
|---|
|  | 102 | if(lbGrid.Selected[i]) then | 
|---|
|  | 103 | TPCEDiag(lbGrid.Items.Objects[i]).AddProb := (ckbDiagProb.Checked) and | 
|---|
|  | 104 | (TPCEDiag(lbGrid.Items.Objects[i]).Category <> PL_ITEMS); | 
|---|
|  | 105 | GridChanged; | 
|---|
|  | 106 | end; | 
|---|
|  | 107 | end; | 
|---|
|  | 108 |  | 
|---|
|  | 109 | procedure TfrmDiagnoses.FormCreate(Sender: TObject); | 
|---|
|  | 110 | begin | 
|---|
|  | 111 | inherited; | 
|---|
|  | 112 | FTabName := CT_DiagNm; | 
|---|
|  | 113 | FPCEListCodesProc := ListDiagnosisCodes; | 
|---|
|  | 114 | FPCEItemClass := TPCEDiag; | 
|---|
|  | 115 | FPCECode := 'POV'; | 
|---|
|  | 116 | FSectionTabCount := 3; | 
|---|
|  | 117 | FormResize(Self); | 
|---|
|  | 118 | end; | 
|---|
|  | 119 |  | 
|---|
|  | 120 | procedure TfrmDiagnoses.btnRemoveClick(Sender: TObject); | 
|---|
|  | 121 | begin | 
|---|
|  | 122 | inherited; | 
|---|
|  | 123 | EnsurePrimaryDiag; | 
|---|
|  | 124 | end; | 
|---|
|  | 125 |  | 
|---|
|  | 126 | procedure TfrmDiagnoses.UpdateNewItemStr(var x: string); | 
|---|
|  | 127 | begin | 
|---|
|  | 128 | inherited; | 
|---|
|  | 129 | if lbGrid.Items.Count = 0 then | 
|---|
|  | 130 | x := x + U + '1' | 
|---|
|  | 131 | else | 
|---|
|  | 132 | x := x + U + '0'; | 
|---|
|  | 133 | end; | 
|---|
|  | 134 |  | 
|---|
|  | 135 | procedure TfrmDiagnoses.UpdateControls; | 
|---|
|  | 136 | var | 
|---|
|  | 137 | i, j, k, PLItemCount: integer; | 
|---|
|  | 138 | OK: boolean; | 
|---|
|  | 139 | const | 
|---|
|  | 140 | PL_ITEMS = 'Problem List Items'; | 
|---|
|  | 141 | begin | 
|---|
|  | 142 | inherited; | 
|---|
|  | 143 | if(NotUpdating) then | 
|---|
|  | 144 | begin | 
|---|
|  | 145 | BeginUpdate; | 
|---|
|  | 146 | try | 
|---|
|  | 147 | cmdDiagPrimary.Enabled := (lbGrid.SelCount = 1); | 
|---|
|  | 148 | OK := (lbGrid.SelCount > 0); | 
|---|
|  | 149 | PLItemCount := 0; | 
|---|
|  | 150 | if OK then | 
|---|
|  | 151 | for k := 0 to lbGrid.Items.Count - 1 do | 
|---|
|  | 152 | if (lbGrid.Selected[k]) and (TPCEDiag(lbGrid.Items.Objects[k]).Category = PL_ITEMS) then | 
|---|
|  | 153 | PLItemCount := PLItemCount + 1; | 
|---|
|  | 154 | OK := OK and (PLItemCount < lbGrid.SelCount); | 
|---|
|  | 155 | lblAdd2PL.Enabled := OK; | 
|---|
|  | 156 | ckbDiagProb.Enabled := OK; | 
|---|
|  | 157 | if(OK) then | 
|---|
|  | 158 | begin | 
|---|
|  | 159 | j := 0; | 
|---|
|  | 160 | for i := 0 to lbGrid.Items.Count-1 do | 
|---|
|  | 161 | begin | 
|---|
|  | 162 | if(lbGrid.Selected[i]) and (TPCEDiag(lbGrid.Items.Objects[i]).AddProb) then | 
|---|
|  | 163 | inc(j); | 
|---|
|  | 164 | end; | 
|---|
|  | 165 | if(j = 0) then | 
|---|
|  | 166 | ckbDiagProb.Checked := FALSE | 
|---|
|  | 167 | else | 
|---|
|  | 168 | if(j < lbGrid.SelCount) then | 
|---|
|  | 169 | ckbDiagProb.State := cbGrayed | 
|---|
|  | 170 | else | 
|---|
|  | 171 | ckbDiagProb.Checked := TRUE; | 
|---|
|  | 172 | end | 
|---|
|  | 173 | else | 
|---|
|  | 174 | ckbDiagProb.Checked := FALSE; | 
|---|
|  | 175 | finally | 
|---|
|  | 176 | EndUpdate; | 
|---|
|  | 177 | end; | 
|---|
|  | 178 | end; | 
|---|
|  | 179 | end; | 
|---|
|  | 180 |  | 
|---|
|  | 181 | procedure TfrmDiagnoses.FormResize(Sender: TObject); | 
|---|
|  | 182 | begin | 
|---|
|  | 183 | inherited; | 
|---|
|  | 184 | FSectionTabs[0] := -(lbxSection.width - LBCheckWidthSpace - (8*MainFontWidth) - ScrollBarWidth); | 
|---|
|  | 185 | FSectionTabs[1] := -FSectionTabs[0]+2; | 
|---|
|  | 186 | FSectionTabs[2] := -FSectionTabs[0]+4; | 
|---|
|  | 187 | UpdateTabPos; | 
|---|
|  | 188 | end; | 
|---|
|  | 189 |  | 
|---|
|  | 190 | procedure TfrmDiagnoses.lbxSectionClickCheck(Sender: TObject; | 
|---|
|  | 191 | Index: Integer); | 
|---|
|  | 192 | begin | 
|---|
|  | 193 | if not FUpdatingGrid then | 
|---|
|  | 194 | if (lbxSection.Checked[Index]) and (Piece(lbxSection.Items[Index], U, 5) = '#') then | 
|---|
|  | 195 | begin | 
|---|
|  | 196 | InfoBox(TX_INACTIVE_CODE, TC_INACTIVE_CODE, MB_ICONWARNING or MB_OK); | 
|---|
|  | 197 | lbxSection.Checked[Index] := False; | 
|---|
|  | 198 | exit; | 
|---|
|  | 199 | end; | 
|---|
|  | 200 | inherited; | 
|---|
|  | 201 | EnsurePrimaryDiag; | 
|---|
|  | 202 | end; | 
|---|
|  | 203 |  | 
|---|
|  | 204 | procedure TfrmDiagnoses.btnOKClick(Sender: TObject); | 
|---|
|  | 205 | begin | 
|---|
|  | 206 | inherited; | 
|---|
|  | 207 | if  BILLING_AWARE then | 
|---|
|  | 208 | GetEncounterDiagnoses; | 
|---|
|  | 209 | end; | 
|---|
|  | 210 |  | 
|---|
|  | 211 | procedure TfrmDiagnoses.lbSectionClick(Sender: TObject); | 
|---|
|  | 212 | begin | 
|---|
|  | 213 | inherited; | 
|---|
|  | 214 | // | 
|---|
|  | 215 | end; | 
|---|
|  | 216 |  | 
|---|
|  | 217 | procedure TfrmDiagnoses.GetEncounterDiagnoses; | 
|---|
|  | 218 | var | 
|---|
|  | 219 | i: integer; | 
|---|
|  | 220 | dxCode, dxName: string; | 
|---|
|  | 221 | ADiagnosis: TPCEItem; | 
|---|
|  | 222 | begin | 
|---|
|  | 223 | inherited; | 
|---|
|  | 224 | UBAGlobals.BAPCEDiagList.Clear; | 
|---|
|  | 225 | with lbGrid do for i := 0 to Items.Count - 1 do | 
|---|
|  | 226 | begin | 
|---|
|  | 227 | ADiagnosis := TPCEDiag(Items.Objects[i]); | 
|---|
|  | 228 | dxCode :=  ADiagnosis.Code; | 
|---|
|  | 229 | dxName :=  ADiagnosis.Narrative; | 
|---|
|  | 230 | if BAPCEDiagList.Count = 0 then | 
|---|
|  | 231 | UBAGlobals.BAPCEDiagList.Add(U + DX_ENCOUNTER_LIST_TXT); | 
|---|
|  | 232 | UBAGlobals.BAPCEDiagList.Add(dxCode + U + dxName); | 
|---|
|  | 233 | end; | 
|---|
|  | 234 | end; | 
|---|
|  | 235 |  | 
|---|
|  | 236 |  | 
|---|
|  | 237 | procedure TfrmDiagnoses.lbSectionDrawItem(Control: TWinControl; | 
|---|
|  | 238 | Index: Integer; Rect: TRect; State: TOwnerDrawState); | 
|---|
|  | 239 | begin | 
|---|
|  | 240 | inherited; | 
|---|
|  | 241 | if (control as TListbox).items[index] = DX_PROBLEM_LIST_TXT then | 
|---|
|  | 242 | (Control as TListBox).Canvas.Font.Style := [fsBold] | 
|---|
|  | 243 | else | 
|---|
|  | 244 | if (control as Tlistbox).items[index] = DX_PERSONAL_LIST_TXT then | 
|---|
|  | 245 | (Control as TListBox).Canvas.Font.Style := [fsBold] | 
|---|
|  | 246 | else | 
|---|
|  | 247 | if (control as Tlistbox).items[index] =  DX_TODAYS_DX_LIST_TXT  then | 
|---|
|  | 248 | (Control as TListBox).Canvas.Font.Style := [fsBold] | 
|---|
|  | 249 | else | 
|---|
|  | 250 | if (control as Tlistbox).items[index] = DX_ENCOUNTER_LIST_TXT then | 
|---|
|  | 251 | (Control as TListBox).Canvas.Font.Style := [fsBold] | 
|---|
|  | 252 | else | 
|---|
|  | 253 | (Control as TListBox).Canvas.Font.Style := []; | 
|---|
|  | 254 |  | 
|---|
|  | 255 | (Control as TListBox).Canvas.TextOut(Rect.Left+2, Rect.Top+1, (Control as | 
|---|
|  | 256 | TListBox).Items[Index]); {display the text } | 
|---|
|  | 257 | end; | 
|---|
|  | 258 |  | 
|---|
|  | 259 | end. | 
|---|