Procedure

TfrmODMeds.ControlChange

Module

fODMeds

Last Modified

7/15/2014 3:26:42 PM

Visibility

Public/Published

Owner

TfrmODMeds

Declaration

procedure ControlChange(Sender: TObject);

Calls Hierarchy


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...

Called-By Hierarchy


              TfrmODMeds.ControlChange
              TfrmODMeds.SetupDialog┤ 
                 TfrmODMeds.Validate┤ 
           TfrmODMeds.btnSelectClick┤ 
           TfrmODMeds.UMDelayClick┘ │ 
            TfrmODMeds.tabDoseChange┤ 
            TfrmODMeds.FormKeyDown┘ │ 
           TfrmODMeds.cboRouteChange┤ 
         TfrmODMeds.SetOnMedSelect┘ │ 
          TfrmODMeds.SetupDialog┤   │ 
    TfrmODMeds.btnSelectClick...┤   │ 
     TfrmODMeds.CheckFormAltDose┘   │ 
     TfrmODMeds.cboDosageClick┘     │ 
   TfrmODMeds.cboDosageKeyUp┘       │ 
         TfrmODMeds.popDurationClick┤ 
          TfrmODMeds.cboXRouteChange┤ 
           TfrmODMeds.cboXRouteClick┤ 
          TfrmODMeds.cboXRouteExit┘ │ 
       TfrmODMeds.txtXDurationChange┤ 
       TfrmODMeds.popDurationClick┘ │ 
          TfrmODMeds.btnXRemoveClick┤ 
        TfrmODMeds.grdDosesKeyDown┘ │ 
     TfrmODMeds.timCheckChangesTimer┤ 
          TfrmODMeds.UpdateRelated┘ │ 
          TfrmODMeds.SetupDialog┤   │ 
    TfrmODMeds.btnSelectClick...┤   │ 
    TfrmODMeds.cboDosageClick...┤   │ 
      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.pnlXDurationExit┤   │ 
          TfrmODMeds.chkPRNClick┤   │ 
      TfrmODMeds.cboScheduleExit┤   │ 
       TfrmODMeds.cboDosageKeyUp┤   │ 
      TfrmODMeds.cboXDosageKeyUp┘   │ 
       TfrmODMeds.chkPtInstructClick┤ 
          TfrmODMeds.chkDoseNowClick┤ 
        TfrmODMeds.SetOnQuickOrder┘ │ 
          TfrmODMeds.SetupDialog┤   │ 
    TfrmODMeds.btnSelectClick...┘   │ 
              TfrmODMeds.chkPRNClick┤ 
       TfrmODMeds.cboXSequenceChange┤ 
         TfrmODMeds.txtRefillsChange┘ 

Calls

Name Declaration Comments
TResponses.Clear procedure Clear; overload; -
TfrmODMeds.ConstructedDoseFields function ConstructedDoseFields(const ADose: string; PrependName: Boolean = FALSE): string; -
TfrmODMeds.FindCommonDrug function FindCommonDrug(DoseList: TStringList): string; -
TResponses.GetOrderText function GetOrderText: string; -
TfrmODMeds.InpatientSig function InpatientSig: string; -
TfrmODMeds.lblAdminSchGetText function lblAdminSchGetText: string; -
TfrmODMeds.OutpatientSig function OutpatientSig: string; -
TResponses.Update procedure Update(const APromptID: string; AnInstance: Integer; const AnIValue, AnEValue: string); -
TfrmODMeds.ValFor function ValFor(FieldID, ARow: Integer): string; -
TfrmODMeds.ValueOf function ValueOf(FieldID: Integer; ARow: Integer = -1): string; -

Called-By

Name Declaration Comments
TfrmODMeds.btnSelectClick procedure btnSelectClick(Sender: TObject); -
TfrmODMeds.btnXRemoveClick procedure btnXRemoveClick(Sender: TObject); -
TfrmODMeds.cboRouteChange procedure cboRouteChange(Sender: TObject); -
TfrmODMeds.cboXRouteChange procedure cboXRouteChange(Sender: TObject); -
TfrmODMeds.cboXRouteClick procedure cboXRouteClick(Sender: TObject); -
TfrmODMeds.cboXSequenceChange procedure cboXSequenceChange(Sender: TObject); -
TfrmODMeds.chkDoseNowClick procedure chkDoseNowClick(Sender: TObject); -
TfrmODMeds.chkPRNClick procedure chkPRNClick(Sender: TObject); -
TfrmODMeds.chkPtInstructClick procedure chkPtInstructClick(Sender: TObject); -
TfrmODMeds.popDurationClick procedure popDurationClick(Sender: TObject); -
TfrmODMeds.SetupDialog procedure SetupDialog(OrderAction: Integer; const ID: string); override; -
TfrmODMeds.tabDoseChange procedure tabDoseChange(Sender: TObject); -
TfrmODMeds.timCheckChangesTimer procedure timCheckChangesTimer(Sender: TObject); -
TfrmODMeds.txtRefillsChange procedure txtRefillsChange(Sender: TObject); -
TfrmODMeds.txtXDurationChange procedure txtXDurationChange(Sender: TObject); -
TfrmODMeds.Validate procedure Validate(var AnErrMsg: string); override; -


