Procedure

TfrmODMedIV.loadExpectFirstDose

Module

fODMedIV

Last Modified

7/15/2014 3:26:42 PM

Visibility

Public/Published

Owner

TfrmODMedIV

Declaration

procedure loadExpectFirstDose;

Calls Hierarchy


TfrmODMedIV.loadExpectFirstDose
 ├TfrmODMedIV.DisplayDoseNow
 ├LoadAdminInfo
 └FMToday
   └FMNow

Called-By Hierarchy


          TfrmODMedIV.loadExpectFirstDose
     TfrmODMedIV.SetValuesFromResponses┤ 
              TfrmODMedIV.SetupDialog┤ │ 
    TfrmODMedIV.cboSolutionMouseClick┘ │ 
        TfrmODMedIV.cboSolutionExit┘   │ 
              TfrmODMedIV.ControlChange┘ 
TfrmODMedIV.SetValuesFromResponses...┤   
            TfrmODMedIV.cboTypeChange┤   
         TfrmODMedIV.ClearAllFields┘ │   
           TfrmODMedIV.InitDialog┤   │   
         TfrmODMedIV.FormCreate┘ │   │   
       TfrmODMedIV.cmdRemoveClick┘   │   
          TfrmODMedIV.chkDoseNowClick┤   
              TfrmODMedIV.chkPRNClick┤   
 TfrmODMedIV.cboSolutionMouseClick...┤   
        TfrmODMedIV.cboAddFreqCloseUp┤   
      TfrmODMedIV.cboAddFreqKeyDown┘ │   
        TfrmODMedIV.cboDurationChange┤   
    TfrmODMedIV.cboInfusionTimeChange┤   
        TfrmODMedIV.cboPriorityChange┤   
           TfrmODMedIV.cboRouteChange┤   
    TfrmODMedIV.txtAllIVRoutesClick┘ │   
      TfrmODMedIV.cboRouteKeyDown┘   │   
    TfrmODMedIV.cboAdditiveMouseClick┤   
        TfrmODMedIV.cboAdditiveExit┘ │   
        TfrmODMedIV.txtSelectedChange┤   
        TfrmODMedIV.cboScheduleChange┤   
            TfrmODMedIV.txtNSSClick┘ │   
   TfrmODMedIV.cboScheduleKeyDown┘   │   
       TfrmODMedIV.cboSelectedCloseUp┤   
     TfrmODMedIV.cboSelectedKeyDown┘ │   
           TfrmODMedIV.cmdRemoveClick┤   
       TfrmODMedIV.txtXDurationChange┤   
         TfrmODMedIV.txtXDurationExit┤   
            TfrmODMedIV.txtRateChange┘   

Calls

Name Declaration Comments
TfrmODMedIV.DisplayDoseNow procedure DisplayDoseNow(Status: boolean); -
FMToday function FMToday: TFMDateTime; -
LoadAdminInfo procedure LoadAdminInfo(const Schedule: string; OrdItem: Integer; var StartText: string; var AdminTime: TFMDateTime; var Duration: string; Admin: string = ''); -

Called-By

Name Declaration Comments
TfrmODMedIV.ControlChange procedure ControlChange(Sender: TObject); -
TfrmODMedIV.SetValuesFromResponses procedure SetValuesFromResponses; -


Source

