Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/Orders/fODMedIV.pas

    r829 r1679  
    4545    txtAllIVRoutes: TLabel;
    4646    lblTypeHelp: TLabel;
     47    cboAddFreq: TCaptionComboBox;
     48    lblAddFreq: TLabel;
     49    lblPrevAddFreq: TLabel;
     50    lbl508Required: TVA508StaticText;
     51    VA508CompOrderSig: TVA508ComponentAccessibility;
     52    VA508CompRoute: TVA508ComponentAccessibility;
     53    VA508CompType: TVA508ComponentAccessibility;
     54    VA508CompSchedule: TVA508ComponentAccessibility;
     55    VA508CompGrdSelected: TVA508ComponentAccessibility;
    4756    procedure FormCreate(Sender: TObject);
    4857    procedure tabFluidChange(Sender: TObject);
     
    5968    procedure FormResize(Sender: TObject);
    6069    procedure txtSelectedExit(Sender: TObject);
    61     procedure cboSelectedExit(Sender: TObject);
    6270    procedure ControlChange(Sender: TObject);
    6371    procedure txtSelectedChange(Sender: TObject);
    64     procedure cboSelectedChange(Sender: TObject);
    6572    procedure grdSelectedDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
    6673      State: TGridDrawState);
     
    94101    procedure cboRouteClick(Sender: TObject);
    95102    procedure lblTypeHelpClick(Sender: TObject);
     103    procedure cboSelectedCloseUp(Sender: TObject);
     104    procedure cboRouteKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     105    procedure cboScheduleKeyUp(Sender: TObject; var Key: Word;
     106      Shift: TShiftState);
     107    procedure cboPriorityKeyUp(Sender: TObject; var Key: Word;
     108      Shift: TShiftState);
     109    procedure cboAddFreqKeyDown(Sender: TObject; var Key: Word;
     110      Shift: TShiftState);
     111    procedure cboAddFreqCloseUp(Sender: TObject);
     112    procedure FormKeyPress(Sender: TObject; var Key: Char);
     113    procedure txtSelectedKeyDown(Sender: TObject; var Key: Word;
     114      Shift: TShiftState);
     115    procedure cboSelectedKeyDown(Sender: TObject; var Key: Word;
     116      Shift: TShiftState);
     117    procedure cboTypeKeyDown(Sender: TObject; var Key: Word;
     118      Shift: TShiftState);
     119    procedure cboRouteKeyDown(Sender: TObject; var Key: Word;
     120      Shift: TShiftState);
     121    procedure cboScheduleKeyDown(Sender: TObject; var Key: Word;
     122      Shift: TShiftState);
     123    procedure VA508CompOrderSigStateQuery(Sender: TObject; var Text: string);
     124    procedure VA508CompRouteInstructionsQuery(Sender: TObject;
     125      var Text: string);
     126    procedure VA508CompTypeInstructionsQuery(Sender: TObject; var Text: string);
     127    procedure VA508CompScheduleInstructionsQuery(Sender: TObject;
     128      var Text: string);
     129    procedure VA508CompGrdSelectedCaptionQuery(Sender: TObject;
     130      var Text: string);
    96131  private
    97132    FInpatient: Boolean;
     
    102137    OSchedule: string;
    103138    oAdmin: string;
    104     Action: integer;
    105139    OrderIEN: string;
    106140    FAdminTimeText: string;
     
    108142    FOriginalDurationType: integer;
    109143    FOriginalInfusionType: integer;
    110     FInitialOrderID: boolean;
     144    FIVTypeDefined: boolean;
     145    //FInitialOrderID: boolean;
    111146    procedure SetValuesFromResponses;
    112147    procedure DoSetFontSize( FontSize: integer);
     
    119154    procedure UpdateDuration(SchType: string);
    120155    procedure ClearAllFields;
     156    function UpdateAddFreq(OI: integer): string;
     157    function IsAltCtrl_L_Pressed(Shift : TShiftState; Key : Word) : Boolean;
     158    procedure SetCtrlAlt_L_LabelAccessText(var Text: string; theLabel : TLabel);
    121159  public
     160    OrdAction: integer;
    122161    procedure InitDialog; override;
    123162    procedure SetupDialog(OrderAction: Integer; const ID: string); override;
     
    152191    Units: string;
    153192    Volumes: string;
     193    AddFreq: string;
    154194  end;
    155195
     
    168208  TX_BAD_ROUTE = 'Route cannot be free-text';
    169209  TX_LEADING_NUMERIC = 'this additive must start with a leading numeric value';
     210  TX_BAD_BAG = 'A valid additive frequency must be entered for ';
     211  Tx_BAG_NO_COMMENTS ='"See Comments" entered for additive ';
     212  TX_BAG_NO_COMMENTS1 = ' no comments defined for this order.';
    170213
    171214(*
     
    200243    Exit;
    201244  end;
     245  OrdAction := -1;
    202246  DoSetFontSize(MainFontSize);
    203247  FillerID := 'PSIV';                            // does 'on Display' order check **KCM**
     
    221265var
    222266bottom: integer;
    223 begin
    224   inherited;
     267isNewOrder: boolean;
     268begin
     269  inherited;
     270  if OrdAction in [ORDER_COPY, ORDER_EDIT] then isNewOrder := false
     271  else isNewOrder := True;
    225272  with grdSelected do
    226273  begin
    227274    ColWidths[1] := Canvas.TextWidth(' 10000 ') + GetSystemMetrics(SM_CXVSCROLL);
    228275    ColWidths[2] := Canvas.TextWidth('meq.') + GetSystemMetrics(SM_CXVSCROLL);
    229     ColWidths[0] := ClientWidth - ColWidths[1] - ColWidths[2] - 4;
     276    //AGP ADDITIVE FREQUENCY CHANGES
     277    ColWidths[3] := Canvas.TextWidth(lblAddFreq.Caption + '  ') + GetSystemMetrics(SM_CXVSCROLL);
     278     if IsNewOrder = false then
     279      begin
     280        ColWidths[4] := Canvas.TextWidth(lblPrevAddFreq.Caption) + GetSystemMetrics(SM_CXVSCROLL);
     281        ColWidths[0] := ClientWidth - ColWidths[1] - ColWidths[2] - ColWidths[3] - ColWidths[4] - 5;
     282      end
     283    else
     284      begin
     285        ColWidths[4] := 0;
     286        ColWidths[0] := ClientWidth - ColWidths[1] - ColWidths[2] - ColWidths[3] - ColWidths[4] - 25;
     287      end;
    230288  end;
    231289  lblAmount.Left := grdSelected.Left + grdSelected.ColWidths[0];
     290  lblAddFreq.Left := grdSelected.Left +  grdSelected.ColWidths[0] +  grdSelected.ColWidths[1] + grdSelected.ColWidths[2];
     291  if isNewOrder = false then
     292    begin
     293      lblPrevAddFreq.Visible := True;
     294      lblPrevAddFreq.Left := grdSelected.Left +  grdSelected.ColWidths[0] +  grdSelected.ColWidths[1] + grdSelected.ColWidths[2] + grdSelected.ColWidths[3];
     295    end
     296  else lblPrevAddFreq.Visible := False;
    232297  self.cboType.SelLength := 0;
    233298  self.cboInfusionTime.SelLength := 0;
     
    243308  self.lblAdminTime.Top := self.chkDoseNow.Top + self.chkDoseNow.Height + 2;
    244309  self.lblFirstDose.Top := self.lblAdminTime.Top + self.lblAdminTime.Height + 2;
    245   if self.Label1.Top < (self.lblFirstDose.Top + self.lblFirstDose.Height) then
    246     begin
    247       self.Label1.Top := self.lblFirstDose.Top + self.lblFirstDose.Height + 2;
     310  self.lbl508Required.Top := self.lblFirstDose.Top + self.lblFirstDose.Height + 5;
     311  if self.Label1.Top < (self.lbl508Required.Top + self.lbl508Required.Height) then
     312    begin
     313      self.Label1.Top := self.lbl508Required.Top + self.lbl508Required.Height + 5;
    248314      self.memOrder.Top := self.Label1.Top + self.Label1.Height;
    249315    end;
     
    262328  //FRouteConflict := False;
    263329  //lblTypeHelp.Hint := IVTypeHelpText;
     330  ClearAllFields;
     331  //FIVTypeDefined := false;
    264332  lblType.Hint := IVTypeHelpText;
    265333  cboType.Hint := IVTYpeHelpText;
     
    286354    //if (Patient.Inpatient) and (cboSchedule.Items.IndexOfName('Other')<0) then
    287355    if cboSchedule.Items.IndexOf('Other') = -1 then cboSchedule.Items.Add('OTHER');
    288 
    289356    cboSchedule.Enabled := False;
    290357    lblschedule.Enabled := False;
     
    310377    chkDoseNow.Visible := false;
    311378    chkPRN.Enabled := false;
     379    //AGP ADDITIVE FREQUENCY CHANGES
     380    if cboAddFreq.Items.Count = 0 then
     381      begin
     382        cboAddFreq.Items.Add('1 Bag/Day');
     383        cboAddFreq.Items.Add('All Bags');
     384        cboAddFreq.Items.Add('See Comments');
     385      end;
    312386  end;
    313387  tabFluid.TabIndex := 0;
     
    330404  oAdmin := '';
    331405  self.txtAllIVRoutes.Visible := false;
     406  memorder.text := '';
     407  memOrder.Lines.Clear;
    332408end;
    333409
     
    339415             CRLF + '     “over a specified time period” (e.g. “Infuse over 30 min.”).' + CRLF + CRLF +
    340416             'Examples:' + CRLF + 'Continuous = Infusion/drip' + CRLF + 'Intermittent = IVP/IVPB';
     417end;
     418
     419procedure TfrmODMedIV.SetCtrlAlt_L_LabelAccessText(var Text: string; theLabel : TLabel);
     420begin
     421  if theLabel.Visible then
     422    Text := 'Press Ctrl + Alt + L to access ' + theLabel.Caption;
    341423end;
    342424
     
    455537end;
    456538
     539procedure TfrmODMedIV.VA508CompRouteInstructionsQuery(
     540  Sender: TObject; var Text: string);
     541begin
     542  inherited;
     543  SetCtrlAlt_L_LabelAccessText(Text, txtAllIVRoutes);
     544end;
     545
     546procedure TfrmODMedIV.VA508CompScheduleInstructionsQuery(Sender: TObject;
     547  var Text: string);
     548begin
     549  inherited;
     550  SetCtrlAlt_L_LabelAccessText(Text, txtNSS);
     551end;
     552
     553procedure TfrmODMedIV.VA508CompTypeInstructionsQuery(Sender: TObject;
     554  var Text: string);
     555begin
     556  inherited;
     557  SetCtrlAlt_L_LabelAccessText(Text, lblTypeHelp);
     558end;
     559
     560procedure TfrmODMedIV.VA508CompGrdSelectedCaptionQuery(Sender: TObject;
     561  var Text: string);
     562begin
     563  inherited;
     564  if grdSelected.Col = 0 then
     565    Text := lblComponent.Caption
     566  else if grdSelected.Col = 1 then
     567    Text := lblAmount.Caption
     568  else if grdSelected.Col = 2 then
     569    Text := lblAmount.Caption + ', Unit'
     570  else if grdSelected.Col = 3 then
     571    Text := lblAddFreq.Caption
     572  else if grdSelected.Col = 4 then
     573    Text := lblPrevAddFreq.Caption;
     574end;
     575
     576procedure TfrmODMedIV.VA508CompOrderSigStateQuery(Sender: TObject;
     577  var Text: string);
     578begin
     579  inherited;
     580  Text := memOrder.Text;
     581end;
     582
    457583procedure TfrmODMedIV.Validate(var AnErrMsg: string);
    458584var
    459585  DispWarning, ItemOK, Result: Boolean;
    460   LDec,RDec,x, tempStr, iunit, infError: string;
     586  LDec,RDec,x, tempStr, iunit, infError, Bag: string;
    461587  digits, i, j, Len, temp, Value: Integer;
    462588
     
    499625                end;
    500626            end;
     627           //AGP ADDITIVE FREQUENCY CHANGES
     628           if MixedCase(self.cboType.Items.Strings[self.cboType.ItemIndex]) = 'Continuous' then
     629             begin
     630               Bag := (Cells[3, i]);
     631               if Length(Bag) = 0 then
     632                 begin
     633                   SetError(TX_BAD_BAG + cells[0, i]);
     634                 end
     635               else if cboAddFreq.Items.IndexOf(Bag) = -1 then
     636                  begin
     637                    SetError(TX_BAD_BAG + cells[0, i]);
     638                  end
     639               else if (MixedCase(Bag) = 'See Comments') and ((self.memComments.Text = '') or (self.memComments.Text = CRLF)) then
     640                  begin
     641                    SetError(Tx_BAG_NO_COMMENTS + cells[0,i] + Tx_BAG_NO_COMMENTS1);
     642                  end;
     643                   
     644             end;
    501645        end;
    502646  end;
     
    574718          else if (iunit = 'Hours') and (Len > 2) then setError('Infuse Over Time cannot exceed 2 spaces for ' + iunit);
    575719        end;
    576       if (cboSchedule.ItemIndex = -1) and (cboSchedule.Text = '')  then SetError(TX_NO_SCHEDULE);
     720      if (cboSchedule.ItemIndex = -1) and (cboSchedule.Text = '') and (chkPRN.Checked = false) then SetError(TX_NO_SCHEDULE);
     721      if (cboSchedule.ItemIndex > -1) and (cboSchedule.Text = '') then
     722        begin
     723          cboSchedule.ItemIndex := -1;
     724          SetError(TX_NO_SCHEDULE)
     725        end;
    577726      if (cboSchedule.ItemIndex = -1) and (cboSchedule.Text <> '') then SetError(TX_BAD_SCHEDULE);
    578727    end;
    579728  if txtXDuration.Text = '' then
    580729    begin
    581       if AnErrMsg = '' then self.FInitialOrderID := True;
    582       exit;
     730      if AnErrMsg = '' then exit;
     731      //if AnErrMsg = '' then self.FInitialOrderID := True;
     732      //exit;
    583733    end;
    584734  Len := Length(txtXDuration.Text);
     
    607757         SetError('Duration with a unit of "doses" must be greater then 0 and less then 2000000');
    608758     end;
    609   if AnErrMsg = '' then self.FInitialOrderID := True;
     759  //if AnErrMsg = '' then self.FInitialOrderID := True;
    610760 
    611761end;
     
    629779procedure TfrmODMedIV.SetValuesFromResponses;
    630780var
    631   x, addRoute, tempSch, AdminTime, TempOrder, tmpSch, tempIRoute, tempRoute: string;
    632   AnInstance, i, idx: Integer;
    633   AResponse: TResponse;
     781  x, addRoute, tempSch, AdminTime, TempOrder, tmpSch, tempIRoute, tempRoute, PreAddFreq: string;
     782  AnInstance, i, idx, j: Integer;
     783  AResponse, AddFreqResp: TResponse;
    634784  AnIVComponent: TIVComponent;
    635785  AllIVRoute: TStringList;
     
    637787begin
    638788  Changing := True;
    639   self.FInitialOrderID := false;
     789  //self.FInitialOrderID := false;
    640790  with Responses do
    641791  begin
     792    SetControl(cboType, 'TYPE', 1);
     793    if cboType.ItemIndex > -1 then  FIVTypeDefined := True;
    642794    FInpatient := OrderForInpatient;
    643795    AnInstance := NextInstance('ORDERABLE', 0);
     
    682834            Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount);
    683835          Cells[2, RowCount - 1] := AnIVComponent.Units;
     836          Cells[3, RowCount - 1] := 'N/A';
    684837        end;
    685838      end;
     
    721874        AnIVComponent.Units   := Piece(x, U, 1);
    722875        AnIVComponent.Volumes := Copy(x, Pos(U, x) + 1, Length(x));
     876        //AGP ADDITIVE FREQUENCY CHANGES
     877        AnIVComponent.AddFreq := '';
     878        PreAddFreq := '';
     879        AddFreqResp := FindResponseByName('ADDFREQ', AnInstance);
     880        if AddFreqResp <> nil then
     881          begin
     882            if cboAddFreq.Items.IndexOf(AddFreqResp.IValue) = -1 then
     883                 begin
     884                   AnIvComponent.AddFreq := '';
     885                 end
     886            else AnIvComponent.AddFreq := AddFreqResp.IValue;
     887            PreAddFreq := AddFreqResp.IValue;
     888          end;
    723889        with grdSelected do
    724890        begin
     
    729895            Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount);
    730896          Cells[2, RowCount - 1] := AnIVComponent.Units;
     897          Cells[3, RowCount -1] := AnIVComponent.AddFreq;
     898          if OrdAction in [ORDER_COPY, ORDER_EDIT] then Cells[4, RowCount -1] := PreAddFreq;
    731899        end;
    732900      end;
     
    803971         //if (cboSchedule.ItemIndex > -1) then lblAdminTime.Caption := 'Admin. Time: ' + Piece(cboSchedule.Items.strings[cboSchedule.itemindex],U,5);
    804972         //if (cboSchedule.ItemIndex > -1) and (Piece(lblAdminTime.Caption, ':' ,2) = ' ') then lblAdminTime.Caption := 'Admin. Time: ' + AdminTime;
    805          if (Action in [ORDER_COPY, ORDER_EDIT])  then
     973         if (OrdAction in [ORDER_COPY, ORDER_EDIT])  then
    806974           begin
    807975            TempOrder := Piece(OrderIEN,';',1);
     
    812980                if AResponse <> nil then AdminTime := AResponse.EValue;
    813981                //lblAdminTime.Caption := 'Admin. Time: ' + AdminTime;
    814                 if cboSchedule.ItemIndex > -1 then
     982                if (cboSchedule.ItemIndex > -1) and (AdminTime <> '') then
    815983                  begin
    816984                    tmpSch := cboSchedule.Items.Strings[cboSchedule.itemindex];
     
    8481016             cboInfusionTime.itemindex := 0;
    8491017           end;
     1018          For j := 0 to grdSelected.RowCount -1 do
     1019            grdSelected.Cells[3,j] := 'N/A';
    8501020      end
    8511021    else
     
    8901060begin
    8911061  inherited;
    892   Action := OrderAction;
     1062  OrdAction := OrderAction;
    8931063  OrderIEN := id;
    894   self.FInitialOrderID := True;
     1064  //self.FInitialOrderID := True;
    8951065  if self.EvtID > 0 then FAdminTimeText := 'To Be Determined';
     1066  if isIMO = true then self.Caption := 'Clinic ' + self.Caption;
    8961067  if (isIMO) or ((patient.Inpatient = true) and (encounter.Location <> patient.Location)) and (FAdminTimeText = '') then
    8971068      FAdminTimeText := 'Not defined for Clinic Locations';
    8981069  if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then
    8991070    begin
    900 
    9011071      SetValuesFromResponses;
    9021072    end;
     
    9281098procedure TfrmODMedIV.cboSolutionNeedData(Sender: TObject; const StartFrom: string;
    9291099  Direction, InsertAt: Integer);
    930 var
    931   CurString: string;
    932 begin
    933   inherited;
    934   if (Direction = 1) then
    935     CurString := AnsiUpperCase(StartFrom) + '          ';
    936   cboSolution.ForDataUse(SubSetOfOrderItems(CurString, Direction, 'S.IVB RX'));
     1100begin
     1101  cboSolution.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.IVB RX'));
    9371102end;
    9381103
    9391104procedure TfrmODMedIV.cbotypeChange(Sender: TObject);
     1105var
     1106i: integer;
    9401107begin
    9411108  inherited;
     
    9551122      lblInfusionRate.Caption := 'Infuse Over Time (Optional)';
    9561123      cboInfusionTime.Enabled := true;
    957       cboDuration.Items.Add('doses');
     1124      if cboDuration.items.IndexOf('doses') = -1 then cboDuration.Items.Add('doses');
     1125      //AGP ADDITIVE FREQUECNY CHANGES
     1126      lblAddFreq.Caption := 'Additive Frequency';
     1127      for i := 0 to grdselected.RowCount - 1 do
     1128        begin
     1129          if (TIVComponent(grdselected.Objects[0, i]) <> nil) and (TIVComponent(grdselected.Objects[0, i]).Fluid = 'A') then
     1130            begin
     1131              grdSelected.Cells[3, i] := 'N/A';
     1132            end;
     1133        end;
    9581134    end
    9591135  //else if (self.cbotype.Text = 'Continuous') or (self.cboType.itemIndex = 0) then
     
    9751151      updateDuration('');
    9761152      cboduration.Items.Delete(cboDuration.Items.IndexOf('doses'));
    977     end;
     1153      lblAddFreq.Caption := 'Additive Frequency*';
     1154      if FIVTypeDefined = True then
     1155        begin
     1156          for i := 0 to grdselected.RowCount - 1 do
     1157            begin
     1158              if (TIVComponent(grdselected.Objects[0, i]) <> nil) and (TIVComponent(grdselected.Objects[0, i]).Fluid = 'A') then
     1159                begin
     1160                  grdSelected.Cells[3, i] := '';
     1161                end;
     1162            end;
     1163        end;
     1164    end;
     1165  FIVTypeDefined := True;
    9781166  self.txtRate.Text := '';
    9791167  ControlChange(Sender);
     1168end;
     1169
     1170procedure TfrmODMedIV.cboTypeKeyDown(Sender: TObject; var Key: Word;
     1171  Shift: TShiftState);
     1172begin
     1173  inherited;
     1174  if IsAltCtrl_L_Pressed(Shift, Key) then
     1175    lblTypeHelpClick(lblTypeHelp);
     1176end;
     1177
     1178function TfrmODMedIV.IsAltCtrl_L_Pressed(Shift : TShiftState; Key : Word) : Boolean;
     1179begin
     1180  Result := (ssCtrl in Shift) and (ssAlt in Shift) and (Key = Ord('L'));
    9801181end;
    9811182
     
    9861187  T2 = #13#13'The first order''s administrative schedule is "';
    9871188  T3 = #13'The second order''s administrative schedule is "';
    988   T4 = #13#13'Do you want to continue?';
     1189  T4 = #13#13'Do you want to continue?';   
     1190  T5 = '" and a priority of "';
    9891191  T1A = 'By checking the "Give additional dose now" box, you have actually entered a new order with the schedule "NOW"';
    9901192  T2A = ' in addition to the one you are placing for the same medication.';
     
    9921194  medNm: string;
    9931195  theSch: string;
     1196  ordPriority: string;
    9941197  //SchID: integer;
    9951198begin
     
    10001203    //SchID := cboSchedule.ItemIndex;
    10011204    theSch := cboSchedule.Text;
     1205    ordPriority := cboPriority.SelText;
    10021206    if length(theSch)>0 then
    10031207    begin
    10041208      //if (InfoBox(T1+medNm+T+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL)then
    1005       if (InfoBox(T1+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL)then
     1209      //if (InfoBox(T1+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL)then
     1210      if (InfoBox(T1+T2+'NOW'+T5+ordPriority+T+T3+theSch+T5+ordPriority+T+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL)then
    10061211      begin
    10071212        chkDoseNow.Checked := False;
     
    10891294    Cells[1, RowCount - 1] := IntToStr(AnIVComponent.Amount);
    10901295    Cells[2, RowCount - 1] := AnIVComponent.Units;
     1296    Cells[3, RowCount - 1] := 'N/A';
    10911297    Row := RowCount - 1;
    10921298    if Length(Piece(AnIVComponent.Volumes, U, 2)) > 0 then Col := 1 else Col := 0;
    1093     if RowCount = 1 then        // switch to additives after 1st IV
     1299  (*  if RowCount = 1 then        // switch to additives after 1st IV
    10941300    begin
    10951301       tabFluid.TabIndex := 1;
    10961302       tabFluidChange(Self);
    1097     end;
     1303    end;  *)
    10981304  end;
    10991305  Application.ProcessMessages;         //CQ: 10157
     1306  updateRoute;
    11001307  ClickOnGridCell;
    1101   updateRoute;
     1308  //updateRoute;
    11021309  ControlChange(Sender);
    11031310  //updateRoute(routeIEN);
     
    11171324procedure TfrmODMedIV.cboAdditiveNeedData(Sender: TObject; const StartFrom: string;
    11181325  Direction, InsertAt: Integer);
    1119 var
    1120   CurString: string;
    1121 begin
    1122   inherited;
    1123   if (Direction = 1) then
    1124     CurString := AnsiUpperCase(StartFrom) + '          ';
    1125   cboAdditive.ForDataUse(SubSetOfOrderItems(CurString, Direction, 'S.IVA RX'));
     1326begin
     1327  cboAdditive.ForDataUse(SubSetOfOrderItems(StartFrom, Direction, 'S.IVA RX'));
     1328end;
     1329
     1330procedure TfrmODMedIV.cboAddFreqCloseUp(Sender: TObject);
     1331begin
     1332  inherited;
     1333  with cboAddFreq do
     1334  begin
     1335    if tag < 0 then exit;
     1336    grdSelected.Cells[Tag div 256, Tag mod 256] := MixedCase(items.Strings[itemindex]);
     1337    Tag := -1;
     1338    Hide;
     1339    ControlChange(Sender);
     1340    TControl(self.grdSelected).Enabled := True;
     1341    ActiveControl := self.grdSelected;
     1342  end;
     1343  grdSelected.Refresh;
     1344end;
     1345
     1346procedure TfrmODMedIV.cboAddFreqKeyDown(Sender: TObject; var Key: Word;
     1347  Shift: TShiftState);
     1348begin
     1349  inherited;
     1350  if (Key = VK_RETURN) or (Key = VK_Tab) then
     1351  begin
     1352    cboAddFreqCloseUp(cboAddFreq);
     1353    Key := 0;
     1354  end;
    11261355end;
    11271356
     
    11771406      cboPriority.SetFocus;
    11781407    end;
     1408end;
     1409
     1410procedure TfrmODMedIV.cboPriorityKeyUp(Sender: TObject; var Key: Word;
     1411  Shift: TShiftState);
     1412begin
     1413  inherited;
     1414  if (Key = VK_BACK) and (cboPriority.Text = '') then cboPriority.ItemIndex := -1;
    11791415end;
    11801416
     
    12321468end;
    12331469
     1470procedure TfrmODMedIV.cboRouteKeyDown(Sender: TObject; var Key: Word;
     1471  Shift: TShiftState);
     1472begin
     1473  inherited;
     1474  if IsAltCtrl_L_Pressed(Shift, Key) then
     1475    txtAllIVRoutesClick(txtAllIVRoutes);
     1476end;
     1477
     1478procedure TfrmODMedIV.cboRouteKeyUp(Sender: TObject; var Key: Word;
     1479  Shift: TShiftState);
     1480begin
     1481  inherited;
     1482  if (Key = VK_BACK) and (cboRoute.Text = '') then cboRoute.ItemIndex := -1; 
     1483end;
     1484
    12341485procedure TfrmODMedIV.cboAdditiveMouseClick(Sender: TObject);
    12351486var
     
    12731524    Cells[0, RowCount - 1] := AnIVComponent.Name;
    12741525    Cells[2, RowCount - 1] := AnIVComponent.Units;
     1526    Cells[3, RowCount -1] :=  UpdateAddFreq(AnIVComponent.IEN);
    12751527    Row := RowCount - 1;
    12761528    Col := 1;
     
    13021554  self.cboDuration.Text := '';
    13031555  self.txtAllIVRoutes.Visible := false;
    1304   self.FInitialOrderID := True;
     1556  //self.FInitialOrderID := True;
    13051557  cbotypeChange(self.cboType);
    13061558  if self.cboroute.Items.Count > 0 then self.cboRoute.Clear;
     1559  FIVTypeDefined := false;
    13071560end;
    13081561
     
    13241577      SetFocus;
    13251578      if AControl is TComboBox then                    //CQ: 10157
    1326         TComboBox(AControl).DroppedDown := True;
     1579        begin
     1580          TComboBox(AControl).DroppedDown := True;
     1581          TControl(self.grdSelected).Enabled := false;
     1582        end;
    13271583    end;
    13281584  end;
     
    13301586begin
    13311587  AnIVComponent := TIVComponent(grdSelected.Objects[0, grdSelected.Row]);
    1332   if (AnIVComponent = nil) or (grdSelected.Col = 0) then Exit;
     1588  if (AnIVComponent = nil) or (grdSelected.Col = 0) then
     1589    begin
     1590      if (AnIVComponent <> nil) and (grdSelected.Col = 0) then grdSelected.Refresh;
     1591      Exit;
     1592    end;
    13331593  // allow selection if more the 1 unit to choose from
    13341594  if (grdSelected.Col = 2) and (Length(Piece(AnIVComponent.Units, U, 2)) > 0) then
     
    13541614    PlaceControl(txtSelected);
    13551615  end;
     1616  // AGP ADDITIVE FREQUENCY CHANGES
     1617  if (Self.cboType.ItemIndex < 1) and (grdSelected.Col = 3) and (AnIVComponent.Fluid = 'A') then
     1618  begin
     1619    cboAddFreq.ItemIndex := cboAddFreq.Items.IndexOf(grdSelected.Cells[grdSelected.Col, grdSelected.Row]);
     1620    cboAddFreq.Tag  := (grdSelected.Col * 256) + grdSelected.Row;
     1621    PlaceControl(cboAddFreq);
     1622  end;
    13561623end;
    13571624
     
    13761643    Hide;
    13771644  end;
     1645  grdSelected.Refresh;
     1646end;
     1647
     1648
     1649
     1650procedure TfrmODMedIV.txtSelectedKeyDown(Sender: TObject; var Key: Word;
     1651  Shift: TShiftState);
     1652begin
     1653  inherited;
     1654  if (Key = VK_RETURN) or (Key = VK_Tab) then
     1655    begin
     1656      ActiveControl := grdSelected;
     1657      Key := 0;
     1658    end;
    13781659end;
    13791660
    13801661procedure TfrmODMedIV.cboScheduleChange(Sender: TObject);
     1662var
     1663othSch: string;
     1664idx: integer;
    13811665begin
    13821666  inherited;
     
    13861670       self.cboDuration.ItemIndex := -1;
    13871671     end;
    1388    if self.cboSchedule.ItemIndex > -1 then updateDuration(Piece(cboSchedule.Items.Strings[cboSchedule.itemindex],U,3));
     1672   if self.cboSchedule.ItemIndex > -1 then
     1673      begin
     1674        if cboSchedule.ItemIndex = cboSchedule.Items.IndexOf('Other') then
     1675          begin
     1676            othSch := CreateOtherSchedule;
     1677            if length(trim(othSch)) > 1 then
     1678              begin
     1679                cboSchedule.Items.Add(othSch + U + U + NSSScheduleType + U + NSSAdminTime);
     1680                idx := cboSchedule.Items.IndexOf(Piece(OthSch, U, 1));
     1681                cboSchedule.ItemIndex := idx;
     1682            end
     1683            else cboSchedule.itemindex := -1;
     1684        end;
     1685        if cboSchedule.itemIndex > -1  then  updateDuration(Piece(cboSchedule.Items.Strings[cboSchedule.itemindex],U,3));
     1686      end;
    13891687  ControlChange(sender);
    13901688end;
     
    13931691var
    13941692  othSch: string;
    1395   idx, i : integer;
     1693  idx: integer;
    13961694begin
    13971695  inherited;
     
    14021700        begin
    14031701          cboSchedule.Items.Add(othSch + U + U + NSSScheduleType + U + NSSAdminTime);
    1404           idx := -1;
    1405           for I := 0 to cboSchedule.Items.Count - 1 do
    1406             if Piece(cboSchedule.Items.Strings[i], U, 1) = othSch then
    1407               begin
    1408                 idx := i;
    1409                 break;
    1410               end;
    1411           //idx := cboSchedule.Items.IndexOfName(othSch);
     1702          idx := cboSchedule.Items.IndexOf(Piece(OthSch, U, 1));
    14121703          cboSchedule.ItemIndex := idx;
    14131704        end;
     
    14311722      cboSchedule.SetFocus;
    14321723    end;
    1433 end;
    1434 
    1435 procedure TfrmODMedIV.cboSelectedChange(Sender: TObject);   // combo editor for grid
     1724    if (cboSchedule.ItemIndex > -1) and (cboSchedule.Text = '') then cboSchedule.ItemIndex := -1;
     1725end;
     1726
     1727procedure TfrmODMedIV.cboScheduleKeyDown(Sender: TObject; var Key: Word;
     1728  Shift: TShiftState);
     1729begin
     1730  inherited;
     1731  if IsAltCtrl_L_Pressed(Shift, Key) then
     1732    txtNSSClick(txtNSS);
     1733end;
     1734
     1735procedure TfrmODMedIV.cboScheduleKeyUp(Sender: TObject; var Key: Word;
     1736  Shift: TShiftState);
     1737begin
     1738  inherited;
     1739  if (Key = VK_BACK) and (cboSchedule.Text = '') then cboSchedule.ItemIndex := -1; 
     1740end;
     1741
     1742procedure TfrmODMedIV.cboSelectedCloseUp(Sender: TObject);
    14361743begin
    14371744  inherited;
    14381745  with cboSelected do
    14391746  begin
    1440     if Tag < 0 then Exit;
    1441     grdSelected.Cells[Tag div 256, Tag mod 256] := Text;
    1442   end;
    1443   ControlChange(Sender);
    1444 end;
    1445 
    1446 procedure TfrmODMedIV.cboSelectedExit(Sender: TObject);
    1447 begin
    1448   inherited;
    1449   with cboSelected do
    1450   begin
    1451     grdSelected.Cells[Tag div 256, Tag mod 256] := Text;
     1747    if tag < 0 then exit;
     1748    grdSelected.Cells[Tag div 256, Tag mod 256] := MixedCase(items.Strings[itemindex]);
    14521749    Tag := -1;
    14531750    Hide;
     1751    ControlChange(Sender);
     1752    TControl(self.grdSelected).Enabled := True;
     1753    ActiveControl := self.grdSelected;
     1754  end;
     1755  grdSelected.Refresh;
     1756end;
     1757
     1758procedure TfrmODMedIV.cboSelectedKeyDown(Sender: TObject; var Key: Word;
     1759  Shift: TShiftState);
     1760begin
     1761  inherited;
     1762  if (Key = VK_RETURN) or (Key = VK_Tab) then
     1763  begin
     1764    cboSelectedCloseUp(cboSelected);
     1765    Key := 0;
    14541766  end;
    14551767end;
     
    15281840        if Length(Cells[1,i]) > 0 then Responses.Update('STRENGTH', CurAdd, Cells[1,i], Cells[1,i]);
    15291841        if Length(Cells[2,i]) > 0 then Responses.Update('UNITS',    CurAdd, Cells[2,i], Cells[2,i]);
     1842        //AGP ADDITIVE FREQUECNY CHANGES
     1843        if (Length(Cells[3,i]) > 0) and (Cells[3,i] <> 'N/A') then Responses.Update('ADDFREQ',    CurAdd, Cells[3,i], Cells[3,i]);
    15301844        Inc(CurAdd);
    15311845      end; {if Fluid A}
     
    15581872    end;
    15591873  end;
    1560   if cboType.Text = 'Intermittent' then iType := 'I'
    1561   else iType := 'C';
     1874  if (cboType.ItemIndex > -1) and (cboType.Items.Strings[cboType.ItemIndex] = 'Intermittent') then iType := 'I'
     1875  else if (cboType.ItemIndex > -1) and (cboType.Items.Strings[cboType.ItemIndex] = 'Continuous') then iType := 'C'
     1876  else iType := '';
    15621877  Responses.Update('TYPE',1,iType,cboType.Text);
    15631878  Responses.Update('ROUTE',1,cboRoute.ItemID,cboRoute.Text);
     
    16351950begin
    16361951  aSchedule := '';
    1637   if not ShowOtherSchedule(aSchedule) then
    1638   begin
    1639     cboSchedule.ItemIndex := -1;
    1640     cboSchedule.Text      := '';
    1641   end
    1642   else
     1952  cboSchedule.ItemIndex := -1;
     1953  cboSchedule.Text      := '';
     1954  cboSchedule.DroppedDown := false;
     1955  if ShowOtherSchedule(aSchedule) then
    16431956    begin
    16441957        Result := Piece(aSchedule,U,1);
     
    16521965begin
    16531966  inherited;
    1654   if Sender = ActiveControl then Exit;
    1655   if not (gdSelected in State) then Exit;
     1967  //if Sender = ActiveControl then Exit;
     1968  //if not (gdSelected in State) then Exit;
    16561969  with Sender as TStringGrid do
    16571970  begin
    1658     Canvas.Brush.Color := Color;
    1659     Canvas.Font := Font;
     1971    if State = [gdSelected..gdFocused] then
     1972      begin
     1973        Canvas.Font.Color := Get508CompliantColor(clWhite);
     1974        Canvas.Brush.Color := clHighlight;
     1975        //Canvas.Font.Color := clHighlightText;
     1976        Canvas.Font.Style := [fsBold];
     1977        Canvas.MoveTo(Rect.Left,Rect.top);
     1978      end
     1979    else
     1980      begin
     1981        if (ACol = 4) and (ColWidths[4] > 0) then
     1982          Canvas.Brush.Color := clInactiveBorder
     1983        else  Canvas.Brush.Color := clWindow;
     1984        Canvas.Font := Font;
     1985      end;
     1986    Canvas.FillRect(Rect);
     1987    //Canvas.Brush.Color := Color;
     1988
    16601989    Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
    16611990  end;
     
    16962025    tabFluidChange(tabFluid);
    16972026  end;
     2027end;
     2028
     2029procedure TfrmODMedIV.FormKeyPress(Sender: TObject; var Key: Char);
     2030begin
     2031  if (Key = #13) and (ActiveControl = grdSelected) then
     2032  Key := #0;   //Don't let the base class turn it into a forward tab!
     2033  inherited;
    16982034end;
    16992035
     
    17812117        cboSchedule.ItemIndex := idx;
    17822118        exit;
     2119      end;
     2120    //if PRN schedule than set the checkbox than exit
     2121    if (X = ' PRN') or (X = 'PRN') then
     2122      begin
     2123        chkPRN.Checked := True;
     2124        Exit;
    17832125      end;
    17842126      //Check to see if schedule is a Day-of-Week Schedule (MO-WE-FR@BID)
     
    18052147                  //tempSch := U + Piece(x, '@', 1) + '@' + Pieces(cboSchedule.Items.Strings[idx], U, 2, 5);
    18062148                  tempSch := Piece(x, '@', 1) + '@' + cboSchedule.Items.Strings[idx];
    1807                   cboSchedule.Items.Add(tempSch);
    18082149                  cboSchedule.Text := (Piece(tempSch,U,1));
    18092150                  cboSchedule.ItemIndex := cboSchedule.Items.IndexOf(Piece(tempSch, U, 1));
     
    18862227end;
    18872228
     2229function TfrmODMedIV.UpdateAddFreq(OI: integer): string;
     2230begin
     2231  if (self.cboType.ItemIndex = -1) or (MixedCase(self.cboType.Items.Strings[self.cboType.ItemIndex]) = 'Continuous') then
     2232     Result := GetDefaultAddFreq(OI)
     2233  else Result := '';
     2234end;
     2235
    18882236procedure TfrmODMedIV.UpdateDuration(SchType: string);
    18892237begin
     
    19092257i: integer;
    19102258OrderIds, TempIVRoute: TStringList;
    1911 Default: boolean;
     2259//Default: boolean;
    19122260begin
    19132261  if self.grdSelected.RowCount > 0 then self.txtAllIVRoutes.Visible := True;
     
    19282276 if OrderIds.Count > 0 then
    19292277   begin
    1930      if (self.FInitialOrderID = True) and (self.grdSelected.RowCount = 1) then Default := True
    1931      else Default := False;
    1932      LoadDosageFormIVRoutes(self.cboRoute.Items, OrderIds, Default);
    1933      if default = True then
     2278     //if (self.FInitialOrderID = True) and (self.grdSelected.RowCount = 1) then Default := True
     2279     //else Default := False;
     2280     LoadDosageFormIVRoutes(self.cboRoute.Items, OrderIds);
     2281     //if default = True then
     2282     //  begin
     2283     for I := 0 to cboRoute.items.Count - 1 do
    19342284       begin
    1935          for I := 0 to cboRoute.items.Count - 1 do
    1936            if Piece(cboRoute.Items.Strings[i], U, 5) = 'D' then
    1937              begin
    1938                cboRoute.ItemIndex := i;
    1939                break;
    1940              end;
    1941          self.FInitialOrderID := false;
     2285        if Piece(cboRoute.Items.Strings[i], U, 5) = 'D' then
     2286          begin
     2287           cboRoute.ItemIndex := i;
     2288           break;
     2289          end;
    19422290       end;
     2291       //  self.FInitialOrderID := false;
     2292       //end;
    19432293     OrderIds.Free;
    19442294   end;
     
    19542304procedure TfrmODMedIV.txtAllIVRoutesClick(Sender: TObject);
    19552305var
    1956 i: integer;
    1957 begin
    1958   inherited;
    1959   if MessageDlg('You can also select "OTHER" from the Route list'
     2306  i: integer;
     2307  msg : String;
     2308begin
     2309  inherited;
     2310  msg := 'You can also select "OTHER" from the Route list'
    19602311     + ' to select a Route from the Expanded Med Route List.'
    1961      + #13#10 + 'Click OK to launch the Expanded Med Route List.',
    1962      mtInformation, [mbOK, mbCancel],0) = mrOK then
     2312     + #13#10 + 'Click OK to launch the Expanded Med Route List.';
     2313  if ShowMsg(msg, smiInfo, smbOKCancel) = smrOk then
    19632314  begin
    19642315      for I := 0 to cboRoute.Items.Count - 1 do if cboRoute.Items.Strings[i] = U + 'OTHER' then break;
     
    19712322procedure TfrmODMedIV.txtNSSClick(Sender: TObject);
    19722323var
    1973 i: integer;
    1974 begin
    1975   inherited;
    1976   if MessageDlg('You can also select ' + '"' + 'Other' + '"' + ' from the schedule list'
     2324  i: integer;
     2325  msg : String;
     2326begin
     2327  inherited;
     2328  msg := 'You can also select ' + '"' + 'Other' + '"' + ' from the schedule list'
    19772329    + ' to create a day-of-week schedule.'
    1978     + #13#10 + 'Click OK to launch schedule builder',
    1979     mtInformation, [mbOK, mbCancel],0) = mrOK then
     2330    + #13#10 + 'Click OK to launch schedule builder';
     2331  if ShowMsg(msg, smiInfo, smbOKCancel) = smrOK then
    19802332  begin
    19812333      //cboSchedule.Items.Add(U + 'OTHER');
Note: See TracChangeset for help on using the changeset viewer.