Source

3071  procedure TfrmODMeds.ControlChange(Sender: TObject);
3072  var
3073    x,ADose,AUnit,ADosageText: string;
3074    i, LastDose: Integer;
3075    DoseList: TStringList;
3076  begin
3077    inherited;
3078    if csLoading in ComponentState then Exit;       // to prevent error caused by txtRefills
3079    if Changing then Exit;
3080    if txtMed.Tag = 0 then Exit;
3081    ADose := '';
3082    AUnit := '';
3083    ADosageText := '';
3084    FUpdated := FALSE;
3085    Responses.Clear;
3086    if self.MedName = '' then Responses.Update('ORDERABLE',  1, IntToStr(txtMed.Tag), txtMed.Text)
3087    else Responses.Update('ORDERABLE',  1, IntToStr(txtMed.Tag), self.MedName);
3088    DoseList := TStringList.Create;
3089    case tabDose.TabIndex of
3090    TI_DOSE:
3091      begin
3092        if (cboDosage.ItemIndex < 0) and (Length(cboDosage.Text) > 0) then
3093        begin
3094          // try to resolve freetext dose and add it as a new item to the combobox
3095          ADosageText := cboDosage.Text;
3096          ADose := Piece(ADosageText,' ',1);
3097          Delete(ADosageText,1,Length(ADose)+1);
3098          ADosageText := ADose + Trim(ADosageText);
3099          DoseList.Add(ADosageText);
3100          FDrugID := FindCommonDrug(DoseList);
3101          if FDrugID <> '' then
3102          begin
3103            if ExtractFloat(cboDosage.Text) > 0 then
3104            begin
3105              x := ConstructedDoseFields(cboDosage.Text, TRUE);
3106              FDrugID := '';
3107              with cboDosage do ItemIndex := cboDosage.Items.Add(x);
3108            end;
3109          end;
3110        end;
3111        x := ValueOf(FLD_DOSETEXT);    Responses.Update('INSTR',    1, x,  x);
3112        x := ValueOf(FLD_DRUG_ID);     Responses.Update('DRUG',     1, x, '');
3113        x := ValueOf(FLD_DOSEFLDS);    Responses.Update('DOSE',     1, x, '');
3114        x := ValueOf(FLD_STRENGTH);
3115        // if outpt or inpt order with no total dose (i.e., topical)
3116        if (not FInptDlg) or (ValueOf(FLD_TOTALDOSE) = '')
3117                                  then Responses.Update('STRENGTH', 1, x,  x);
3118        // if no strength for dosage, use dispense drug name
3119        if Length(x) = 0 then
3120        begin
3121          x := ValueOf(FLD_DRUG_NM);
3122          if Length(x) > 0        then Responses.Update('NAME',     1, x,  x);
3123        end;
3124        x := ValueOf(FLD_ROUTE_AB);
3125        if Length(x) = 0 then x := ValueOf(FLD_ROUTE_NM);
3126        if Length(ValueOf(FLD_ROUTE_ID)) > 0
3127                                  then Responses.Update('ROUTE',    1, ValueOf(FLD_ROUTE_ID), x)
3128                                  else Responses.Update('ROUTE',    1, '', x);
3129        x := ValueOf(FLD_SCHEDULE);    Responses.Update('SCHEDULE', 1, x,  x);
3130        if FInptDlg then
3131          begin
3132          (* AGP Change Admin Time Wrap 27.73
3133            x := Piece(self.lblAdminSch.text,':',2);
3134            x := Copy(x,2,Length(x));  *)
3135            x := lblAdminSchGetText;
3136            if FAdminTimeText <> '' then x := '';
3137            if x = 'Not Defined' then x := '';
3138            Responses.Update('ADMIN',1,x,x);
3139            X := ValueOf(FLD_SCHED_TYP);
3140            if self.chkPRN.Checked = true then x := 'P';
3141            Responses.Update('SCHTYPE',1,x,x);
3142          end;
3143      end;
3144    TI_COMPLEX:
3145      begin
3146        //if txtNss.Visible then txtNss.Visible := False;
3147        with grdDoses do for i := 1 to Pred(RowCount) do
3148        begin
3149          x := Piece(Piece(grdDoses.Cells[COL_DOSAGE, i], TAB, 2), U, 5);
3150          if x = '' then x := Piece(grdDoses.Cells[COL_DOSAGE, i], TAB, 1);
3151          if x = '' then Continue;
3152          x := x + U + Piece(Piece(grdDoses.Cells[COL_DOSAGE, i], U, 4), '&', 6);
3153          DoseList.Add(x);
3154        end;
3155        FDrugID := FindCommonDrug(DoseList);
3156        if FDrugID <> '' then                       // common drug found
3157        begin
3158          x := ValueOf(FLD_STRENGTH, 1);
3159          if (not FInptDlg) or (ValueOf(FLD_TOTALDOSE, 1) = '')
3160                                  then    Responses.Update('STRENGTH', 1, x, x);
3161          // if no strength, use dispense drug
3162          if Length(x) = 0 then
3163          begin
3164            x := ValueOf(FLD_DRUG_NM, 1);
3165            if Length(x) > 0      then    Responses.Update('NAME',     1, x, x);
3166          end;
3167          Responses.Update('DRUG', 1, FDrugID, '');
3168        end; {if FDrugID}
3169        LastDose := 0;
3170        with grdDoses do for i := 1 to Pred(RowCount) do
3171          if Length(ValueOf(FLD_DOSETEXT, i)) > 0 then LastDose := i;
3172        with grdDoses do for i := 1 to Pred(RowCount) do
3173        begin
3174          if Length(ValueOf(FLD_DOSETEXT, i)) = 0 then Continue;
3175          x := ValueOf(FLD_DOSETEXT, i);  Responses.Update('INSTR',    i, x, x);
3176          x := ValueOf(FLD_DOSEFLDS, i);  Responses.Update('DOSE',     i, x, '');
3177          x := ValueOf(FLD_ROUTE_AB, i);
3178          if Length(x) = 0 then x := ValueOf(FLD_ROUTE_NM, i);
3179          if Length(ValueOf(FLD_ROUTE_ID, i)) > 0
3180                                     then Responses.Update('ROUTE',    i, ValueOf(FLD_ROUTE_ID, i), x)
3181                                     else Responses.Update('ROUTE',    i, '', x);
3182          x := ValueOf(FLD_SCHEDULE, i);  Responses.Update('SCHEDULE', i, x, x);
3183          if FSmplPRNChkd then   // GE CQ7585  Carry PRN checked from simple to complex tab
3184          begin
3185             pnlXSchedule.Tag := 1;
3186             chkXPRN.Checked := True;
3187            //cboXScheduleClick(Self);// force onclick to fire when complex tab is entered
3188             FSmplPRNChkd := False;
3189          end;
3190          x := ValueOf(FLD_DURATION, i);  Responses.Update('DAYS',     i, UpperCase(x), x);
3191          if FInptDlg then
3192            begin
3193              x := ValFor(VAL_ADMINTIME,i);
3194              if FAdminTimeText <> '' then x := '';
3195              if x = 'Not Defined' then x := '';
3196              Responses.Update('ADMIN',i,x,x);
3197              x := ValueOf(FLD_SCHED_TYP, i);
3198              if ValFor(VAL_CHKXPRN, i) = '1' then x := 'P';
3199              Responses.Update('SCHTYPE', i, x, x);
3200            end;
3201          x := ValueOf(FLD_SEQUENCE, i);
3202          if      Uppercase(x) = 'THEN'   then x := 'T'
3203          else if Uppercase(x) = 'AND'    then x := 'A'
3204          else if Uppercase(x) = 'EXCEPT' then x := 'X'
3205          else x := '';
3206          if  i = LastDose then  x := '';            // no conjunction for last dose
3207          Responses.Update('CONJ',     i, x, x);
3208        end; {with grdDoses}
3209      end; {TI_COMPLEX}
3210    end; {case TabDose.TabIndex}
3211    DoseList.Free;
3212    Responses.Update('URGENCY',   1, ValueOf(FLD_PRIOR_ID), '');
3213    Responses.Update('COMMENT',   1, TX_WPTYPE, ValueOf(FLD_COMMENT));
3214    if FInptDlg then                       // inpatient orders
3215    begin
3216      Responses.Update('NOW',     1, ValueOf(FLD_NOW_ID), ValueOf(FLD_NOW_NM));
3217      x := InpatientSig;
3218      Responses.Update('SIG',     1, TX_WPTYPE, x);
3219    end else                                        // outpatient orders
3220    begin
3221      x := ValueOf(FLD_SUPPLY);           Responses.Update('SUPPLY',  1, x,  x);
3222      x := ValueOf(FLD_QUANTITY);         Responses.Update('QTY',     1, x,  x);
3223      x := ValueOf(FLD_REFILLS);          Responses.Update('REFILLS', 1, x,  x);
3224      x := ValueOf(FLD_SC);               Responses.Update('SC',      1, x, '');
3225      x := ValueOf(FLD_PICKUP);           Responses.Update('PICKUP',  1, x, '');
3226      x := ValueOf(FLD_PTINSTR);          Responses.Update('PI',      1, TX_WPTYPE, x);
3227      x := '';
3228      x := OutpatientSig;                 Responses.Update('SIG',     1, TX_WPTYPE, x);
3229    end;
3230    memOrder.Text := Responses.OrderText;
3231  end;