Function

TfrmODMeds.ValueOf

Module

fODMeds

Last Modified

7/15/2014 3:26:42 PM

Comments

Contents of cboDosage
    DrugName^Strength^NF^TDose&Units&U/D&Noun&LDose&Drug^DoseText^CostText^MaxRefills
  Contents of grid cells  (Only the first tab piece for each cell is drawn)
    Dosage    <TAB> DosageFields
    RouteText <TAB> IEN^RouteName^Abbreviation
    Schedule  <TAB> (nothing)
    Duration  <TAB> Duration^Units 






 the following functions were created to get rid of a compile warning saying the
 return value may be undefined - too much branching logic in the case statements
 for the compiler to handle

Visibility

Private

Owner

TfrmODMeds

Declaration

function ValueOf(FieldID: Integer; ARow: Integer = -1): string;

Calls Hierarchy


TfrmODMeds.ValueOf
 ├GetSingleDoseSchedule
 ├GetSingleDoseScheduleEX
 ├TfrmODMeds.FieldsForDose
 │ └TfrmODMeds.ConstructedDoseFields
 ├TfrmODMeds.FieldsForDrug
 ├GetComplexDoseSchedule
 │ └TfrmODMeds.ValFor
 └GetComplexDoseScheduleEX
   └TfrmODMeds.ValFor

Called-By Hierarchy


                        TfrmODMeds.ValueOf
                   TfrmODMeds.InitDialog┤ 
                 TfrmODMeds.FormCreate┘ │ 
               TfrmODMeds.SetOnMedSelect┤ 
                TfrmODMeds.SetupDialog┤ │ 
             TfrmODMeds.btnSelectClick┤ │ 
             TfrmODMeds.UMDelayClick┘ │ │ 
           TfrmODMeds.CheckFormAltDose┘ │ 
           TfrmODMeds.cboDosageClick┘   │ 
         TfrmODMeds.cboDosageKeyUp┘     │ 
              TfrmODMeds.SetOnQuickOrder┤ 
                TfrmODMeds.SetupDialog┤ │ 
          TfrmODMeds.btnSelectClick...┘ │ 
            TfrmODMeds.cboDosageClick...┤ 
         TfrmODMeds.QuantityMessageCheck┤ 
            TfrmODMeds.cboXDosageEnter┤ │ 
    TfrmODMeds.pnlXDurationButtonEnter┤ │ 
             TfrmODMeds.cboXRouteEnter┤ │ 
          TfrmODMeds.cboXSequenceEnter┤ │ 
          TfrmODMeds.cboXScheduleEnter┘ │ 
                TfrmODMeds.OutpatientSig┤ 
              TfrmODMeds.ControlChange┘ │ 
              TfrmODMeds.SetupDialog┤   │ 
                 TfrmODMeds.Validate┤   │ 
        TfrmODMeds.btnSelectClick...┤   │ 
            TfrmODMeds.tabDoseChange┤   │ 
            TfrmODMeds.FormKeyDown┘ │   │ 
           TfrmODMeds.cboRouteChange┤   │ 
      TfrmODMeds.SetOnMedSelect...┘ │   │ 
         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.chkPRNClick┤   │ 
       TfrmODMeds.cboXSequenceChange┤   │ 
         TfrmODMeds.txtRefillsChange┘   │ 
                 TfrmODMeds.InpatientSig┤ 
           TfrmODMeds.ControlChange...┘ │ 
             TfrmODMeds.ControlChange...┤ 
           TfrmODMeds.cboXDosageClick...┤ 
      TfrmODMeds.timCheckChangesTimer...┘ 

Calls

Name Declaration Comments
TfrmODMeds.FieldsForDose function FieldsForDose(ARow: Integer): string; -
TfrmODMeds.FieldsForDrug function FieldsForDrug(const DrugID: string): string; -
GetComplexDoseSchedule function GetComplexDoseSchedule: string; -
GetComplexDoseScheduleEX function GetComplexDoseScheduleEX: string; -
GetSingleDoseSchedule function GetSingleDoseSchedule: string; -
GetSingleDoseScheduleEX function GetSingleDoseScheduleEX: string; -

