Procedure

TfrmODMedIV.ControlChange

Module

fODMedIV

Last Modified

7/15/2014 3:26:42 PM

Comments

Update Responses & Create Order Text

Visibility

Public/Published

Owner

TfrmODMedIV

Declaration

procedure ControlChange(Sender: TObject);

Calls Hierarchy


TfrmODMedIV.ControlChange
 ├TfrmODMedIV.loadExpectFirstDose
 │ ├TfrmODMedIV.DisplayDoseNow
 │ ├LoadAdminInfo
 │ └FMToday
 │   └FMNow
 ├TResponses.FindResponseByName
 ├TResponses.Clear
 ├TResponses.Update
 │ ├TResponses.FindResponseByName
 │ └TResponses.IENForPrompt
 ├IsNumericRate
 └TResponses.GetOrderText
   ├TResponses.NextInstance
   ├TResponses.FindResponseByName
   ├TResponses.FormatResponse
   │ └TResponses.FindResponseByIEN
   └TResponses.AppendChildren
     ├TResponses.FindPromptByIEN
     ├TResponses.FindResponseByIEN
     └TResponses.FormatResponse...

Called-By Hierarchy


             TfrmODMedIV.ControlChange
  TfrmODMedIV.SetValuesFromResponses┤ 
           TfrmODMedIV.SetupDialog┤ │ 
 TfrmODMedIV.cboSolutionMouseClick┘ │ 
     TfrmODMedIV.cboSolutionExit┘   │ 
           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
TResponses.Clear procedure Clear; overload; -
TResponses.FindResponseByName function FindResponseByName(const APromptID: string; AnInstance: Integer): TResponse; -
TResponses.GetOrderText function GetOrderText: string; -
IsNumericRate function IsNumericRate(const x: string): Boolean; -
TfrmODMedIV.loadExpectFirstDose procedure loadExpectFirstDose; -
TResponses.Update procedure Update(const APromptID: string; AnInstance: Integer; const AnIValue, AnEValue: string); -

Called-By

Name Declaration Comments
TfrmODMedIV.cboAddFreqCloseUp procedure cboAddFreqCloseUp(Sender: TObject); -
TfrmODMedIV.cboAdditiveMouseClick procedure cboAdditiveMouseClick(Sender: TObject); -
TfrmODMedIV.cboDurationChange procedure cboDurationChange(Sender: TObject); -
TfrmODMedIV.cboInfusionTimeChange procedure cboInfusionTimeChange(Sender: TObject); -
TfrmODMedIV.cboPriorityChange procedure cboPriorityChange(Sender: TObject); -
TfrmODMedIV.cboRouteChange procedure cboRouteChange(Sender: TObject); -
TfrmODMedIV.cboScheduleChange procedure cboScheduleChange(Sender: TObject); -
TfrmODMedIV.cboSelectedCloseUp procedure cboSelectedCloseUp(Sender: TObject); -
TfrmODMedIV.cboSolutionMouseClick procedure cboSolutionMouseClick(Sender: TObject); -
TfrmODMedIV.cboTypeChange procedure cboTypeChange(Sender: TObject); -
TfrmODMedIV.chkDoseNowClick procedure chkDoseNowClick(Sender: TObject); -
TfrmODMedIV.chkPRNClick procedure chkPRNClick(Sender: TObject); -
TfrmODMedIV.cmdRemoveClick procedure cmdRemoveClick(Sender: TObject); -
TfrmODMedIV.SetValuesFromResponses procedure SetValuesFromResponses; -
TfrmODMedIV.txtRateChange procedure txtRateChange(Sender: TObject); -
TfrmODMedIV.txtSelectedChange procedure txtSelectedChange(Sender: TObject); -
TfrmODMedIV.txtXDurationChange procedure txtXDurationChange(Sender: TObject); -
TfrmODMedIV.txtXDurationExit procedure txtXDurationExit(Sender: TObject); -


Source

