Procedure

TfrmODMeds.UpdateStartExpires

Module

fODMeds

Last Modified

7/15/2014 3:26:42 PM

Visibility

Private

Owner

TfrmODMeds

Declaration

procedure UpdateStartExpires(const CurSchedule: string);

Calls Hierarchy


TfrmODMeds.UpdateStartExpires
 ├TfrmODMeds.ValFor
 ├TfrmODMeds.lblAdminSchSetText
 ├TfrmODMeds.lblAdminSchGetText
 ├LoadAdminInfo
 ├FMToday
 │ └FMNow
 └TfrmODMeds.DisplayDoseNow

Called-By Hierarchy


         TfrmODMeds.UpdateStartExpires
              TfrmODMeds.SetupDialog┤ 
          TfrmODMeds.SetOnQuickOrder┤ 
            TfrmODMeds.SetupDialog┤ │ 
         TfrmODMeds.btnSelectClick┘ │ 
         TfrmODMeds.UMDelayClick┘   │ 
            TfrmODMeds.tabDoseChange┤ 
            TfrmODMeds.FormKeyDown┘ │ 
       TfrmODMeds.cboXScheduleChange┤ 
            TfrmODMeds.txtNSSClick┘ │ 
        TfrmODMeds.cboXScheduleClick┤ 
           TfrmODMeds.chkXPRNClick┤ │ 
       TfrmODMeds.pnlXScheduleExit┘ │ 
     TfrmODMeds.timCheckChangesTimer┤ 
          TfrmODMeds.UpdateRelated┘ │ 
          TfrmODMeds.SetupDialog┤   │ 
    TfrmODMeds.btnSelectClick...┤   │ 
       TfrmODMeds.cboDosageClick┤   │ 
     TfrmODMeds.cboDosageKeyUp┘ │   │ 
      TfrmODMeds.cboDosageChange┤   │ 
        TfrmODMeds.cboDosageExit┤   │ 
     TfrmODMeds.cboScheduleClick┤   │ 
     TfrmODMeds.cmdAcceptClick┤ │   │ 
        TfrmODMeds.chkPRNClick┤ │   │ 
        TfrmODMeds.txtNSSClick┤ │   │ 
   TfrmODMeds.cboScheduleEnter┤ │   │ 
   TfrmODMeds.UMShowNSSBuilder┘ │   │ 
    TfrmODMeds.cboScheduleChange┤   │ 
      TfrmODMeds.txtSupplyChange┤   │ 
    TfrmODMeds.txtQuantityChange┤   │ 
         TfrmODMeds.grdDosesExit┤   │ 
     TfrmODMeds.cboXDosageChange┤   │ 
      TfrmODMeds.cboXDosageClick┤   │ 
     TfrmODMeds.cboXDosageExit┤ │   │ 
    TfrmODMeds.cboXDosageKeyUp┘ │   │ 
       TfrmODMeds.cboXDosageExit┤   │ 
TfrmODMeds.cboXScheduleChange...┤   │ 
 TfrmODMeds.cboXScheduleClick...┤   │ 
     TfrmODMeds.pnlXScheduleExit┤   │ 
   TfrmODMeds.txtXDurationChange┤   │ 
   TfrmODMeds.popDurationClick┘ │   │ 
     TfrmODMeds.pnlXDurationExit┤   │ 
          TfrmODMeds.chkPRNClick┤   │ 
      TfrmODMeds.cboScheduleExit┤   │ 
       TfrmODMeds.cboDosageKeyUp┤   │ 
      TfrmODMeds.cboXDosageKeyUp┘   │ 
              TfrmODMeds.chkPRNClick┤ 
       TfrmODMeds.cboXSequenceChange┘ 

Calls