431   procedure TfrmODMedIV.loadExpectFirstDose;
432   var
433   i: integer;
434   AnIVComponent: TIVComponent;
435   fAddIEN, fSolIEN, Interval, idx: integer;
436   AdminTime:    TFMDateTime;
437   Admin, Duration, ShowText, SchTxt, SchType, IVType: string;
438   doseNow, calFirstDose: boolean;
439   begin
440     idx := self.cboSchedule.ItemIndex;
441     IVType := self.cboType.Items.Strings[self.cboType.itemindex];
442     if idx = -1 then
443       begin
444         if IVType = 'Continuous' then
445           begin
446             self.lblFirstDose.Caption := '';
447             self.lblFirstDose.Visible := false;
448           end;
449         exit;
450       end;
451     doseNow := true;
452     SchType := Piece(self.cboSchedule.Items.Strings[idx],U,3);
453     if self.EvtID > 0 then doseNow := false;
454     if (IVType = 'Continuous') or ((idx > -1) and ((SchType = 'P') or (SchType = 'O') or (SchType = 'OC')) or
455        (self.chkPRN.Checked = True))  then
456        begin
457          self.lblFirstDose.Caption := '';
458          self.lblAdminTime.Caption := '';
459          self.lblFirstDose.Visible := false;
460          self.lblAdminTime.Visible := false;
461          self.lblAdminTime.TabStop := false;
462          self.lblFirstDose.TabStop := false;
463          if (self.cboType.Text = 'Continuous') or (Piece(self.cboSchedule.Items.Strings[idx],U,3) = 'O') then doseNow := false;
464          if chkDoseNow.Checked = true then lblFirstDose.Visible := false;
465          if idx > -1 then oSchedule := Piece(self.cboSchedule.Items.Strings[idx],U,1);
466          if (self.chkPRN.Checked = True) and (idx > -1) and (LeftStr(Piece(self.cboSchedule.Items.Strings[idx],U,1),3)<> 'PRN') then
467             OSchedule := Piece(self.cboSchedule.Items.Strings[idx],U,1) + ' PRN';
468          DisplayDoseNow(doseNow);
469          exit;
470          //  end;
471        end
472     else if SchType <> 'O' then
473       begin
474         self.lblAdminTime.Visible := true;
475         if FAdminTimeText <> '' then self.lblAdminTime.Caption := 'Admin. Time: ' + FAdminTimeText
476         else if Piece(self.cboSchedule.Items[idx],U,4) <> '' then
477              self.lblAdminTime.Caption := 'Admin. Time: ' + Piece(self.cboSchedule.Items[idx],U,4)
478         else self.lblAdminTime.Caption := 'Admin. Time: Not Defined';
479       end;
480    DisplayDoseNow(doseNow);
481    if chkDoseNow.Checked = true then
482      begin
483        lblFirstDose.Visible := false;
484        Exit;
485      end;
486    self.lblFirstDose.Visible := True;
487    fSolIEN := 0;
488    fAddIEN := 0;
489    for i := 0 to self.grdSelected.RowCount - 1 do
490     begin
491      AniVComponent := TIVComponent(self.grdSelected.Objects[0, i]);
492      if AnIVComponent = nil then Continue;
493      if (AnIVComponent.Fluid = 'B') and (fSolIEN = 0) then fSolIEN := AnIVComponent.IEN;
494      if (AnIVComponent.Fluid = 'A') and (fAddIEN = 0) then fAddIEN := AnIVComponent.IEN;
495      if (fSolIEN > 0) and (fAddIEN > 0) then break;
496     end;
497     SchTxt := self.cboSchedule.Text;
498     Admin := '';
499     if (self.lblAdminTime.visible = True) and (self.lblAdminTime.Caption <> '') then
500       begin
501         Admin := Copy(self.lblAdminTime.Caption,  14, (Length(self.lblAdminTime.Caption)-1));
502         if not (Admin[1] in ['0'..'9']) then Admin := '';
503       end;
504     if (fSolIEN = oSolIEN) and (fAddIEN = oAddIEN) and (OSchedule = SchTxt) and (oAdmin = Admin) then CalFirstDose := false
505     else
506       begin
507         CalFirstDose := True;
508         oSolIEN := fSolIEN;
509         oAddIEN := fAddIEN;
510         oSchedule := SchTxt;
511         oAdmin := Admin;
512       end;
513     if CalFirstDose = True then
514     begin
515       if fAddIEN > 0 then LoadAdminInfo(';' + schTxt, fAddIEN, ShowText, AdminTime, Duration, Admin)
516       else LoadAdminInfo(';' + schTxt, fSolIEN, ShowText, AdminTime, Duration, Admin);
517       if AdminTime > 0 then
518         begin
519           ShowText := 'Expected First Dose: ';
520           Interval := Trunc(FMDateTimeToDateTime(AdminTime) - FMDateTimeToDateTime(FMToday));
521           case Interval of
522           0: ShowText := ShowText + 'TODAY ' + FormatFMDateTime('(mmm dd, yy) at hh:nn', AdminTime);
523           1: ShowText := ShowText + 'TOMORROW ' + FormatFMDateTime('(mmm dd, yy) at hh:nn', AdminTime);
524           else ShowText := ShowText + FormatFMDateTime('mmm dd, yy at hh:nn', AdminTime);
525         end;
526       end;
527       self.lblFirstDose.Caption := ShowText;
528     end;
529     if (self.lblFirstDose.Visible = true) and (self.lblFirstDose.Caption <> '') and (JAWSON = true) then self.lblFirstDose.TabStop := true
530     else self.lblFirstDose.TabStop := false;
531     if (self.lblAdminTime.Visible = true) and (self.lblAdminTime.Caption <> '') and (JAWSON = true) then self.lblAdminTime.TabStop := true
532     else self.lblAdminTime.TabStop := false;
533   end;