| 1 | unit fODMedIV; | 
|---|
| 2 |  | 
|---|
| 3 | interface | 
|---|
| 4 |  | 
|---|
| 5 | uses | 
|---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, | 
|---|
| 7 | fODBase, Grids, StdCtrls, ORCtrls, ComCtrls, ExtCtrls, Buttons, Menus, IdGlobal; | 
|---|
| 8 |  | 
|---|
| 9 | type | 
|---|
| 10 | TfrmODMedIV = class(TfrmODBase) | 
|---|
| 11 | lblInfusionRate: TLabel; | 
|---|
| 12 | txtRate: TCaptionEdit; | 
|---|
| 13 | lblComponent: TLabel; | 
|---|
| 14 | lblAmount: TLabel; | 
|---|
| 15 | grdSelected: TCaptionStringGrid; | 
|---|
| 16 | cmdRemove: TButton; | 
|---|
| 17 | lblComments: TLabel; | 
|---|
| 18 | memComments: TCaptionMemo; | 
|---|
| 19 | txtSelected: TCaptionEdit; | 
|---|
| 20 | cboSelected: TCaptionComboBox; | 
|---|
| 21 | popDuration: TPopupMenu; | 
|---|
| 22 | popML: TMenuItem; | 
|---|
| 23 | popDays: TMenuItem; | 
|---|
| 24 | popHours: TMenuItem; | 
|---|
| 25 | popL: TMenuItem; | 
|---|
| 26 | pnlXDuration: TPanel; | 
|---|
| 27 | txtXDuration: TCaptionEdit; | 
|---|
| 28 | lblLimit: TLabel; | 
|---|
| 29 | btnXDuration: TBitBtn; | 
|---|
| 30 | pnlCombo: TPanel; | 
|---|
| 31 | cboAdditive: TORComboBox; | 
|---|
| 32 | tabFluid: TTabControl; | 
|---|
| 33 | cboSolution: TORComboBox; | 
|---|
| 34 | lblPriority: TLabel; | 
|---|
| 35 | cboPriority: TORComboBox; | 
|---|
| 36 | procedure FormCreate(Sender: TObject); | 
|---|
| 37 | procedure tabFluidChange(Sender: TObject); | 
|---|
| 38 | procedure cboAdditiveNeedData(Sender: TObject; const StartFrom: string; Direction, | 
|---|
| 39 | InsertAt: Integer); | 
|---|
| 40 | procedure cboSolutionNeedData(Sender: TObject; const StartFrom: string; Direction, | 
|---|
| 41 | InsertAt: Integer); | 
|---|
| 42 | procedure cboAdditiveMouseClick(Sender: TObject); | 
|---|
| 43 | procedure cboAdditiveExit(Sender: TObject); | 
|---|
| 44 | procedure cboSolutionMouseClick(Sender: TObject); | 
|---|
| 45 | procedure cboSolutionExit(Sender: TObject); | 
|---|
| 46 | procedure FormDestroy(Sender: TObject); | 
|---|
| 47 | procedure cmdRemoveClick(Sender: TObject); | 
|---|
| 48 | procedure FormResize(Sender: TObject); | 
|---|
| 49 | procedure txtSelectedExit(Sender: TObject); | 
|---|
| 50 | procedure cboSelectedExit(Sender: TObject); | 
|---|
| 51 | procedure ControlChange(Sender: TObject); | 
|---|
| 52 | procedure txtSelectedChange(Sender: TObject); | 
|---|
| 53 | procedure cboSelectedChange(Sender: TObject); | 
|---|
| 54 | procedure grdSelectedDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; | 
|---|
| 55 | State: TGridDrawState); | 
|---|
| 56 | procedure FormKeyDown(Sender: TObject; var Key: Word; | 
|---|
| 57 | Shift: TShiftState); | 
|---|
| 58 | procedure grdSelectedKeyPress(Sender: TObject; var Key: Char); | 
|---|
| 59 | procedure grdSelectedMouseDown(Sender: TObject; Button: TMouseButton; | 
|---|
| 60 | Shift: TShiftState; X, Y: Integer); | 
|---|
| 61 | procedure btnXDurationClick(Sender: TObject); | 
|---|
| 62 | procedure popDurationClick(Sender: TObject); | 
|---|
| 63 | procedure txtXDurationChange(Sender: TObject); | 
|---|
| 64 | procedure pnlXDurationEnter(Sender: TObject); | 
|---|
| 65 | procedure txtXDurationExit(Sender: TObject); | 
|---|
| 66 | procedure txtRateExit(Sender: TObject); | 
|---|
| 67 | private | 
|---|
| 68 | FInpatient: Boolean; | 
|---|
| 69 | procedure SetValuesFromResponses; | 
|---|
| 70 | procedure DoSetFontSize( FontSize: integer); | 
|---|
| 71 | procedure ClickOnGridCell; | 
|---|
| 72 | procedure SetLimitationControl(aValue: string); | 
|---|
| 73 | public | 
|---|
| 74 | procedure InitDialog; override; | 
|---|
| 75 | procedure SetupDialog(OrderAction: Integer; const ID: string); override; | 
|---|
| 76 | procedure Validate(var AnErrMsg: string); override; | 
|---|
| 77 | procedure SetFontSize( FontSize: integer); override; | 
|---|
| 78 | end; | 
|---|
| 79 |  | 
|---|
| 80 | var | 
|---|
| 81 | frmODMedIV: TfrmODMedIV; | 
|---|
| 82 |  | 
|---|
| 83 | implementation | 
|---|
| 84 |  | 
|---|
| 85 | {$R *.DFM} | 
|---|
| 86 |  | 
|---|
| 87 | uses ORFn, uConst, rODMeds, rODBase, uAccessibleStringGrid, fFrame; | 
|---|
| 88 |  | 
|---|
| 89 | const | 
|---|
| 90 | TX_NO_DEA     = 'Provider must have a DEA# or VA# to order this medication'; | 
|---|
| 91 | TC_NO_DEA     = 'DEA# Required'; | 
|---|
| 92 |  | 
|---|
| 93 | type | 
|---|
| 94 | TIVComponent = class | 
|---|
| 95 | private | 
|---|
| 96 | IEN: Integer; | 
|---|
| 97 | Name: string; | 
|---|
| 98 | Fluid: Char; | 
|---|
| 99 | Amount: Integer; | 
|---|
| 100 | Units: string; | 
|---|
| 101 | Volumes: string; | 
|---|
| 102 | end; | 
|---|
| 103 |  | 
|---|
| 104 | const | 
|---|
| 105 | TC_RESTRICT  = 'Ordering Restrictions'; | 
|---|
| 106 | TX_NO_BASE   = 'A solution must be selected.'; | 
|---|
| 107 | TX_NO_AMOUNT = 'A valid strength or volume must be entered for '; | 
|---|
| 108 | TX_NO_UNITS  = 'Units must be entered for '; | 
|---|
| 109 | TX_NO_RATE   = 'An infusion rate must be entered.'; | 
|---|
| 110 | TX_BAD_RATE  = 'The infusion rate must be:  # ml/hr  or  text@labels per day'; | 
|---|
| 111 |  | 
|---|
| 112 | (* | 
|---|
| 113 | { TIVComponent methods } | 
|---|
| 114 |  | 
|---|
| 115 | procedure TIVComponent.Clear; | 
|---|
| 116 | begin | 
|---|
| 117 | IEN     := 0; | 
|---|
| 118 | Name    := ''; | 
|---|
| 119 | Fluid   := #0; | 
|---|
| 120 | Amount  := 0; | 
|---|
| 121 | Units   := ''; | 
|---|
| 122 | Volumes := ''; | 
|---|
| 123 | end; | 
|---|
| 124 | *) | 
|---|
| 125 |  | 
|---|
| 126 | { Form methods } | 
|---|
| 127 |  | 
|---|
| 128 | procedure TfrmODMedIV.FormCreate(Sender: TObject); | 
|---|
| 129 | var | 
|---|
| 130 | Restriction: string; | 
|---|
| 131 | begin | 
|---|
| 132 | frmFrame.pnlVisit.Enabled := false; | 
|---|
| 133 | inherited; | 
|---|
| 134 | AllowQuickOrder := True; | 
|---|
| 135 | CheckAuthForMeds(Restriction); | 
|---|
| 136 | if Length(Restriction) > 0 then | 
|---|
| 137 | begin | 
|---|
| 138 | InfoBox(Restriction, TC_RESTRICT, MB_OK); | 
|---|
| 139 | Close; | 
|---|
| 140 | Exit; | 
|---|
| 141 | end; | 
|---|
| 142 | DoSetFontSize(MainFontSize); | 
|---|
| 143 | FillerID := 'PSIV';                            // does 'on Display' order check **KCM** | 
|---|
| 144 | StatusText('Loading Dialog Definition'); | 
|---|
| 145 | Responses.Dialog := 'PSJI OR PAT FLUID OE';    // loads formatting info | 
|---|
| 146 | StatusText('Loading Default Values'); | 
|---|
| 147 | CtrlInits.LoadDefaults(ODForIVFluids);         // ODForIVFluids returns TStrings with defaults | 
|---|
| 148 | InitDialog; | 
|---|
| 149 | TAccessibleStringGrid.WrapControl(grdSelected); | 
|---|
| 150 | end; | 
|---|
| 151 |  | 
|---|
| 152 | procedure TfrmODMedIV.FormDestroy(Sender: TObject); | 
|---|
| 153 | var | 
|---|
| 154 | i: Integer; | 
|---|
| 155 | begin | 
|---|
| 156 | TAccessibleStringGrid.UnwrapControl(grdSelected); | 
|---|
| 157 | with grdSelected do for i := 0 to RowCount - 1 do TIVComponent(Objects[0, i]).Free; | 
|---|
| 158 | inherited; | 
|---|
| 159 | frmFrame.pnlVisit.Enabled := True; | 
|---|
| 160 | end; | 
|---|
| 161 |  | 
|---|
| 162 | procedure TfrmODMedIV.FormResize(Sender: TObject); | 
|---|
| 163 | begin | 
|---|
| 164 | inherited; | 
|---|
| 165 | with grdSelected do | 
|---|
| 166 | begin | 
|---|
| 167 | ColWidths[1] := Canvas.TextWidth(' 10000 ') + GetSystemMetrics(SM_CXVSCROLL); | 
|---|
| 168 | ColWidths[2] := Canvas.TextWidth('meq.') + GetSystemMetrics(SM_CXVSCROLL); | 
|---|
| 169 | ColWidths[0] := ClientWidth - ColWidths[1] - ColWidths[2] - 4; | 
|---|
| 170 | end; | 
|---|
| 171 | lblAmount.Left := grdSelected.Left + grdSelected.ColWidths[0]; | 
|---|
| 172 | end; | 
|---|
| 173 |  | 
|---|
| 174 | { TfrmODBase overrides } | 
|---|
| 175 |  | 
|---|
| 176 | procedure TfrmODMedIV.InitDialog; | 
|---|
| 177 | const | 
|---|
| 178 | NOSELECTION: TGridRect = (Left: -1; Top: -1; Right: -1; Bottom: -1); | 
|---|
| 179 | var | 
|---|
| 180 | i: Integer; | 
|---|
| 181 | begin | 
|---|
| 182 | inherited; | 
|---|
| 183 | //grdSelected.Selection := NOSELECTION; | 
|---|
| 184 | with grdSelected do for i := 0 to RowCount - 1 do | 
|---|
| 185 | begin | 
|---|
| 186 | TIVComponent(Objects[0, i]).Free; | 
|---|
| 187 | Rows[i].Clear; | 
|---|
| 188 | end; | 
|---|
| 189 | grdSelected.RowCount := 1; | 
|---|
| 190 | //txtRate.Text := ' ml/hr';   {*kcm*} | 
|---|
| 191 | with CtrlInits do | 
|---|
| 192 | begin | 
|---|
| 193 | SetControl(cboSolution, 'ShortList'); | 
|---|
| 194 | cboSolution.InsertSeparator; | 
|---|
| 195 | SetControl(cboPriority, 'Priorities'); | 
|---|
| 196 | end; | 
|---|
| 197 | tabFluid.TabIndex := 0; | 
|---|
| 198 | tabFluidChange(Self);            // this makes cboSolution visible | 
|---|
| 199 | cboSolution.InitLongList(''); | 
|---|
| 200 | cboAdditive.InitLongList(''); | 
|---|
| 201 | ActiveControl := cboSolution;  //SetFocusedControl(cboSolution); | 
|---|
| 202 | StatusText(''); | 
|---|
| 203 | end; | 
|---|
| 204 |  | 
|---|
| 205 | procedure TfrmODMedIV.Validate(var AnErrMsg: string); | 
|---|
| 206 | var | 
|---|
| 207 | ItemOK: Boolean; | 
|---|
| 208 | x: string; | 
|---|
| 209 | i: Integer; | 
|---|
| 210 |  | 
|---|
| 211 | procedure SetError(const x: string); | 
|---|
| 212 | begin | 
|---|
| 213 | if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF; | 
|---|
| 214 | AnErrMsg := AnErrMsg + x; | 
|---|
| 215 | end; | 
|---|
| 216 |  | 
|---|
| 217 | begin | 
|---|
| 218 | inherited; | 
|---|
| 219 | with grdSelected do | 
|---|
| 220 | begin | 
|---|
| 221 | ItemOK := False; | 
|---|
| 222 | for i := 0 to RowCount - 1 do | 
|---|
| 223 | if TIVComponent(Objects[0, i]).Fluid = 'B' then ItemOK := True; | 
|---|
| 224 | if not ItemOK then SetError(TX_NO_BASE); | 
|---|
| 225 | for i := 0 to RowCount - 1 do | 
|---|
| 226 | begin | 
|---|
| 227 | if (Objects[0, i] <> nil) and ((Length(Cells[1, i]) = 0) or (StrToFloat(Cells[1,i])=0)) | 
|---|
| 228 | then SetError(TX_NO_AMOUNT + Cells[0, i]); | 
|---|
| 229 | if (Objects[0, i] <> nil) and (Length(Cells[2, i]) = 0) | 
|---|
| 230 | then SetError(TX_NO_UNITS + Cells[0, i]); | 
|---|
| 231 | end; | 
|---|
| 232 | end; | 
|---|
| 233 | if Length(txtRate.Text) = 0 then SetError(TX_NO_RATE) else | 
|---|
| 234 | begin | 
|---|
| 235 | x := Trim(txtRate.Text); | 
|---|
| 236 | ValidateIVRate(x); | 
|---|
| 237 | if Length(x) = 0 then SetError(TX_BAD_RATE) else Responses.Update('RATE', 1, x, x); | 
|---|
| 238 | end; | 
|---|
| 239 | end; | 
|---|
| 240 |  | 
|---|
| 241 | procedure TfrmODMedIV.SetValuesFromResponses; | 
|---|
| 242 | var | 
|---|
| 243 | x: string; | 
|---|
| 244 | AnInstance: Integer; | 
|---|
| 245 | AResponse: TResponse; | 
|---|
| 246 | AnIVComponent: TIVComponent; | 
|---|
| 247 | begin | 
|---|
| 248 | Changing := True; | 
|---|
| 249 | with Responses do | 
|---|
| 250 | begin | 
|---|
| 251 | FInpatient := OrderForInpatient; | 
|---|
| 252 | AnInstance := NextInstance('ORDERABLE', 0); | 
|---|
| 253 | while AnInstance > 0 do | 
|---|
| 254 | begin | 
|---|
| 255 | AResponse := FindResponseByName('ORDERABLE', AnInstance); | 
|---|
| 256 | if AResponse <> nil then | 
|---|
| 257 | begin | 
|---|
| 258 | x := AmountsForIVFluid(StrToIntDef(AResponse.IValue, 0), 'B'); | 
|---|
| 259 | AnIVComponent := TIVComponent.Create; | 
|---|
| 260 | AnIVComponent.IEN     := StrToIntDef(AResponse.IValue, 0); | 
|---|
| 261 | if not FInpatient then | 
|---|
| 262 | begin | 
|---|
| 263 | if DEACheckFailedForIVOnOutPatient(AnIVComponent.IEN,'S') then | 
|---|
| 264 | begin | 
|---|
| 265 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 266 | cboAdditive.Text := ''; | 
|---|
| 267 | Exit; | 
|---|
| 268 | end; | 
|---|
| 269 | end else | 
|---|
| 270 | begin | 
|---|
| 271 | if DEACheckFailed(AnIVComponent.IEN, FInpatient) then | 
|---|
| 272 | begin | 
|---|
| 273 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 274 | cboAdditive.Text := ''; | 
|---|
| 275 | Exit; | 
|---|
| 276 | end; | 
|---|
| 277 | end; | 
|---|
| 278 | AnIVComponent.Name    := AResponse.EValue; | 
|---|
| 279 | AnIVComponent.Fluid   := 'B'; | 
|---|
| 280 | AnIVComponent.Amount  := StrToIntDef(Piece(x, U, 2), 0); | 
|---|
| 281 | AnIVComponent.Units   := Piece(x, U, 1); | 
|---|
| 282 | AnIVComponent.Volumes := Copy(x, Pos(U, x) + 1, Length(x)); | 
|---|
| 283 | with grdSelected do | 
|---|
| 284 | begin | 
|---|
| 285 | if Objects[0, RowCount - 1] <> nil then RowCount := RowCount + 1; | 
|---|
| 286 | Objects[0, RowCount - 1] := AnIVComponent; | 
|---|
| 287 | Cells[0, RowCount - 1] := AnIVComponent.Name; | 
|---|
| 288 | if AnIVComponent.Amount <> 0 then | 
|---|
| 289 | Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount); | 
|---|
| 290 | Cells[2, RowCount - 1] := AnIVComponent.Units; | 
|---|
| 291 | end; | 
|---|
| 292 | end; | 
|---|
| 293 | AResponse := FindResponseByName('VOLUME', AnInstance); | 
|---|
| 294 | if AResponse <> nil then with grdSelected do Cells[1, RowCount - 1] := AResponse.EValue; | 
|---|
| 295 | AnInstance := NextInstance('ORDERABLE', AnInstance); | 
|---|
| 296 | end; {while AnInstance - ORDERABLE} | 
|---|
| 297 | AnInstance := NextInstance('ADDITIVE', 0); | 
|---|
| 298 | while AnInstance > 0 do | 
|---|
| 299 | begin | 
|---|
| 300 | AResponse := FindResponseByName('ADDITIVE', AnInstance); | 
|---|
| 301 | if AResponse <> nil then | 
|---|
| 302 | begin | 
|---|
| 303 | x := AmountsForIVFluid(StrToIntDef(AResponse.IValue, 0), 'A'); | 
|---|
| 304 | AnIVComponent := TIVComponent.Create; | 
|---|
| 305 | AnIVComponent.IEN     := StrToIntDef(AResponse.IValue, 0); | 
|---|
| 306 | if not FInpatient then | 
|---|
| 307 | begin | 
|---|
| 308 | if DEACheckFailedForIVOnOutPatient(AnIVComponent.IEN,'A') then | 
|---|
| 309 | begin | 
|---|
| 310 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 311 | cboAdditive.Text := ''; | 
|---|
| 312 | Exit; | 
|---|
| 313 | end; | 
|---|
| 314 | end else | 
|---|
| 315 | begin | 
|---|
| 316 | if DEACheckFailed(AnIVComponent.IEN, FInpatient) then | 
|---|
| 317 | begin | 
|---|
| 318 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 319 | cboAdditive.Text := ''; | 
|---|
| 320 | Exit; | 
|---|
| 321 | end; | 
|---|
| 322 | end; | 
|---|
| 323 | AnIVComponent.Name    := AResponse.EValue; | 
|---|
| 324 | AnIVComponent.Fluid   := 'A'; | 
|---|
| 325 | AnIVComponent.Amount  := StrToIntDef(Piece(x, U, 2), 0); | 
|---|
| 326 | AnIVComponent.Units   := Piece(x, U, 1); | 
|---|
| 327 | AnIVComponent.Volumes := Copy(x, Pos(U, x) + 1, Length(x)); | 
|---|
| 328 | with grdSelected do | 
|---|
| 329 | begin | 
|---|
| 330 | if Objects[0, RowCount - 1] <> nil then RowCount := RowCount + 1; | 
|---|
| 331 | Objects[0, RowCount - 1] := AnIVComponent; | 
|---|
| 332 | Cells[0, RowCount - 1] := AnIVComponent.Name; | 
|---|
| 333 | if AnIVComponent.Amount <> 0 then | 
|---|
| 334 | Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount); | 
|---|
| 335 | Cells[2, RowCount - 1] := AnIVComponent.Units; | 
|---|
| 336 | end; | 
|---|
| 337 | end; | 
|---|
| 338 | AResponse := FindResponseByName('STRENGTH', AnInstance); | 
|---|
| 339 | if AResponse <> nil then with grdSelected do Cells[1, RowCount - 1] := AResponse.EValue; | 
|---|
| 340 | AResponse := FindResponseByName('UNITS', AnInstance); | 
|---|
| 341 | if AResponse <> nil then with grdSelected do Cells[2, RowCount - 1] := AResponse.EValue; | 
|---|
| 342 | AnInstance := NextInstance('ADDITIVE', AnInstance); | 
|---|
| 343 | end; {while AnInstance - ADDITIVE} | 
|---|
| 344 | SetControl(txtRate,     'RATE',    1); | 
|---|
| 345 | if LowerCase(Copy(ReverseStr(txtRate.Text), 1, 6)) = 'rh/lm '             {*kcm*} | 
|---|
| 346 | then txtRate.Text := Copy(txtRate.Text, 1, Length(txtRate.Text) - 6); | 
|---|
| 347 | SetControl(cboPriority, 'URGENCY', 1); | 
|---|
| 348 | SetControl(memComments, 'COMMENT', 1); | 
|---|
| 349 |  | 
|---|
| 350 | AnInstance := NextInstance('DAYS', 0); | 
|---|
| 351 | if AnInstance > 0 then | 
|---|
| 352 | begin | 
|---|
| 353 | AResponse := FindResponseByName('DAYS', AnInstance); | 
|---|
| 354 | if AResponse <> nil then | 
|---|
| 355 | SetLimitationControl(AResponse.EValue); | 
|---|
| 356 | end; | 
|---|
| 357 | end; {if...with Responses} | 
|---|
| 358 | Changing := False; | 
|---|
| 359 | ControlChange(Self); | 
|---|
| 360 | end; | 
|---|
| 361 |  | 
|---|
| 362 | procedure TfrmODMedIV.SetupDialog(OrderAction: Integer; const ID: string); | 
|---|
| 363 | begin | 
|---|
| 364 | inherited; | 
|---|
| 365 | if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then SetValuesFromResponses; | 
|---|
| 366 | end; | 
|---|
| 367 |  | 
|---|
| 368 | { tabFluid events } | 
|---|
| 369 |  | 
|---|
| 370 | procedure TfrmODMedIV.tabFluidChange(Sender: TObject); | 
|---|
| 371 | begin | 
|---|
| 372 | inherited; | 
|---|
| 373 | case TabFluid.TabIndex of | 
|---|
| 374 | 0: begin | 
|---|
| 375 | cboSolution.Visible := True; | 
|---|
| 376 | cboAdditive.Visible := False; | 
|---|
| 377 | end; | 
|---|
| 378 | 1: begin | 
|---|
| 379 | cboAdditive.Visible := True; | 
|---|
| 380 | cboSolution.Visible := False; | 
|---|
| 381 | end; | 
|---|
| 382 | end; | 
|---|
| 383 | if cboSolution.Visible then | 
|---|
| 384 | ActiveControl := cboSolution; | 
|---|
| 385 | if cboAdditive.Visible then | 
|---|
| 386 | ActiveControl := cboAdditive; | 
|---|
| 387 | end; | 
|---|
| 388 |  | 
|---|
| 389 | { cboSolution events } | 
|---|
| 390 |  | 
|---|
| 391 | procedure TfrmODMedIV.cboSolutionNeedData(Sender: TObject; const StartFrom: string; | 
|---|
| 392 | Direction, InsertAt: Integer); | 
|---|
| 393 | var | 
|---|
| 394 | CurString: string; | 
|---|
| 395 | begin | 
|---|
| 396 | inherited; | 
|---|
| 397 | if (Direction = 1) then | 
|---|
| 398 | CurString := AnsiUpperCase(StartFrom) + '          '; | 
|---|
| 399 | cboSolution.ForDataUse(SubSetOfOrderItems(CurString, Direction, 'S.IVB RX')); | 
|---|
| 400 | end; | 
|---|
| 401 |  | 
|---|
| 402 | procedure TfrmODMedIV.cboSolutionMouseClick(Sender: TObject); | 
|---|
| 403 | var | 
|---|
| 404 | AnIVComponent: TIVComponent; | 
|---|
| 405 | x: string; | 
|---|
| 406 | begin | 
|---|
| 407 | inherited; | 
|---|
| 408 | if CharAt(cboSolution.ItemID, 1) = 'Q' then              // setup quick order | 
|---|
| 409 | begin | 
|---|
| 410 | Responses.QuickOrder := ExtractInteger(cboSolution.ItemID); | 
|---|
| 411 | SetValuesFromResponses; | 
|---|
| 412 | cboSolution.ItemIndex := -1; | 
|---|
| 413 | Exit; | 
|---|
| 414 | end; | 
|---|
| 415 | if cboSolution.ItemIEN <= 0 then Exit;                   // process selection of solution | 
|---|
| 416 | FInpatient := OrderForInpatient; | 
|---|
| 417 | if not FInpatient then | 
|---|
| 418 | begin | 
|---|
| 419 | if DEACheckFailedForIVOnOutPatient(cboSolution.ItemIEN,'S') then | 
|---|
| 420 | begin | 
|---|
| 421 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 422 | cboSolution.Text := ''; | 
|---|
| 423 | Exit; | 
|---|
| 424 | end; | 
|---|
| 425 | end else | 
|---|
| 426 | begin | 
|---|
| 427 | if DEACheckFailed(cboSolution.ItemIEN, FInpatient) then | 
|---|
| 428 | begin | 
|---|
| 429 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 430 | cboSolution.Text := ''; | 
|---|
| 431 | Exit; | 
|---|
| 432 | end; | 
|---|
| 433 | end; | 
|---|
| 434 |  | 
|---|
| 435 | x := AmountsForIVFluid(cboSolution.ItemIEN, 'B'); | 
|---|
| 436 | AnIVComponent := TIVComponent.Create; | 
|---|
| 437 | AnIVComponent.IEN     := cboSolution.ItemIEN; | 
|---|
| 438 | AnIVComponent.Name    := Piece(cboSolution.Items[cboSolution.ItemIndex], U, 3); | 
|---|
| 439 | AnIVComponent.Fluid   := 'B'; | 
|---|
| 440 | AnIVComponent.Amount  := StrToIntDef(Piece(x, U, 2), 0); | 
|---|
| 441 | AnIVComponent.Units   := Piece(x, U, 1); | 
|---|
| 442 | AnIVComponent.Volumes := Copy(x, Pos(U, x) + 1, Length(x)); | 
|---|
| 443 | cboSolution.ItemIndex := -1; | 
|---|
| 444 | with grdSelected do | 
|---|
| 445 | begin | 
|---|
| 446 | if Objects[0, RowCount - 1] <> nil then RowCount := RowCount + 1; | 
|---|
| 447 | Objects[0, RowCount - 1] := AnIVComponent; | 
|---|
| 448 | Cells[0, RowCount - 1] := AnIVComponent.Name; | 
|---|
| 449 | Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount); | 
|---|
| 450 | Cells[2, RowCount - 1] := AnIVComponent.Units; | 
|---|
| 451 | Row := RowCount - 1; | 
|---|
| 452 | if Length(Piece(AnIVComponent.Volumes, U, 2)) > 0 then Col := 1 else Col := 0; | 
|---|
| 453 | if RowCount = 1 then        // switch to additives after 1st IV | 
|---|
| 454 | begin | 
|---|
| 455 | tabFluid.TabIndex := 1; | 
|---|
| 456 | tabFluidChange(Self); | 
|---|
| 457 | end; | 
|---|
| 458 | end; | 
|---|
| 459 | Application.ProcessMessages;         //CQ: 10157 | 
|---|
| 460 | ClickOnGridCell; | 
|---|
| 461 | ControlChange(Sender); | 
|---|
| 462 | end; | 
|---|
| 463 |  | 
|---|
| 464 | procedure TfrmODMedIV.cboSolutionExit(Sender: TObject); | 
|---|
| 465 | begin | 
|---|
| 466 | inherited; | 
|---|
| 467 | if cboSolution.ItemIEN > 0 then cboSolutionMouseClick(Self); | 
|---|
| 468 | end; | 
|---|
| 469 |  | 
|---|
| 470 | { cboAdditive events } | 
|---|
| 471 |  | 
|---|
| 472 | procedure TfrmODMedIV.cboAdditiveNeedData(Sender: TObject; const StartFrom: string; | 
|---|
| 473 | Direction, InsertAt: Integer); | 
|---|
| 474 | var | 
|---|
| 475 | CurString: string; | 
|---|
| 476 | begin | 
|---|
| 477 | inherited; | 
|---|
| 478 | if (Direction = 1) then | 
|---|
| 479 | CurString := AnsiUpperCase(StartFrom) + '          '; | 
|---|
| 480 | cboAdditive.ForDataUse(SubSetOfOrderItems(CurString, Direction, 'S.IVA RX')); | 
|---|
| 481 | end; | 
|---|
| 482 |  | 
|---|
| 483 | procedure TfrmODMedIV.cboAdditiveMouseClick(Sender: TObject); | 
|---|
| 484 | var | 
|---|
| 485 | AnIVComponent: TIVComponent; | 
|---|
| 486 | x: string; | 
|---|
| 487 | begin | 
|---|
| 488 | inherited; | 
|---|
| 489 | if cboAdditive.ItemIEN <= 0 then Exit; | 
|---|
| 490 | FInpatient := OrderForInpatient; | 
|---|
| 491 | if not FInpatient then | 
|---|
| 492 | begin | 
|---|
| 493 | if DEACheckFailedForIVOnOutPatient(cboAdditive.ItemIEN,'A') then | 
|---|
| 494 | begin | 
|---|
| 495 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 496 | cboAdditive.Text := ''; | 
|---|
| 497 | Exit; | 
|---|
| 498 | end; | 
|---|
| 499 | end else | 
|---|
| 500 | begin | 
|---|
| 501 | if DEACheckFailed(cboAdditive.ItemIEN, FInpatient) then | 
|---|
| 502 | begin | 
|---|
| 503 | InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK); | 
|---|
| 504 | cboAdditive.Text := ''; | 
|---|
| 505 | Exit; | 
|---|
| 506 | end; | 
|---|
| 507 | end; | 
|---|
| 508 | x := AmountsForIVFluid(cboAdditive.ItemIEN, 'A'); | 
|---|
| 509 | AnIVComponent := TIVComponent.Create; | 
|---|
| 510 | AnIVComponent.IEN     := cboAdditive.ItemIEN; | 
|---|
| 511 | AnIVComponent.Name    := Piece(cboAdditive.Items[cboAdditive.ItemIndex], U, 3); | 
|---|
| 512 | AnIVComponent.Fluid   := 'A'; | 
|---|
| 513 | AnIVComponent.Amount  := 0; | 
|---|
| 514 | AnIVComponent.Units   := Piece(x, U, 1); | 
|---|
| 515 | AnIVComponent.Volumes := ''; | 
|---|
| 516 | cboAdditive.ItemIndex := -1; | 
|---|
| 517 | with grdSelected do | 
|---|
| 518 | begin | 
|---|
| 519 | if Objects[0, RowCount - 1] <> nil then RowCount := RowCount + 1; | 
|---|
| 520 | Objects[0, RowCount - 1] := AnIVComponent; | 
|---|
| 521 | Cells[0, RowCount - 1] := AnIVComponent.Name; | 
|---|
| 522 | Cells[2, RowCount - 1] := AnIVComponent.Units; | 
|---|
| 523 | Row := RowCount - 1; | 
|---|
| 524 | Col := 1; | 
|---|
| 525 | end; | 
|---|
| 526 | Application.ProcessMessages;         //CQ: 10157 | 
|---|
| 527 | ClickOnGridCell; | 
|---|
| 528 | ControlChange(Sender); | 
|---|
| 529 | end; | 
|---|
| 530 |  | 
|---|
| 531 | procedure TfrmODMedIV.cboAdditiveExit(Sender: TObject); | 
|---|
| 532 | begin | 
|---|
| 533 | inherited; | 
|---|
| 534 | if cboAdditive.ItemIEN > 0 then cboAdditiveMouseClick(Self); | 
|---|
| 535 | end; | 
|---|
| 536 |  | 
|---|
| 537 | { grdSelected events } | 
|---|
| 538 |  | 
|---|
| 539 | procedure TfrmODMedIV.ClickOnGridCell; | 
|---|
| 540 | var | 
|---|
| 541 | AnIVComponent: TIVComponent; | 
|---|
| 542 |  | 
|---|
| 543 | procedure PlaceControl(AControl: TWinControl); | 
|---|
| 544 | var | 
|---|
| 545 | ARect: TRect; | 
|---|
| 546 | begin | 
|---|
| 547 | with AControl do | 
|---|
| 548 | begin | 
|---|
| 549 | ARect := grdSelected.CellRect(grdSelected.Col, grdSelected.Row); | 
|---|
| 550 | SetBounds(ARect.Left + grdSelected.Left + 1,  ARect.Top  + grdSelected.Top + 1, | 
|---|
| 551 | ARect.Right - ARect.Left + 1,       ARect.Bottom - ARect.Top + 1); | 
|---|
| 552 | BringToFront; | 
|---|
| 553 | Show; | 
|---|
| 554 | SetFocus; | 
|---|
| 555 | if AControl is TComboBox then                    //CQ: 10157 | 
|---|
| 556 | TComboBox(AControl).DroppedDown := True; | 
|---|
| 557 | end; | 
|---|
| 558 | end; | 
|---|
| 559 |  | 
|---|
| 560 | begin | 
|---|
| 561 | AnIVComponent := TIVComponent(grdSelected.Objects[0, grdSelected.Row]); | 
|---|
| 562 | if (AnIVComponent = nil) or (grdSelected.Col = 0) then Exit; | 
|---|
| 563 | // allow selection if more the 1 unit to choose from | 
|---|
| 564 | if (grdSelected.Col = 2) and (Length(Piece(AnIVComponent.Units, U, 2)) > 0) then | 
|---|
| 565 | begin | 
|---|
| 566 | PiecesToList(AnIVComponent.Units, U, cboSelected.Items); | 
|---|
| 567 | cboSelected.ItemIndex := cboSelected.Items.IndexOf(grdSelected.Cells[grdSelected.Col, grdSelected.Row]); | 
|---|
| 568 | cboSelected.Tag  := (grdSelected.Col * 256) + grdSelected.Row; | 
|---|
| 569 | PlaceControl(cboSelected); | 
|---|
| 570 | end; | 
|---|
| 571 | // allow selection if more than 1 volume to choose from | 
|---|
| 572 | if (grdSelected.Col = 1) and (Length(Piece(AnIVComponent.Volumes, U, 2)) > 0) then | 
|---|
| 573 | begin | 
|---|
| 574 | PiecesToList(AnIVComponent.Volumes, U, cboSelected.Items); | 
|---|
| 575 | cboSelected.ItemIndex := cboSelected.Items.IndexOf(grdSelected.Cells[grdSelected.Col, grdSelected.Row]); | 
|---|
| 576 | cboSelected.Tag  := (grdSelected.Col * 256) + grdSelected.Row; | 
|---|
| 577 | PlaceControl(cboSelected); | 
|---|
| 578 | end; | 
|---|
| 579 | // display text box to enter strength if the entry is an additive | 
|---|
| 580 | if (grdSelected.Col = 1) and (AnIVComponent.Fluid = 'A') then | 
|---|
| 581 | begin | 
|---|
| 582 | txtSelected.Text := grdSelected.Cells[grdSelected.Col, grdSelected.Row]; | 
|---|
| 583 | txtSelected.Tag  := (grdSelected.Col * 256) + grdSelected.Row; | 
|---|
| 584 | PlaceControl(txtSelected); | 
|---|
| 585 | end; | 
|---|
| 586 | end; | 
|---|
| 587 |  | 
|---|
| 588 | procedure TfrmODMedIV.txtSelectedChange(Sender: TObject);   // text editor for grid | 
|---|
| 589 | begin | 
|---|
| 590 | inherited; | 
|---|
| 591 | with txtSelected do | 
|---|
| 592 | begin | 
|---|
| 593 | if Tag < 0 then Exit; | 
|---|
| 594 | grdSelected.Cells[Tag div 256, Tag mod 256] := Text; | 
|---|
| 595 | end; | 
|---|
| 596 | ControlChange(Sender); | 
|---|
| 597 | end; | 
|---|
| 598 |  | 
|---|
| 599 | procedure TfrmODMedIV.txtSelectedExit(Sender: TObject); | 
|---|
| 600 | begin | 
|---|
| 601 | inherited; | 
|---|
| 602 | with txtSelected do | 
|---|
| 603 | begin | 
|---|
| 604 | grdSelected.Cells[Tag div 256, Tag mod 256] := Text; | 
|---|
| 605 | Tag := -1; | 
|---|
| 606 | Hide; | 
|---|
| 607 | end; | 
|---|
| 608 | end; | 
|---|
| 609 |  | 
|---|
| 610 | procedure TfrmODMedIV.cboSelectedChange(Sender: TObject);   // combo editor for grid | 
|---|
| 611 | begin | 
|---|
| 612 | inherited; | 
|---|
| 613 | with cboSelected do | 
|---|
| 614 | begin | 
|---|
| 615 | if Tag < 0 then Exit; | 
|---|
| 616 | grdSelected.Cells[Tag div 256, Tag mod 256] := Text; | 
|---|
| 617 | end; | 
|---|
| 618 | ControlChange(Sender); | 
|---|
| 619 | end; | 
|---|
| 620 |  | 
|---|
| 621 | procedure TfrmODMedIV.cboSelectedExit(Sender: TObject); | 
|---|
| 622 | begin | 
|---|
| 623 | inherited; | 
|---|
| 624 | with cboSelected do | 
|---|
| 625 | begin | 
|---|
| 626 | grdSelected.Cells[Tag div 256, Tag mod 256] := Text; | 
|---|
| 627 | Tag := -1; | 
|---|
| 628 | Hide; | 
|---|
| 629 | end; | 
|---|
| 630 | end; | 
|---|
| 631 |  | 
|---|
| 632 | procedure TfrmODMedIV.cmdRemoveClick(Sender: TObject);  // remove button for grid | 
|---|
| 633 | var | 
|---|
| 634 | i: Integer; | 
|---|
| 635 | begin | 
|---|
| 636 | inherited; | 
|---|
| 637 | with grdSelected do | 
|---|
| 638 | begin | 
|---|
| 639 | if Row < 0 then Exit; | 
|---|
| 640 | if Objects[0, Row] <> nil then TIVComponent(Objects[0, Row]).Free; | 
|---|
| 641 | for i := Row to RowCount - 2 do Rows[i] := Rows[i + 1]; | 
|---|
| 642 | Rows[RowCount - 1].Clear; | 
|---|
| 643 | RowCount := RowCount - 1; | 
|---|
| 644 | end; | 
|---|
| 645 | ControlChange(Sender); | 
|---|
| 646 | end; | 
|---|
| 647 |  | 
|---|
| 648 | { update Responses & Create Order Text } | 
|---|
| 649 |  | 
|---|
| 650 | procedure TfrmODMedIV.ControlChange(Sender: TObject); | 
|---|
| 651 | var | 
|---|
| 652 | i, CurAdd, CurBase: Integer; | 
|---|
| 653 | x,xlimIn,xLimEx,eSch,iSch: string; | 
|---|
| 654 | AnIVComponent: TIVComponent; | 
|---|
| 655 | FQOSchedule: TResponse; | 
|---|
| 656 |  | 
|---|
| 657 | function IsNumericRate(const x: string): Boolean; | 
|---|
| 658 | var | 
|---|
| 659 | i: Integer; | 
|---|
| 660 | begin | 
|---|
| 661 | Result := True; | 
|---|
| 662 | for i := 1 to Length(x) do if not (x[i] in ['0'..'9','.']) then Result := False; | 
|---|
| 663 | end; | 
|---|
| 664 |  | 
|---|
| 665 | begin | 
|---|
| 666 | inherited; | 
|---|
| 667 | if Changing then Exit; | 
|---|
| 668 | //  FQOSchedule := TResponse.Create; | 
|---|
| 669 | FQOSchedule := Responses.FindResponseByName('SCHEDULE',1); | 
|---|
| 670 | if FQOSchedule <> nil then | 
|---|
| 671 | begin | 
|---|
| 672 | eSch := FQOSchedule.EValue; | 
|---|
| 673 | iSch := FQOSchedule.IValue; | 
|---|
| 674 | end; | 
|---|
| 675 | //if Sender <> Self then Responses.Clear;       // Sender=Self when called from SetupDialog | 
|---|
| 676 | Responses.Clear;   // want this to clear even after SetupDialog in case instances don't match | 
|---|
| 677 | CurAdd := 1; CurBase := 1; | 
|---|
| 678 | with grdSelected do for i := 0 to RowCount - 1 do | 
|---|
| 679 | begin | 
|---|
| 680 | AnIVComponent := TIVComponent(Objects[0, i]); | 
|---|
| 681 | if AnIVComponent = nil then Continue; | 
|---|
| 682 | with AnIVComponent do | 
|---|
| 683 | begin | 
|---|
| 684 | if Fluid = 'B' then                        // Solutions | 
|---|
| 685 | begin | 
|---|
| 686 | if IEN > 0                then Responses.Update('ORDERABLE', CurBase, IntToStr(IEN), Name); | 
|---|
| 687 | if Length(Cells[1,i]) > 0 then Responses.Update('VOLUME',    CurBase, Cells[1,i], Cells[1,i]); | 
|---|
| 688 | Inc(CurBase); | 
|---|
| 689 | end; {if Fluid B} | 
|---|
| 690 | if Fluid = 'A' then                        // Additives | 
|---|
| 691 | begin | 
|---|
| 692 | if IEN > 0                then Responses.Update('ADDITIVE', CurAdd, IntToStr(IEN), Name); | 
|---|
| 693 | if Length(Cells[1,i]) > 0 then Responses.Update('STRENGTH', CurAdd, Cells[1,i], Cells[1,i]); | 
|---|
| 694 | if Length(Cells[2,i]) > 0 then Responses.Update('UNITS',    CurAdd, Cells[2,i], Cells[2,i]); | 
|---|
| 695 | Inc(CurAdd); | 
|---|
| 696 | end; {if Fluid A} | 
|---|
| 697 | end; {with AnIVComponent} | 
|---|
| 698 | end; {with grdSelected} | 
|---|
| 699 | x := txtRate.Text; | 
|---|
| 700 | xlimIn := ''; | 
|---|
| 701 | xlimEx := ''; | 
|---|
| 702 | if length(txtXDuration.Text) > 0 then | 
|---|
| 703 | begin | 
|---|
| 704 | if (btnXDuration.Caption = 'L') or (btnXDuration.Caption = 'ml') then | 
|---|
| 705 | begin | 
|---|
| 706 | xlimEx := 'with total volume ' +  txtXDuration.Text + btnXDuration.Caption; | 
|---|
| 707 | xlimIn := 'with total volume ' +  txtXDuration.Text + btnXDuration.Caption; | 
|---|
| 708 | end | 
|---|
| 709 | else if (btnXDuration.Caption = 'days') or (btnXDuration.Caption = 'hours') then | 
|---|
| 710 | begin | 
|---|
| 711 | xlimEx := 'for ' + txtXDuration.Text + ' ' +  btnXDuration.Caption; | 
|---|
| 712 | xlimIn := 'for ' + txtXDuration.Text + ' ' +  btnXDuration.Caption; | 
|---|
| 713 | end  else | 
|---|
| 714 | begin | 
|---|
| 715 | xlimIn := ''; | 
|---|
| 716 | xlimEx := ''; | 
|---|
| 717 | end; | 
|---|
| 718 | end; | 
|---|
| 719 | //if x = IntToStr(StrToIntDef(x, -1)) then x := x + ' ml/hr'; | 
|---|
| 720 | if IsNumericRate(x) then x := x + ' ml/hr'; | 
|---|
| 721 | if (Pos('@',x)>0) and (Piece(x,'@',1) = IntToStr(StrToIntDef(Piece(x,'@',1), -1))) | 
|---|
| 722 | then x := Piece(x,'@',1) + ' ml/hr@' + Copy(x, Pos('@',x) + 1, Length(x)); | 
|---|
| 723 | with txtRate     do if (Length(Text) > 0) then Responses.Update('RATE', 1, x, x); | 
|---|
| 724 | with cboPriority do if ItemIndex > -1     then Responses.Update('URGENCY', 1, ItemID, Text); | 
|---|
| 725 | if Length(xlimIn)>0 then Responses.Update('DAYS',1, xlimIn, xlimEx); | 
|---|
| 726 | with memComments do if GetTextLen > 0     then Responses.Update('COMMENT', 1, TX_WPTYPE, Text); | 
|---|
| 727 | memOrder.Text := Responses.OrderText; | 
|---|
| 728 | if (Length(eSch)>0) or (Length(iSch)>0) then | 
|---|
| 729 | Responses.Update('SCHEDULE',1,iSch,eSch); | 
|---|
| 730 | end; | 
|---|
| 731 |  | 
|---|
| 732 | procedure TfrmODMedIV.grdSelectedDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; | 
|---|
| 733 | State: TGridDrawState); | 
|---|
| 734 | begin | 
|---|
| 735 | inherited; | 
|---|
| 736 | if Sender = ActiveControl then Exit; | 
|---|
| 737 | if not (gdSelected in State) then Exit; | 
|---|
| 738 | with Sender as TStringGrid do | 
|---|
| 739 | begin | 
|---|
| 740 | Canvas.Brush.Color := Color; | 
|---|
| 741 | Canvas.Font := Font; | 
|---|
| 742 | Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]); | 
|---|
| 743 | end; | 
|---|
| 744 | end; | 
|---|
| 745 |  | 
|---|
| 746 | procedure TfrmODMedIV.SetFontSize( FontSize: integer); | 
|---|
| 747 | begin | 
|---|
| 748 | inherited SetFontSize( FontSize ); | 
|---|
| 749 | DoSetFontSize( FontSize ); | 
|---|
| 750 | end; | 
|---|
| 751 |  | 
|---|
| 752 | procedure TfrmODMedIV.DoSetFontSize( FontSize: integer); | 
|---|
| 753 | begin | 
|---|
| 754 | tabFluid.TabHeight := Abs(Font.Height) + 4; | 
|---|
| 755 | grdSelected.DefaultRowHeight := Abs(Font.Height) + 8; | 
|---|
| 756 | end; | 
|---|
| 757 |  | 
|---|
| 758 | procedure TfrmODMedIV.FormKeyDown(Sender: TObject; var Key: Word; | 
|---|
| 759 | Shift: TShiftState); | 
|---|
| 760 | begin | 
|---|
| 761 | inherited; | 
|---|
| 762 | if (Key = VK_TAB) and (ssCtrl in Shift) then | 
|---|
| 763 | begin | 
|---|
| 764 | //Back-tab works the same as forward-tab because there are only two tabs. | 
|---|
| 765 | tabFluid.TabIndex := (tabFluid.TabIndex + 1) mod tabFluid.Tabs.Count; | 
|---|
| 766 | Key := 0; | 
|---|
| 767 | tabFluidChange(tabFluid); | 
|---|
| 768 | end; | 
|---|
| 769 | end; | 
|---|
| 770 |  | 
|---|
| 771 | procedure TfrmODMedIV.grdSelectedKeyPress(Sender: TObject; var Key: Char); | 
|---|
| 772 | begin | 
|---|
| 773 | inherited; | 
|---|
| 774 | ClickOnGridCell; | 
|---|
| 775 | end; | 
|---|
| 776 |  | 
|---|
| 777 | procedure TfrmODMedIV.grdSelectedMouseDown(Sender: TObject; | 
|---|
| 778 | Button: TMouseButton; Shift: TShiftState; X, Y: Integer); | 
|---|
| 779 | begin | 
|---|
| 780 | inherited; | 
|---|
| 781 | ClickOnGridCell; | 
|---|
| 782 | end; | 
|---|
| 783 |  | 
|---|
| 784 | procedure TfrmODMedIV.btnXDurationClick(Sender: TObject); | 
|---|
| 785 | var | 
|---|
| 786 | APoint: TPoint; | 
|---|
| 787 | begin | 
|---|
| 788 | inherited; | 
|---|
| 789 | txtXDuration.SetFocus; | 
|---|
| 790 | with TSpeedButton(Sender) do APoint := ClientToScreen(Point(0, Height)); | 
|---|
| 791 | popDuration.Popup(APoint.X, APoint.Y); | 
|---|
| 792 | end; | 
|---|
| 793 |  | 
|---|
| 794 | procedure TfrmODMedIV.popDurationClick(Sender: TObject); | 
|---|
| 795 | var | 
|---|
| 796 | x: string; | 
|---|
| 797 | begin | 
|---|
| 798 | inherited; | 
|---|
| 799 | with TMenuItem(Sender) do | 
|---|
| 800 | begin | 
|---|
| 801 | x := Caption; | 
|---|
| 802 | {if Length(Trim(txtXDuration.Text)) > 0 then | 
|---|
| 803 | if AnsiCompareStr(btnXduration.Caption,x) <> 0 then | 
|---|
| 804 | txtXDuration.Text := '';} | 
|---|
| 805 | end; | 
|---|
| 806 | btnXDuration.Caption := x; | 
|---|
| 807 | txtXDurationChange(Sender); | 
|---|
| 808 | ControlChange(Sender); | 
|---|
| 809 | end; | 
|---|
| 810 |  | 
|---|
| 811 | procedure TfrmODMedIV.txtXDurationChange(Sender: TObject); | 
|---|
| 812 | begin | 
|---|
| 813 | inherited; | 
|---|
| 814 | if Changing then Exit; | 
|---|
| 815 | ControlChange(Sender); | 
|---|
| 816 | end; | 
|---|
| 817 |  | 
|---|
| 818 | procedure TfrmODMedIV.pnlXDurationEnter(Sender: TObject); | 
|---|
| 819 | begin | 
|---|
| 820 | inherited; | 
|---|
| 821 | txtXDuration.SetFocus; | 
|---|
| 822 | end; | 
|---|
| 823 |  | 
|---|
| 824 | procedure TfrmODMedIV.SetLimitationControl(aValue: string); | 
|---|
| 825 | var | 
|---|
| 826 | limitUnit,limitValue,tempval: string; | 
|---|
| 827 | begin | 
|---|
| 828 | limitUnit  := ''; | 
|---|
| 829 | limitValue := ''; | 
|---|
| 830 | tempVal := ''; | 
|---|
| 831 | if ( CharAt(aValue,1)= 'f') or ( CharAt(aValue,1)= 'F') then  //days, hours | 
|---|
| 832 | begin | 
|---|
| 833 | limitValue := Piece(aValue,' ',2); | 
|---|
| 834 | limitUnit  := Piece(aValue,' ',3); | 
|---|
| 835 | end; | 
|---|
| 836 | if (CharAt(aValue,1)= 'w') or (CharAt(aValue,1)= 'W') then  //L, ml | 
|---|
| 837 | begin | 
|---|
| 838 | tempval  := Piece(aValue,' ',4); | 
|---|
| 839 | limitValue := FloatToStr(ExtractFloat(tempVal)); | 
|---|
| 840 | limitUnit  := Copy(tempVal,length(limitValue)+1,Length(tempVal)); | 
|---|
| 841 | end; | 
|---|
| 842 | if isNumeric(CharAt(aValue,1)) then | 
|---|
| 843 | begin | 
|---|
| 844 | limitValue := FloatToStr(ExtractFloat(aValue)); | 
|---|
| 845 | limitUnit  := Copy(aValue,length(limitValue)+1,Length(aValue)); | 
|---|
| 846 | if limitUnit = 'D' then limitUnit := 'days' | 
|---|
| 847 | else if limitUnit = 'H' then limitUnit := 'hours' | 
|---|
| 848 | else if limitUnit = 'ML' then limitUnit := 'ml'; | 
|---|
| 849 | end; | 
|---|
| 850 | if ( Length(limitUnit)> 0)  and ( (Length(limitValue) > 0 ) ) then | 
|---|
| 851 | begin | 
|---|
| 852 | txtXDuration.Text := limitValue; | 
|---|
| 853 | if Trim(UpperCase(limitUnit))='CC' then | 
|---|
| 854 | limitUnit := 'ml'; | 
|---|
| 855 | btnXDuration.Caption := limitUnit; | 
|---|
| 856 | end; | 
|---|
| 857 |  | 
|---|
| 858 | end; | 
|---|
| 859 |  | 
|---|
| 860 | procedure TfrmODMedIV.txtXDurationExit(Sender: TObject); | 
|---|
| 861 | var | 
|---|
| 862 | Len: Integer; | 
|---|
| 863 | Code: double; | 
|---|
| 864 | Digits, Warning: string; | 
|---|
| 865 | begin | 
|---|
| 866 | inherited; | 
|---|
| 867 | if Changing then Exit; | 
|---|
| 868 | //AGP Change 26.15 HIN-1203-42283 Added additional check to make sure the user can only enter the correct duration | 
|---|
| 869 | Len := Length(txtXDuration.Text); | 
|---|
| 870 | if (Len > 0) and (Pos('.', txtXDuration.Text)=0) then | 
|---|
| 871 | begin | 
|---|
| 872 | Warning := '0'; | 
|---|
| 873 | Digits := '2'; | 
|---|
| 874 | if ((btnXDuration.Caption = 'days') or (btnXDuration.Caption = 'hours') or (btnXDuration.Caption = 'L')) and (Len > 2) then  Warning := '1'; | 
|---|
| 875 | if (btnXDuration.Caption = 'ml') and (Len > 4) then  Warning := '1'; | 
|---|
| 876 | if Warning = '1' then | 
|---|
| 877 | begin | 
|---|
| 878 | if btnXduration.Caption = 'ml' then Digits := '4'; | 
|---|
| 879 | ShowMessage('Invalid Value.' + #13#10 + 'Reason: Duration for ' + btnXDuration.Caption + ' cannot be greater than ' + digits + ' digits.'); | 
|---|
| 880 | txtXDuration.Text := ''; | 
|---|
| 881 | txtXDuration.SetFocus; | 
|---|
| 882 | Exit; | 
|---|
| 883 | end; | 
|---|
| 884 | end; | 
|---|
| 885 | if (Pos('.', txtXDuration.Text)>0) and | 
|---|
| 886 | ((btnXduration.Caption = 'days') or (btnXduration.Caption = 'hours')) then | 
|---|
| 887 | begin | 
|---|
| 888 | ShowMessage('Can not save order.' + #13#10 | 
|---|
| 889 | + 'Reason: Invalid Duration, please enter an integer value for days or hours.'); | 
|---|
| 890 | txtXDuration.Text := ''; | 
|---|
| 891 | txtXDuration.SetFocus; | 
|---|
| 892 | Exit; | 
|---|
| 893 | end; | 
|---|
| 894 | if (txtXDuration.Text <> '0') and (txtXDuration.Text <> '') then | 
|---|
| 895 | begin | 
|---|
| 896 | try | 
|---|
| 897 | code := StrToFloat(txtXDuration.Text); | 
|---|
| 898 | except | 
|---|
| 899 | code := 0; | 
|---|
| 900 | end; | 
|---|
| 901 | if code < 0.0001 then | 
|---|
| 902 | begin | 
|---|
| 903 | ShowMessage('Can not save order.' + #13#10 + 'Reason: Invalid Duration or Total Volume!'); | 
|---|
| 904 | txtXDuration.Text := ''; | 
|---|
| 905 | txtXDuration.SetFocus; | 
|---|
| 906 | Exit; | 
|---|
| 907 | end; | 
|---|
| 908 | end; | 
|---|
| 909 | try | 
|---|
| 910 | if (Length(txtXDuration.Text)>0) and (StrToFloat(txtXDuration.Text)<0) then | 
|---|
| 911 | begin | 
|---|
| 912 | ShowMessage('Can not save order.' + #13#10 + 'Reason: Invalid Duration or total volume!'); | 
|---|
| 913 | txtXDuration.Text := ''; | 
|---|
| 914 | txtXDuration.SetFocus; | 
|---|
| 915 | Exit; | 
|---|
| 916 | end; | 
|---|
| 917 | except | 
|---|
| 918 | txtXDuration.Text := ''; | 
|---|
| 919 | end; | 
|---|
| 920 | ControlChange(Sender); | 
|---|
| 921 | end; | 
|---|
| 922 |  | 
|---|
| 923 | procedure TfrmODMedIV.txtRateExit(Sender: TObject); | 
|---|
| 924 | var | 
|---|
| 925 | ErrorText, LDec,RDec: string; | 
|---|
| 926 | i: Integer; | 
|---|
| 927 | Result: boolean; | 
|---|
| 928 | begin | 
|---|
| 929 | inherited; | 
|---|
| 930 | //AGP Change 26.28 for CQ # 7598 add infusion rate check for valid value | 
|---|
| 931 | ErrorText := 'The Infusion Rate must be in one of the following formats:' + CRLF + CRLF + 'nnnn.nn ml/hr or text@per labels per day'; | 
|---|
| 932 | Result := False; | 
|---|
| 933 | if pos('@',Self.txtRate.Text)>0 then exit; | 
|---|
| 934 | if pos('.',Self.txtRate.Text)>0 then | 
|---|
| 935 | begin | 
|---|
| 936 | LDec := Piece(Self.txtRate.Text,'.',1); | 
|---|
| 937 | RDec := Piece(Self.txtRate.Text,'.',2); | 
|---|
| 938 | if Length(LDec)>4 then Result := True; | 
|---|
| 939 | if Length(RDec)>2 then Result := True; | 
|---|
| 940 | end | 
|---|
| 941 | else if Length(Self.txtRate.Text)>4 then Result := True; | 
|---|
| 942 | if (Result = False) and (pos('.',Self.txtRate.Text)=0) then | 
|---|
| 943 | begin | 
|---|
| 944 | for i := 1 to Length(Self.txtRate.Text) do if not (Self.txtRate.Text[i] in ['0'..'9']) then Result := True | 
|---|
| 945 | end; | 
|---|
| 946 | if Result = True then | 
|---|
| 947 | begin | 
|---|
| 948 | InfoBox(ErrorText,'Warning - Invalid Infusion Rate', MB_OK); | 
|---|
| 949 | Self.txtRate.Text := ''; | 
|---|
| 950 | Self.txtRate.SetFocus; | 
|---|
| 951 | end; | 
|---|
| 952 | end; | 
|---|
| 953 |  | 
|---|
| 954 | end. | 
|---|