Procedure

TfrmODMeds.timCheckChangesTimer

Module

fODMeds

Last Modified

7/15/2014 3:26:42 PM

Visibility

Public/Published

Owner

TfrmODMeds

Declaration

procedure timCheckChangesTimer(Sender: TObject);

Calls Hierarchy


TfrmODMeds.timCheckChangesTimer
 ├TfrmODMeds.ControlChange
 │ ├TResponses.Clear
 │ ├TResponses.Update
 │ │ ├TResponses.FindResponseByName
 │ │ └TResponses.IENForPrompt
 │ ├TfrmODMeds.FindCommonDrug
 │ │ ├TfrmODMeds.FindDoseFields
 │ │ ├SaveDrug
 │ │ └KillDrug
 │ ├TfrmODMeds.ConstructedDoseFields
 │ ├TfrmODMeds.ValueOf
 │ │ ├GetSingleDoseSchedule
 │ │ ├GetSingleDoseScheduleEX
 │ │ ├TfrmODMeds.FieldsForDose
 │ │ │ └TfrmODMeds.ConstructedDoseFields
 │ │ ├TfrmODMeds.FieldsForDrug
 │ │ ├GetComplexDoseSchedule
 │ │ │ └TfrmODMeds.ValFor
 │ │ └GetComplexDoseScheduleEX
 │ │   └TfrmODMeds.ValFor
 │ ├TfrmODMeds.lblAdminSchGetText
 │ ├TfrmODMeds.ValFor
 │ ├TfrmODMeds.InpatientSig
 │ │ ├TfrmODMeds.ValueOf...
 │ │ └TfrmODMeds.CheckDecimal
 │ │   └TfrmODMeds.TextDosage
 │ ├TfrmODMeds.OutpatientSig
 │ │ ├TfrmODMeds.ValueOf...
 │ │ └TfrmODMeds.CheckDecimal...
 │ └TResponses.GetOrderText
 │   ├TResponses.NextInstance
 │   ├TResponses.FindResponseByName
 │   ├TResponses.FormatResponse
 │   │ └TResponses.FindResponseByIEN
 │   └TResponses.AppendChildren
 │     ├TResponses.FindPromptByIEN
 │     ├TResponses.FindResponseByIEN
 │     └TResponses.FormatResponse...
 ├TResponses.NextInstance
 ├TfrmODMeds.ValueOfResponse
 │ └TResponses.IValueFor
 ├TfrmODMeds.ValueOf...
 ├TfrmODMeds.UpdateStartExpires
 │ ├TfrmODMeds.ValFor
 │ ├TfrmODMeds.lblAdminSchSetText
 │ ├TfrmODMeds.lblAdminSchGetText
 │ ├LoadAdminInfo
 │ ├FMToday
 │ │ └FMNow
 │ └TfrmODMeds.DisplayDoseNow
 ├IsClozapineOrder
 ├TfrmODMeds.UpdateDefaultSupply
 │ ├TResponses.IValueFor
 │ ├IsClozapineOrder
 │ ├DefaultDays
 │ └DaysToQty
 ├TfrmODMeds.UpdateSupplyQuantity
 │ ├TfrmODMeds.DurationToDays
 │ │ └TfrmODMeds.ValFor
 │ ├DaysToQty
 │ └QtyToDays
 └TfrmODMeds.UpdateRefills
   └CalcMaxRefills

Called-By Hierarchy


  TfrmODMeds.timCheckChangesTimer
       TfrmODMeds.UpdateRelated┘ 
       TfrmODMeds.SetupDialog┤   
    TfrmODMeds.btnSelectClick┤   
    TfrmODMeds.UMDelayClick┘ │   
    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.txtNSSClick┘ │   
 TfrmODMeds.cboXScheduleClick┤   
    TfrmODMeds.chkXPRNClick┤ │   
TfrmODMeds.pnlXScheduleExit┘ │   
  TfrmODMeds.pnlXScheduleExit┤   
TfrmODMeds.txtXDurationChange┤   
TfrmODMeds.popDurationClick┘ │   
  TfrmODMeds.pnlXDurationExit┤   
       TfrmODMeds.chkPRNClick┤   
   TfrmODMeds.cboScheduleExit┤   
    TfrmODMeds.cboDosageKeyUp┤   
   TfrmODMeds.cboXDosageKeyUp┘   

