Procedure

TfrmODMeds.UpdateDefaultSupply

Module

fODMeds

Last Modified

7/15/2014 3:26:42 PM

Visibility

Private

Owner

TfrmODMeds

Declaration

procedure UpdateDefaultSupply(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string;
  var CurSupply: Integer; var CurQuantity: double; var SkipQtyCheck: Boolean);

Calls Hierarchy


TfrmODMeds.UpdateDefaultSupply
 ├TResponses.IValueFor
 ├IsClozapineOrder
 ├DefaultDays
 └DaysToQty

Called-By Hierarchy


     TfrmODMeds.UpdateDefaultSupply
  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
DaysToQty function DaysToQty(DaysSupply: Integer; const UnitsPerDose, Schedule, Duration, Drug: string): Integer; -
DefaultDays function DefaultDays(const ADrug, UnitStr, SchedStr: string; OI : Integer): Integer; -
IsClozapineOrder function IsClozapineOrder: boolean; -
TResponses.IValueFor function IValueFor(const APromptID: string; AnInstance: Integer): string; -

Called-By

Name Declaration Comments
TfrmODMeds.timCheckChangesTimer procedure timCheckChangesTimer(Sender: TObject); -


Source

4320  procedure TfrmODMeds.UpdateDefaultSupply(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string;
4321    var CurSupply: Integer; var CurQuantity: double; var SkipQtyCheck: Boolean);
4322  var
4323    ADrug: string;
4324    Checked: boolean;
4325    tmpSupply, OI: integer;
4326  begin
4327    Checked := false;
4328    OI := StrToIntDef(Responses.IValueFor('ORDERABLE', 1), 0);
4329   if ((StrToFloatDef(txtQuantity.Text, 0) = 0) and (StrToIntDef(txtSupply.Text, 0) = 0) and
4330       (txtQuantity.Tag = 0) and (txtSupply.Tag = 0) and (cboDosage.Text <> ''))
4331       or ((cboDosage.ItemIndex < 0) and (not FIsQuickOrder)) or
4332       ((IsClozapineOrder = true) and (FISQuickOrder) and (FQOInitial))  then
4333    begin
4334      Checked := True;
4335      ADrug := Piece(CurDispDrug, U, 1);
4336      CurSupply := DefaultDays(ADrug, CurUnits, CurSchedule, OI);
4337      if CurSupply > 0 then
4338      begin
4339        spnSupply.Position := CurSupply;
4340        if (txtSupply.Text = '') or (StrToInt(txtSupply.Text)<>CurSupply)  then
4341          txtSupply.Text := IntToStr(CurSupply);
4342        if (FIsQuickOrder) and (FQOInitial) and (IsClozapineOrder = false) then
4343        begin
4344          if StrToFloatDef(txtSupply.Text,0) > 0 then
4345          begin
4346            Exit;
4347          end;
4348        end;
4349        CurQuantity := DaysToQty(CurSupply, CurUnits, CurSchedule, CurDuration, ADrug);
4350        if CurQuantity >= 0 then
4351        begin
4352         //spnQuantity.Position := CurQuantity;
4353         if txtQuantity.Text <> '' then
4354          txtQuantity.Text := FloatToStr(CurQuantity);
4355         if (txtQuantity.Text = '') or (StrToInt(txtQuantity.Text) <> CurQuantity) then
4356           txtQuantity.Text := FloatToStr(CurQuantity);
4357        end;
4358        SkipQtyCheck := TRUE;
4359      end;
4360      //if FQOInitial = true then FQOInitial := False;
4361    end;
4362    if (IsClozapineOrder = true) and (CurDispDrug <> '') and (CurDispDrug <> U)and (Checked = false) then
4363      begin
4364        ADrug := Piece(CurDispDrug, U, 1);
4365        tmpSupply := DefaultDays(ADrug, CurUnits, CurSchedule, OI);
4366        if (tmpSupply > 0) and (CurSupply > tmpSupply) then
4367          begin
4368            CurSupply := tmpSupply;
4369            spnSupply.Position := CurSupply;
4370            if (txtSupply.Text = '') or (StrToInt(txtSupply.Text)<>CurSupply)  then
4371            txtSupply.Text := IntToStr(CurSupply);
4372          end;
4373        CurQuantity := DaysToQty(CurSupply, CurUnits, CurSchedule, CurDuration, ADrug);
4374        if CurQuantity >= 0 then
4375        begin
4376         //spnQuantity.Position := CurQuantity;
4377         if (txtQuantity.Text <> '') and (CurQuantity > 0) then
4378          txtQuantity.Text := FloatToStr(CurQuantity);
4379         if (txtQuantity.Text = '') or (StrToInt(txtQuantity.Text) <> CurQuantity) and (CurQuantity > 0)  then
4380           txtQuantity.Text := FloatToStr(CurQuantity);
4381        end;
4382      end;
4383  end;