1931  procedure TfrmODMedIV.ControlChange(Sender: TObject);
1932  var
1933    i, CurAdd, CurBase, idx: Integer;
1934    adminTime,x,xlimIn,xLimEx,eSch,iSch,iType, tmpdur, tmpSch, tmpRate: string;
1935    AnIVComponent: TIVComponent;
1936    FQOSchedule: TResponse;
1937  
1938    function IsNumericRate(const x: string): Boolean;
1939    var
1940      i: Integer;
1941    begin
1942      Result := True;
1943      for i := 1 to Length(x) do if not (x[i] in ['0'..'9','.']) then Result := False;
1944    end;
1945  
1946  begin
1947    inherited;
1948    if Changing then Exit;
1949    loadExpectFirstDose;
1950  //  FQOSchedule := TResponse.Create;
1951    FQOSchedule := Responses.FindResponseByName('SCHEDULE',1);
1952    if FQOSchedule <> nil then
1953    begin
1954      eSch := FQOSchedule.EValue;
1955      iSch := FQOSchedule.IValue;
1956    end;
1957    //if Sender <> Self then Responses.Clear;       // Sender=Self when called from SetupDialog
1958    Responses.Clear;   // want this to clear even after SetupDialog in case instances don't match
1959    CurAdd := 1; CurBase := 1;
1960    tmpRate := '';
1961    with grdSelected do for i := 0 to RowCount - 1 do
1962    begin
1963      AnIVComponent := TIVComponent(Objects[0, i]);
1964      if AnIVComponent = nil then Continue;
1965      with AnIVComponent do
1966      begin
1967        if Fluid = 'B' then                        // Solutions
1968        begin
1969          if IEN > 0                then Responses.Update('ORDERABLE', CurBase, IntToStr(IEN), Name);
1970          if Length(Cells[1,i]) > 0 then Responses.Update('VOLUME',    CurBase, Cells[1,i], Cells[1,i]);
1971          Inc(CurBase);
1972        end; {if Fluid B}
1973        if Fluid = 'A' then                        // Additives
1974        begin
1975          if IEN > 0                then Responses.Update('ADDITIVE', CurAdd, IntToStr(IEN), Name);
1976          if Length(Cells[1,i]) > 0 then Responses.Update('STRENGTH', CurAdd, Cells[1,i], Cells[1,i]);
1977          if Length(Cells[2,i]) > 0 then Responses.Update('UNITS',    CurAdd, Cells[2,i], Cells[2,i]);
1978          //AGP ADDITIVE FREQUECNY CHANGES
1979          if (Length(Cells[3,i]) > 0) and (Cells[3,i] <> 'N/A') then Responses.Update('ADDFREQ',    CurAdd, Cells[3,i], Cells[3,i]);
1980          Inc(CurAdd);
1981        end; {if Fluid A}
1982      end; {with AnIVComponent}
1983    end; {with grdSelected}
1984    x := txtRate.Text;
1985    xlimIn := '';
1986    xlimEx := '';
1987    if length(txtXDuration.Text) > 0 then
1988    begin
1989      tmpDur := LowerCase(cboDuration.Text);
1990      if (tmpDur = 'l') or (tmpDur = 'ml') then
1991      begin
1992        xlimEx := 'with total volume ' +  txtXDuration.Text + self.cboDuration.items.strings[self.cboDuration.itemindex];
1993        xlimIn := 'with total volume ' +  txtXDuration.Text + self.cboDuration.items.strings[self.cboDuration.itemindex];
1994      end
1995      else if (tmpDur = 'days') or (tmpDur = 'hours') then
1996      begin
1997        xlimEx := 'for ' + txtXDuration.Text + ' ' +  self.cboDuration.items.strings[self.cboDuration.itemindex];
1998        xlimIn := 'for ' + txtXDuration.Text + ' ' +  self.cboDuration.items.strings[self.cboDuration.itemindex];
1999      end
2000      else if tmpDur = 'doses' then
2001        begin
2002           xlimEx := 'for a total of ' + txtXDuration.Text + ' ' +  self.cboDuration.items.strings[self.cboDuration.itemindex];
2003           xlimIn := 'for a total of ' + txtXDuration.Text + ' ' +  self.cboDuration.items.strings[self.cboDuration.itemindex];
2004        end
2005     else  begin
2006        xlimIn := '';
2007        xlimEx := '';
2008      end;
2009    end;
2010    if (cboType.ItemIndex > -1) and (cboType.Items.Strings[cboType.ItemIndex] = 'Intermittent') then iType := 'I'
2011    else if (cboType.ItemIndex > -1) and (cboType.Items.Strings[cboType.ItemIndex] = 'Continuous') then iType := 'C'
2012    else iType := '';
2013    Responses.Update('TYPE',1,iType,cboType.Text);
2014    Responses.Update('ROUTE',1,cboRoute.ItemID,cboRoute.Text);
2015    tmpSch := UpperCase(Trim(cboSchedule.Text));
2016    if chkPRN.Checked then tmpSch := tmpSch + ' PRN';
2017    if UpperCase(Copy(tmpSch, Length(tmpSch) - 6, Length(tmpSch))) = 'PRN PRN'
2018    then tmpSch := Copy(tmpSch, 1, Length(tmpSch) - 4);
2019    Responses.Update('SCHEDULE',1,tmpSch,tmpSch);
2020    (*adminTime := Piece(lblAdminTime.Caption,':',2);
2021    adminTime := Copy(adminTime,1,Length(adminTime));
2022    if (Action in [ORDER_COPY, ORDER_EDIT]) and ((FAdminTimeDelay <> '') or (FAdminTimeClinic <> '')) and
2023        (cboSchedule.ItemIndex = FOriginalScheduleIndex) then  Responses.Update('ADMIN',1,FOriginalAdminTime,FOriginalAdminTime)
2024    else Responses.Update('ADMIN',1,adminTime,adminTime);*)
2025    idx := self.cboSchedule.ItemIndex;
2026    if idx > -1 then
2027       begin
2028         adminTime := Piece(lblAdminTime.Caption,':',2);
2029         adminTime := Copy(adminTime,2,Length(adminTime));
2030         if FAdminTimeText <> '' then AdminTime :=  '';
2031         if AdminTime = 'Not Defined' then AdminTime := '';
2032         Responses.Update('ADMIN',1,adminTime,adminTime);
2033       end;
2034    if IsNumericRate(x) then
2035      begin
2036        if cboInfusionTime.Enabled = true then
2037          begin
2038             idx := cboInfusionTime.Items.IndexOf(cboInfusionTime.Text);
2039             if idx > -1 then x := x + ' ' + cboInfusionTime.Items.Strings[idx];
2040             tmpRate := 'Infuse Over ' + x;
2041          end
2042        else
2043          if pos('ml/hr', x)= 0 then  x := x + ' ml/hr';
2044      end;
2045    if (Pos('@',x)>0) and (Piece(x,'@',1) = IntToStr(StrToIntDef(Piece(x,'@',1), -1))) and (cboInfusionTime.Enabled = false) then
2046      begin
2047        if Pos('ml/hr', x) = 0 then
2048           x := Piece(x,'@',1) + ' ml/hr@' + Copy(x, Pos('@',x) + 1, Length(x));
2049      end;
2050    with txtRate     do if (Length(Text) > 0) then
2051      begin
2052        if tmpRate = '' then Responses.Update('RATE', 1, x, x)
2053        else Responses.Update('RATE', 1, 'INFUSE OVER ' + x, tmpRate);
2054      end;
2055    with cboPriority do if ItemIndex > -1     then Responses.Update('URGENCY', 1, ItemID, Text);
2056    if Length(xlimIn)>0 then Responses.Update('DAYS',1, xlimIn, xlimEx);
2057    with memComments do if GetTextLen > 0     then Responses.Update('COMMENT', 1, TX_WPTYPE, Text);
2058    if (chkDoseNow.Visible = True) and (chkDoseNow.Checked = True) then
2059      Responses.Update('NOW', 1, '1', 'NOW')
2060    else Responses.Update('NOW', 1, '', '');
2061    memOrder.Text := Responses.OrderText;
2062    (* (Length(eSch)>0) or (Length(iSch)>0) then
2063      Responses.Update('SCHEDULE',1,iSch,eSch);  *)
2064  end;