Calls

Name Declaration Comments
TfrmODMeds.ControlChange procedure ControlChange(Sender: TObject); -
IsClozapineOrder function IsClozapineOrder: boolean; -
TResponses.NextInstance function NextInstance(const APromptID: string; LastInstance: Integer): Integer; -
TfrmODMeds.UpdateDefaultSupply procedure UpdateDefaultSupply(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string; var CurSupply: Integer; var CurQuantity: double; var SkipQtyCheck: Boolean); -
TfrmODMeds.UpdateRefills procedure UpdateRefills(const CurDispDrug: string; CurSupply: Integer); -
TfrmODMeds.UpdateStartExpires procedure UpdateStartExpires(const CurSchedule: string); -
TfrmODMeds.UpdateSupplyQuantity procedure UpdateSupplyQuantity(const CurUnits, CurSchedule, CurDuration, CurDispDrug, CurInstruct: string; var CurSupply: Integer; var CurQuantity: double); -
TfrmODMeds.ValueOf function ValueOf(FieldID: Integer; ARow: Integer = -1): string; -
TfrmODMeds.ValueOfResponse function ValueOfResponse(FieldID: Integer; AnInstance: Integer = 1): string; -

Called-By

Name Declaration Comments
TfrmODMeds.UpdateRelated procedure UpdateRelated(DelayUpdate: Boolean = TRUE); -


Source