Called-By

Name Declaration Comments
TfrmODMeds.cboDosageClick procedure cboDosageClick(Sender: TObject); -
TfrmODMeds.cboXDosageClick procedure cboXDosageClick(Sender: TObject); -
TfrmODMeds.ControlChange procedure ControlChange(Sender: TObject); -
TfrmODMeds.InitDialog procedure InitDialog; override; -
TfrmODMeds.InpatientSig function InpatientSig: string; -
TfrmODMeds.OutpatientSig function OutpatientSig: string; -
TfrmODMeds.QuantityMessageCheck procedure QuantityMessageCheck(Tag: integer) ; -
TfrmODMeds.SetOnMedSelect procedure SetOnMedSelect; -
TfrmODMeds.SetOnQuickOrder procedure SetOnQuickOrder; -
TfrmODMeds.timCheckChangesTimer procedure timCheckChangesTimer(Sender: TObject); -


Source

4056  function TfrmODMeds.ValueOf(FieldID: Integer; ARow: Integer = -1): string;
4057  var
4058    x: string;
4059  { Contents of cboDosage
4060      DrugName^Strength^NF^TDose&Units&U/D&Noun&LDose&Drug^DoseText^CostText^MaxRefills
4061    Contents of grid cells  (Only the first tab piece for each cell is drawn)
4062      Dosage    <TAB> DosageFields
4063      RouteText <TAB> IEN^RouteName^Abbreviation
4064      Schedule  <TAB> (nothing)
4065      Duration  <TAB> Duration^Units }
4066  
4067    // the following functions were created to get rid of a compile warning saying the
4068    // return value may be undefined - too much branching logic in the case statements
4069    // for the compiler to handle
4070    
4071    function GetSingleDoseSchedule: string;
4072    begin
4073      Result := UpperCase(Trim(cboSchedule.Text));
4074      if chkPRN.Checked then Result := Result + ' PRN';
4075      if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN'
4076        then Result := Copy(Result, 1, Length(Result) - 4);
4077    end;
4078  
4079    function GetSingleDoseScheduleEX: string;
4080    begin
4081      Result := '';
4082      with cboSchedule do
4083      begin
4084        if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 2);
4085  (*     if (Length(Result)=0) and (ItemIndex > -1) then
4086          begin
4087            Result := Piece(Items[ItemIndex], U, 1);
4088            if Piece(Items[ItemIndex], U, 3) = 'P' then
4089            begin
4090              if RightStr(Result,3) = 'PRN' then
4091                begin
4092                  Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
4093                  if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
4094                  Result := Copy(Result,1,Length(Result)-1);
4095                end;
4096             Result := Result + ' AS NEEDED';
4097            end;
4098          end;
4099      end; *)
4100        if RightStr(Result,3) = 'PRN' then
4101        begin
4102          Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
4103          if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
4104            Result := Copy(Result,1,Length(Result)-1);
4105          Result := Result + ' AS NEEDED'
4106        end;
4107        if (Length(Result) > 0) and chkPRN.Checked then
4108          Result := Result + ' AS NEEDED';
4109        if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' then
4110          Result := Copy(Result, 1, Length(Result) - 10);
4111        if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then
4112        begin
4113          Result := Copy(Result, 1, Length(Result) - 13);
4114          if RightStr(Result,1)=' ' then
4115            Result := Result + 'AS NEEDED'
4116          else
4117            Result := Result + ' AS NEEDED';
4118        end;
4119      end;
4120    end;
4121  
4122    function GetComplexDoseSchedule: string;
4123    begin
4124      with grdDoses do
4125      begin
4126        Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1);
4127        if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
4128        if ValFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' PRN';
4129        if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' then
4130        Result := Copy(Result, 1, Length(Result) - 4);
4131      end;
4132    end;
4133  
4134    function GetComplexDoseScheduleEX: string;
4135    begin
4136      with grdDoses do
4137      begin
4138        (*Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 2);
4139        if Result = '' then //Added for CQ: 7639
4140        begin
4141          Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
4142          if RightStr(Result,4) = ' PRN' then
4143            Result := Copy(Result,1,Length(Result)-4); //Remove the Trailing PRN
4144        end;
4145        if (Piece(Cells[COL_SCHEDULE, ARow], TAB, 1) <>
4146           Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1)) and
4147           (Pos('PRN', Piece(Cells[COL_SCHEDULE, ARow], TAB, 1)) > 0)
4148           then Result := Result + ' AS NEEDED';
4149      end;*)
4150        Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,2);
4151        if Result = '' then Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,1); //Added for CQ: 7639
4152        if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
4153        if RightStr(Result,3) = 'PRN' then
4154        begin
4155          Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
4156          if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
4157          Result := Copy(Result,1,Length(Result)-1);
4158          Result := Result + ' AS NEEDED';
4159        end;
4160        if ValFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' AS NEEDED';
4161        if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED'
4162        then Result := Copy(Result, 1, Length(Result) - 10);
4163        if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then
4164        begin
4165          Result := Copy(Result, 1, Length(Result) - 13);
4166          if RightStr(Result,1)=' ' then Result := Result + 'AS NEEDED'
4167          else Result := Result + ' AS NEEDED';
4168        end;
4169      end;
4170    end;
4171    
4172  begin
4173    Result := '';
4174    if ARow < 0 then                                // use single dose controls
4175    begin
4176      case FieldID of
4177      FLD_DOSETEXT  : with cboDosage do
4178                        if ItemIndex > -1 then Result := Uppercase(Piece(Items[ItemIndex], U, 5))
4179                                          else Result := Uppercase(Text);
4180      FLD_LOCALDOSE : with cboDosage do
4181                        if ItemIndex > -1 then Result := Piece(Piece(Items[ItemIndex], U, 4), '&', 5)
4182                                          else Result := Uppercase(Text);
4183      FLD_STRENGTH  : with cboDosage do
4184                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 2);
4185      FLD_DRUG_ID   : with cboDosage do
4186                       if ItemIndex > -1  then Result := Piece(Piece(Items[ItemIndex], U, 4), '&', 6);
4187      FLD_DRUG_NM   : with cboDosage do
4188                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 1);
4189      FLD_DOSEFLDS  : with cboDosage do
4190                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 4);
4191      FLD_TOTALDOSE : with cboDosage do
4192                        if ItemIndex > -1 then Result := Piece(Piece(Items[ItemIndex], U, 4), '&', 1);
4193      FLD_UNITNOUN  : with cboDosage do
4194                        if ItemIndex > -1 then Result := Piece(Piece(Items[ItemIndex], U, 4), '&', 3) + ' '
4195                                                       + Piece(Piece(Items[ItemIndex], U, 4), '&', 4);
4196      FLD_ROUTE_ID  : with cboRoute do
4197                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 1);
4198      FLD_ROUTE_NM  : with cboRoute do
4199                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 2)
4200                                          else Result := Text;
4201      FLD_ROUTE_AB  : with cboRoute do
4202                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 3);
4203      FLD_ROUTE_EX  : with cboRoute do
4204                       if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 4);
4205      FLD_SCHEDULE  : begin      
4206                        Result := GetSingleDoseSchedule;
4207                      end;
4208      FLD_SCHED_EX  : begin
4209                        Result := GetSingleDoseScheduleEX;
4210                      end;
4211      FLD_SCHED_TYP : with cboSchedule do
4212                        if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 3);
4213      FLD_QTYDISP   : with cboDosage do
4214                        begin
4215                          if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 8);
4216                          if (Result = '') and (Items.Count > 0) then Result := Piece(Items[0], U, 8);
4217                          if Result <> ''
4218                            then Result := 'Qty (' + Result + ')'
4219                            else Result := 'Quantity';
4220                        end;
4221      end; {case FieldID}                           // use complex dose controls
4222    end else
4223    begin
4224      if (ARow < 1) or (ARow >= grdDoses.RowCount) then Exit;
4225      if Length(FDrugID) > 0
4226        then x := FieldsForDose(ARow)
4227        else x := Piece(Piece(grdDoses.Cells[COL_DOSAGE, ARow], TAB, 2), U, 4);
4228      with grdDoses do
4229        case FieldID of
4230        FLD_DOSETEXT  : Result := Uppercase(Piece(Cells[COL_DOSAGE, ARow], TAB, 1));
4231        FLD_LOCALDOSE : begin
4232                          if (Length(x) > 0) and (Length(FDrugID) > 0)
4233                            then Result := Piece(x, '&', 5)
4234                            else Result := Uppercase(Piece(Cells[COL_DOSAGE, ARow], TAB, 1));
4235                        end;
4236        FLD_STRENGTH  : Result := Piece(x, '&', 7) + Piece(x, '&', 8);
4237        FLD_DRUG_ID   : Result := Piece(x, '&', 6);
4238        FLD_DRUG_NM   : Result := Piece(FieldsForDrug(Piece(x, '&', 6)), U, 4);
4239        FLD_DOSEFLDS  : Result := x;
4240        FLD_TOTALDOSE : Result := Piece(x, '&', 1);
4241        FLD_UNITNOUN  : Result := Piece(x, '&', 3) + ' ' + Piece(x, '&', 4);
4242        FLD_ROUTE_ID  : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 1);
4243        FLD_ROUTE_NM  : begin
4244                          Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 2);
4245                          if Result = '' then Result := Piece(Cells[COL_ROUTE, ARow], TAB, 1);
4246                        end;
4247        FLD_ROUTE_AB  : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 3);
4248        FLD_ROUTE_EX  : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 4);
4249        FLD_SCHEDULE  : begin
4250                          Result := GetComplexDoseSchedule;
4251                        end;
4252        FLD_SCHED_EX  : begin
4253                          Result := GetComplexDoseScheduleEX;
4254                        end;
4255        FLD_SCHED_TYP : Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 3);
4256        FLD_DURATION  : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1);
4257        FLD_SEQUENCE  : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1);
4258        end; {case FieldID}
4259    end; {if ARow}
4260    if FieldID > FLD_MISC_FLDS then                 // still need to process 'non-sig' fields
4261    begin
4262      case FieldID of
4263      FLD_SUPPLY    : Result := Trim(txtSupply.Text);
4264      FLD_QUANTITY  :
4265      begin
4266         if Pos(',', txtQuantity.Text)>0 then
4267          Result := Piece(txtQuantity.Text,',',1) + Piece(txtQuantity.Text,',',2)
4268         else
4269          Result := Trim(txtQuantity.Text);
4270      end;
4271      FLD_REFILLS   : Result := txtRefills.Text;
4272      FLD_PICKUP    : if      radPickWindow.Checked then Result := 'W'
4273                      else if radPickMail.Checked   then Result := 'M'
4274                      else if radPickClinic.Checked then Result := 'C'
4275                      else Result := '';
4276      FLD_PRIOR_ID  : Result := cboPriority.ItemID;
4277      FLD_PRIOR_NM  : Result := cboPriority.Text;
4278      FLD_COMMENT   : Result := memComment.Text;
4279  
4280      FLD_NOW_ID    : if chkDoseNow.Visible and chkDoseNow.Checked then Result := '1'   else Result := '';
4281      FLD_NOW_NM    : if chkDoseNow.Visible and chkDoseNow.Checked then Result := 'NOW' else Result := '';
4282      FLD_PTINSTR   : if chkPtInstruct.Visible and chkPtInstruct.Checked
4283                        then Result := FPtInstruct
4284                        else Result := ' ';
4285      end; {case FieldID}
4286    end; {if FieldID}
4287  end;