Name Declaration Comments
TfrmODMeds.DisplayDoseNow procedure DisplayDoseNow(Status: boolean); -
FMToday function FMToday: TFMDateTime; -
TfrmODMeds.lblAdminSchGetText function lblAdminSchGetText: string; -
TfrmODMeds.lblAdminSchSetText procedure lblAdminSchSetText(str: string); -
LoadAdminInfo procedure LoadAdminInfo(const Schedule: string; OrdItem: Integer; var StartText: string; var AdminTime: TFMDateTime; var Duration: string; Admin: string = ''); -
TfrmODMeds.ValFor function ValFor(FieldID, ARow: Integer): string; -

Called-By

Name Declaration Comments
TfrmODMeds.cboXScheduleChange procedure cboXScheduleChange(Sender: TObject); -
TfrmODMeds.cboXScheduleClick procedure cboXScheduleClick(Sender: TObject); -
TfrmODMeds.cboXSequenceChange procedure cboXSequenceChange(Sender: TObject); -
TfrmODMeds.chkPRNClick procedure chkPRNClick(Sender: TObject); -
TfrmODMeds.SetOnQuickOrder procedure SetOnQuickOrder; -
TfrmODMeds.SetupDialog procedure SetupDialog(OrderAction: Integer; const ID: string); override; -
TfrmODMeds.tabDoseChange procedure tabDoseChange(Sender: TObject); -
TfrmODMeds.timCheckChangesTimer procedure timCheckChangesTimer(Sender: TObject); -


Source