4700  procedure TfrmODMeds.timCheckChangesTimer(Sender: TObject);
4701  const
4702    UPD_NONE     = 0;
4703    UPD_QUANTITY = 1;
4704    UPD_SUPPLY   = 2;
4705  var
4706    CurUnits, CurSchedule, CurInstruct, CurDispDrug, CurDuration, TmpSchedule, x, x1: string;
4707    CurScheduleIN, CurScheduleOut: string;
4708    CurSupply, i, pNum, j: Integer;
4709    CurQuantity: double;
4710    LackQtyInfo, SaveChanging, LocPosDos: Boolean;
4711  begin
4712    inherited;
4713    timCheckChanges.Enabled := False;
4714    ControlChange(Self);
4715    SaveChanging := Changing;
4716    Changing := TRUE;
4717    // don't allow Exit procedure so Changing gets reset appropriately
4718    CurUnits    := '';
4719    CurSchedule := '';
4720    CurDuration := '';
4721    LackQtyInfo := False;
4722    LocPosDos   := False;
4723    i := Responses.NextInstance('DOSE', 0);
4724    while i > 0 do
4725    begin
4726      x := ValueOfResponse(FLD_DOSEUNIT,  i);
4727      if (x = '') and (not FIsQuickOrder) then LackQtyInfo := TRUE  //StrToIntDef(x, 0) = 0
4728      else if  (x = '') and FIsQuickOrder and (Length(txtQuantity.Text)>0) then
4729        LackQtyInfo := false;
4730      CurUnits    := CurUnits   + x  + U;
4731      x := ValueOfResponse(FLD_DOSEUNIT_LOCAL,  i);
4732      if x = '' then LocPosDos := False
4733      else LocPosDos := True;
4734      x := ValueOfResponse(FLD_SCHEDULE,  i);
4735      if Length(x) = 0         then LackQtyInfo := TRUE;
4736      CurScheduleOut := CurScheduleOut + x + U;
4737      x1 := ValueOf(FLD_SEQUENCE,i);
4738      if Length(x1)>0 then
4739      begin
4740        X1 := CharAt(X1,1);
4741        CurScheduleIn := CurScheduleIn + x1 + ';' + x + U;
4742      end
4743      else
4744        CurScheduleIn := CurScheduleIn + ';' + x + U;
4745      x := ValueOfResponse(FLD_EXPIRE,    i);
4746      CurDuration := CurDuration + x + '~';
4747      x := ValueOfResponse(FLD_ANDTHEN,   i);
4748      CurDuration := CurDuration + x + U;
4749      x := ValueOfResponse(FLD_DRUG_ID,   i);
4750      CurDispDrug := CurDispDrug + x + U;
4751      x := ValueOfResponse(FLD_INSTRUCT,  i);
4752      CurInstruct := CurInstruct + x + U;  //AGP CHANGE 26.19 FOR CQ 7465
4753      i := Responses.NextInstance('DOSE', i);
4754    end;
4755  
4756    pNum := 1;
4757    while Length( Piece(CurScheduleIn,U,pNum)) > 0 do
4758      pNum := pNum + 1;
4759    if Length(Piece(CurScheduleIn,U,pNum)) < 1 then
4760      for j := 1 to pNum - 1 do
4761      begin
4762        if j = pNum -1 then
4763          TmpSchedule := TmpSchedule + ';' + Piece(Piece(CurScheduleIn,U,j),';',2)
4764        else
4765          TmpSchedule := TmpSchedule + Piece(CurScheduleIn,U,j) + U
4766      end;
4767    CurScheduleIn := TmpSchedule;
4768    CurQuantity := StrToFloatDef(ValueOfResponse(FLD_QUANTITY), 0);
4769    CurSupply   := StrToIntDef(ValueOfResponse(FLD_SUPPLY)   ,0);
4770    //CurRefill  := StrToIntDef(ValueOfResponse(FLD_REFILLS) , 0);
4771    if FInptDlg then
4772    begin
4773      CurSchedule := CurScheduleIn;
4774      if Pos('^',CurSchedule)>0 then
4775      begin
4776        if Pos('PRN',Piece(CurSchedule,'^',1))>0 then
4777          if lblAdminTime.Visible then
4778            lblAdminTime.Caption := '';
4779      end;
4780     if (self.tabDose.TabIndex = TI_DOSE) and (CurSchedule <> FLastSchedule) then
4781       UpdateStartExpires(CurSchedule);
4782      if Responses.EventType in ['A','D','T','M','O'] then lblAdminTime.Visible := False;
4783    end;
4784    if not FInptDlg then
4785    begin
4786      CurSchedule := CurScheduleOut;
4787      if ((CurInstruct <> FLastInstruct) and (CurUnits <> U)) or ((IsClozapineOrder = true) and (CurDispDrug <> '') and (CurDispDrug <> U)) //AGP Change 26.48 Do not update quantity and day supply if no matching dose on the server
4788      or ((CurInstruct <> FLastInstruct) and LocPosDos)
4789      //if ((CurInstruct <> FLastInstruct) and (CurUnits <> U))
4790        then UpdateDefaultSupply(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity,
4791                                 LackQtyInfo);
4792      if LackQtyInfo then begin
4793        if FScheduleChanged then
4794          txtQuantity.Text := '0';
4795      end
4796      else
4797        UpdateSupplyQuantity(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurInstruct, CurSupply, CurQuantity);
4798     // if (CurDispDrug <> FLastDispDrug) then UpdateSC(CurDispDrug);
4799      if ((CurDispDrug <> FLastDispDrug) or (CurSupply <> FLastSupply)) and ((CurDispDrug <> '') and (CurSupply > 0))  then
4800        UpdateRefills(CurDispDrug, CurSupply);
4801    end;
4802  
4803    FLastUnits    := CurUnits;
4804    FLastSchedule := CurSchedule;
4805    FLastDuration := CurDuration;
4806    FLastInstruct := CurInstruct;
4807    FLastDispDrug := CurDispDrug;
4808    FLastQuantity := CurQuantity;
4809    FLastSupply   := CurSupply;
4810    if (not FNoZERO) and (txtQuantity.Text = '') and (FLastQuantity = 0) then
4811      txtQuantity.Text := FloatToStr(FLastQuantity);
4812    if (not FNoZERO) and (txtSupply.Text = '') and (FLastSupply = 0) then
4813       txtSupply.Text := IntToStr(FLastSupply);
4814    if (ActiveControl <> nil) and (ActiveControl.Parent <> cboDosage)
4815      then cboDosage.Text := Piece(cboDosage.Text, TAB, 1);
4816    Changing := SaveChanging;
4817    if FUpdated then ControlChange(Self);
4818    FScheduleChanged := false;
4819    //FQOInitial := False;
4820  end;