4482  procedure TfrmODMeds.UpdateStartExpires(const CurSchedule: string);
4483  var
4484    CompSch, CompDose, LastSch, ShowText, Duration, ASchedule, TempSch, schType, Admin, tempAdmin: string;
4485    AdminTime:    TFMDateTime;
4486    j, r, Interval, PrnPos, SchID: Integer;
4487    EndCheck, rowCheck, DoseNow: boolean;
4488  begin
4489    if not FInptDlg then Exit;
4490    if Length(CurSchedule)=0 then Exit;
4491    ASchedule := Trim(CurSchedule);
4492    DoseNow := True;
4493    if self.EvtID > 0 then DoseNow := false;
4494    if (Pos('^',ASchedule)>0) then
4495    begin
4496      PrnPos := Pos('PRN',ASchedule);
4497      if (PrnPos > 1) and (CharAt(ASchedule,PrnPos-1)=' ') then
4498        Delete(ASchedule, PrnPos-1, 4);
4499    end;
4500    if (FAdminTimeText = '') and (self.EvtID > 0) then FAdminTimeText := 'To Be Determined';
4501    AdminTime := 0;
4502    ASchedule := Trim(ASchedule);
4503    //AGP Change for CQ 9906
4504    EndCheck := False;
4505    lastSch := '';
4506    if self.tabDose.TabIndex = TI_COMPLEX then
4507      begin
4508      tempSch := ASchedule;
4509      ASchedule := '';
4510      for r := 1 to self.grdDoses.RowCount-1 do
4511        begin
4512          CompSch := ValFor(VAL_SCHEDULE,r);
4513          CompDose := ValFor(VAL_DOSAGE,r);
4514          RowCheck := ValFor(VAL_CHKXPRN,r)='1';
4515          if (RowCheck = True) then
4516            begin
4517              if EndCheck = false then AdminTime := -1;
4518              if FAdminTimeText = '' then self.grdDoses.cells[COL_ADMINTIME, r] := ''
4519              else Self.grdDoses.Cells[COL_ADMINTIME, r] := FAdminTimeText;
4520            end
4521          else
4522            begin
4523              if CompSch <> '' then
4524                 begin
4525                   //cboXSchedule.Items.IndexOfName(CompSch);
4526                   //cboXSchedule.SelectByID(CompSch);
4527                   SchID := -1;
4528                   for j := 0 to cboXSchedule.Items.Count - 1 do
4529                      begin
4530                        if Piece(cboXSchedule.Items.Strings[j], U, 1) = CompSch then
4531                          begin
4532                            schID := j;
4533                            break;
4534                          end;
4535                      end;
4536                   //if cboXSchedule.ItemIndex > -1 then
4537                   if SchID > -1 then
4538                     begin
4539                       //SchID := cboXSchedule.ItemIndex;
4540                       if (Piece(self.cboXSchedule.Items.Strings[SchID],U,1) = CompSch) then
4541                         begin
4542                           SchType := Piece(self.cboXSchedule.Items.Strings[SchID],U,3);
4543                           if (SchType = 'P') or (SchType = 'O') or (SchType = 'OC') then
4544                               self.grdDoses.Cells[COL_ADMINTIME, r] := ''
4545                           else if FAdminTimeText <> '' then self.grdDoses.Cells[COL_ADMINTIME, r] := FAdminTimeText
4546                           else
4547                             begin
4548                               self.grdDoses.Cells[COL_ADMINTIME, r] := Piece(self.cboXSchedule.Items.Strings[SchID],U,4);
4549                               if self.grdDoses.Cells[COL_ADMINTIME, r] = '' then self.grdDoses.Cells[COL_ADMINTIME, r] := 'Not Defined';
4550  
4551                             end;
4552                           if CompDose <> '' then
4553                             begin
4554                               lastSch := CompSch;
4555                               if (EndCheck = False) and ((SchType = 'P') or (SchType = 'O')) then AdminTime := -1
4556                               //else Aschedule := ';' + CompSch;
4557                             end;
4558                         end;
4559                       
4560                     end;
4561                 end;
4562            end;
4563          if ((ValFor(VAL_SEQUENCE,r) = 'AND') or (ValFor(VAL_SEQUENCE,r) = '')) and (AdminTime > -1) and (EndCheck = false) then
4564            begin
4565              //if (CompSch = '') and (LastSch <> '') and (Aschedule <> '') then CompSch := LastSch;
4566              if (ASchedule <> '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ASchedule + ';' + CompSch;
4567              if (ASchedule = '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ';' + CompSch;
4568            end
4569          else if ValFor(VAL_SEQUENCE, r) = 'THEN' then
4570            begin
4571             // if (CompSch = '') and (LastSch <> '') and (Aschedule <> '') then CompSch := LastSch;
4572              if (ASchedule <> '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ASchedule + ';' + CompSch;
4573              if (ASchedule = '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ';' + CompSch;
4574              EndCheck := True;
4575            end
4576        end;
4577      end;
4578    if self.tabDose.TabIndex = TI_DOSE then
4579      begin
4580       if LeftStr(ASchedule, 1) = ';' then tempSch := Piece(ASchedule, ';', 2)
4581       else tempSch := ASchedule;
4582       if self.chkPRN.Checked = True then
4583         begin
4584           AdminTime := -1;
4585           lblAdminSchSetText('');
4586           if (cboSchedule.ItemIndex > -1) and (Piece(self.cboSchedule.Items.Strings[cboSchedule.itemIndex], U, 3) = 'O') then
4587             DoseNow := false;
4588         end
4589       else begin
4590           //cboSchedule.SelectByID(tempSch);
4591           SchID := -1;
4592           for j := 0 to cboSchedule.Items.Count - 1 do
4593             begin
4594               if Piece(cboSchedule.Items.Strings[j], U, 1) = tempSch then
4595                  begin
4596                    schID := j;
4597                    break;
4598                  end;
4599             end;
4600           if schID > -1 then
4601             begin
4602               SchType := Piece(self.cboSchedule.Items.Strings[schID], U, 3);
4603               if (SchType = 'P') or (SchType = 'OC') or (SchType = 'O') then
4604                 begin
4605                   lblAdminSchSetText('');
4606                   if (SchType = 'P') or (SchType = 'OC') or (SchType = 'O') then AdminTime := -1;
4607                   if SchType = 'O' then DoseNow := false;
4608                 end
4609               else
4610                 begin
4611                   if FAdminTimeText <> '' then tempAdmin := 'Admin. Time: ' + FAdminTimeText
4612                   else
4613                     begin
4614                        if Piece(self.cboSchedule.Items.Strings[schID], U, 4) <> '' then
4615                            tempAdmin := 'Admin. Time: ' + Piece(self.cboSchedule.Items.Strings[schID], U, 4)
4616                        else tempAdmin := 'Admin. Time: Not Defined';
4617                     end;
4618                    lblAdminSchSetText(tempAdmin);
4619               (*    if FAdminTimeText <> '' then self.lblAdminSch.text := 'Admin. Time: ' + FAdminTimeText
4620                   else
4621                     begin
4622                        if Piece(self.cboSchedule.Items.Strings[schID], U, 4) <> '' then
4623                            self.lblAdminSch.text := 'Admin. Time: ' + Piece(self.cboSchedule.Items.Strings[schID], U, 4)
4624                        else self.lblAdminSch.text := 'Admin. Time: Not Defined';
4625                     end;   *)
4626  
4627                 end;
4628             end;
4629         end;
4630      end;
4631    if (Length(ASchedule)>0) and (AdminTime > -1) then
4632       begin
4633        if LeftStr(Aschedule, 1) <> ';' then ASchedule := ';'+ASchedule;
4634        Admin := '';
4635        if (self.lblAdminSch.visible = True) and (self.lblAdminSch.text <> '') and (self.tabDose.TabIndex = TI_DOSE) then
4636          begin
4637            //AGP Change Admin Time Wrap 27.73
4638            //Admin := Copy(self.lblAdminSch.text,  14, (Length(self.lblAdminSch.text)-1));
4639            Admin := lblAdminSchGetText;
4640            if (Admin <> '') and (not (Admin[1] in ['0'..'9'])) then Admin := '';
4641          end
4642        else if self.tabDose.TabIndex = TI_COMPLEX then
4643          begin
4644            Admin := Self.grdDoses.Cells[COL_ADMINTIME, 1];
4645            if (Admin <> '') and (not (Admin[1] in ['0'..'9'])) then Admin := '';
4646          end;           
4647        LoadAdminInfo(ASchedule, txtMed.Tag, ShowText, AdminTime, Duration, Admin);
4648       end;
4649    if AdminTime > 0 then
4650    begin
4651      ShowText := 'Expected First Dose: ';
4652      Interval := Trunc(FMDateTimeToDateTime(AdminTime) - FMDateTimeToDateTime(FMToday));
4653      case Interval of
4654      0: ShowText := ShowText + 'TODAY ' + FormatFMDateTime('(mmm dd, yy) at hh:nn', AdminTime);
4655      1: ShowText := ShowText + 'TOMORROW ' + FormatFMDateTime('(mmm dd, yy) at hh:nn', AdminTime);
4656      else ShowText := ShowText + FormatFMDateTime('mmm dd, yy at hh:nn', AdminTime);
4657      end;
4658  
4659      if (Pos('PRN',Piece(CurSchedule,'^',1))>0) and ((pnlXSchedule.Tag = 1) or chkPrn.Checked ) then
4660      begin
4661        if lblAdmintime.visible then
4662        begin
4663          lblAdmintime.Caption := '';
4664          FAdminTimeLbl := lblAdminTime.Caption;
4665        end;
4666      end else
4667        lblAdminTime.Caption := ShowText;
4668        FAdminTimeLbl := lblAdminTime.Caption;
4669    end
4670    else lblAdminTime.Caption := '';
4671    if (lblAdminTime.Caption <> '') and (lblAdminTime.Visible = True) and (JAWSON = true) then lblAdminTime.TabStop := true
4672    else lblAdminTime.TabStop := false;
4673    if (lblAdminSch.text <> '') and (lblAdminSch.Visible = True) and (JAWSON = true) then lblAdminSch.TabStop := true
4674    else lblAdminSch.TabStop := false;
4675    DisplayDoseNow(DoseNow);
4676  end;