Ignore:
Timestamp:
Jul 6, 2008, 8:20:14 PM (16 years ago)
Author:
Kevin Toppenberg
Message:

Uploading from OR_30_258

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/foia-cprs/CPRS-Chart/Orders/fODMeds.pas

    r459 r460  
    8686    memDrugMsg: TMemo;
    8787    txtNSS: TLabel;
     88    SpeedButton1: TSpeedButton;
    8889    procedure FormCreate(Sender: TObject);
    8990    procedure btnSelectClick(Sender: TObject);
     
    186187    procedure cboScheduleExit(Sender: TObject);
    187188    procedure cboXScheduleExit(Sender: TObject);
     189    procedure cboDosageKeyUp(Sender: TObject; var Key: Word;
     190      Shift: TShiftState);
     191    procedure cboXDosageKeyUp(Sender: TObject; var Key: Word;
     192      Shift: TShiftState);
     193    procedure txtSupplyClick(Sender: TObject);
     194    procedure txtQuantityClick(Sender: TObject);
     195    procedure txtRefillsClick(Sender: TObject);
     196    procedure WMClose(var Msg : TWMClose); message WM_CLOSE;
     197    procedure cboXScheduleEnter(Sender: TObject);
    188198    //procedure btnNSSClick(Sender: TObject);
    189199  private
     
    236246    FOrigiMsgDisp: boolean;
    237247    FNSSOther: boolean;
    238     FFromClick: boolean;
     248    {selection}
    239249    FShowPnlXScheduleOk : boolean;
    240250    FRemoveText : Boolean;
    241     {selection}
     251    FSmplPRNChkd: Boolean;
    242252    procedure ChangeDelayed;
    243253    function FindQuickOrder(const x: string): Integer;
     
    302312//    function ValidateRoute(RouteCombo: TORComboBox) : Boolean; Removed based on Site feeback. See CQ: 7518
    303313    function IsSupplyAndOutPatient : boolean;
     314    function GetSchedListIndex(SchedCombo: TORComboBox; pSchedule: String):integer;
    304315  protected
    305316    procedure InitDialog; override;
    306317    procedure Validate(var AnErrMsg: string); override;
    307318  public
     319    ARow1: integer;
    308320    procedure SetupDialog(OrderAction: Integer; const ID: string); override;
    309321    procedure CheckDecimal(var AStr: string);
     
    319331
    320332uses rCore, uCore, ORFn, rODMeds, rODBase, rOrders, fRptBox, fODMedOIFA,
    321   uAccessibleStringGrid, uOrders, fOtherSchedule, StrUtils;
     333  uAccessibleStringGrid, uOrders, fOtherSchedule, StrUtils, fFrame;
    322334
    323335const
     
    329341  COL_DURATION =  4;
    330342  COL_SEQUENCE =  5;
     343  COL_CHKXPRN  =  6;
    331344  VAL_DOSAGE   = 10;
    332345  VAL_ROUTE    = 20;
     
    334347  VAL_DURATION = 40;
    335348  VAL_SEQUENCE = 50;
     349  VAL_CHKXPRN  = 60;
    336350  TAB          = #9;
    337351  {field identifiers}
     
    387401  TC_NO_DEA     = 'DEA# Required';
    388402  TX_NO_MED     = 'Medication must be selected.';
     403  TX_NO_SEQ     = 'Missing one or more conjunction.';
    389404  TX_NO_DOSE    = 'Dosage must be entered.';
    390405  TX_DOSE_NUM   = 'Dosage may not be numeric only';
     
    422437  x: string;
    423438begin
     439  frmFrame.pnlVisit.Enabled := false;
    424440  AutoSizeDisabled := True;
    425441  inherited;
    426442  btnXDuration.Align := alClient;
    427443  AllowQuickOrder := True;
     444  FSmplPRNChkd := False; // GE CQ7585
    428445  CheckAuthForMeds(x);
    429446  if Length(x) > 0 then
     
    456473  {if not FInptDlg then } Responses.SetPromptFormat('INSTR', '@');
    457474  StatusText('Loading Schedules');
    458   LoadSchedules(cboSchedule.Items, FInptDlg);
     475  //if (Self.EvtID > 0) then LoadSchedules(cboSchedule.Items)
     476  //else LoadSchedules(cboSchedule.Items, FInptDlg);
     477  LoadSchedules(cboSchedule.Items, FInptDlg); 
    459478  StatusText('');
    460479  if FInptDlg then SetControlsInpatient else SetControlsOutpatient;
     
    466485  begin
    467486    txtNss.Visible := True;
     487    //cboSchedule.ListItemsOnly := True;
     488    //cboXSchedule.ListItemsOnly := True;
    468489  end;
    469490  with grdDoses do
     
    537558  FAllDrugs.Free;
    538559  TAccessibleStringGrid.UnwrapControl(grdDoses);
     560  frmFrame.pnlVisit.Enabled := true;
    539561  inherited;
    540562end;
     
    558580  FQOInitial  := False;
    559581  FNSSOther   := False;
    560   FFromClick  := False;
    561582end;
    562583
    563584procedure TfrmODMeds.SetupDialog(OrderAction: Integer; const ID: string);
    564585var
    565   AnInstr, OrderID, nsSch: string;
     586  AnInstr, OrderID, nsSch, Text: string;
    566587  ix: integer;
    567588begin
     
    606627             begin
    607628                SetSchedule(nsSch);
     629                {cboSchedule.SelectByID(nsSch);
     630                if cboSchedule.ItemIndex < 0 then
     631                begin
     632                  cboSchedule.Items.Add(nsSch);
     633                  cboSchedule.ItemIndex := cboSchedule.Items.IndexOf(nsSch);
     634                end;}
    608635             end;
    609636           end;
     
    611638       end;
    612639    end;  //nss
    613     UpdateRelated(FALSE);
     640    if ((OrderAction <> Order_COPY) and (OrderAction <> Order_EDIT)) or
     641    (XfInToOutNow = true) then UpdateRelated(FALSE); //AGP Change
    614642    Changing := False;
    615643  end;
     
    624652      then AnInstr := 'Copy: ' + AnInstr
    625653      else AnInstr := 'Change: ' + AnInstr;
    626     Caption := AnInstr;
     654    Text := AnsiReplaceText(AnInstr,CRLF,'');
     655    Caption := Text;
    627656    memComment.Clear;  // sometimes the sig is in the comment
    628657  end;
     
    654683    // and is not an outpaitent order, then display error text to require route
    655684    if (Length(x) = 0) and (Not IsSupplyAndOutPatient) then
     685    begin
     686      if cboRoute.Showing = true then cboRoute.SetFocus;  //CQ: 7467
    656687      SetError(TX_NO_ROUTE);
     688    end;
    657689    if (Length(x) > 0) and NeedLookup then
    658690    begin
    659691      LookupRoute(x, RouteID, RouteAbbr);
    660692      if RouteID = '0'
    661         then SetError(TX_NF_ROUTE)
     693        then
     694        begin
     695         if cboRoute.Showing = true then cboRoute.SetFocus;    //CQ: 7467
     696        SetError(TX_NF_ROUTE);
     697        end
    662698        else Responses.Update('ROUTE', AnInstance, RouteID, RouteAbbr);
    663699    end;
     
    678714    else if (Length(tmpX) = 0) and FInptDlg and ScheduleRequired(txtMed.Tag, ARoute, ADrug)
    679715      then SetError(TX_NO_SCHED);
    680 
    681716    if Length(tmpX) > 0 then
    682717    begin
     
    706741    if (ValueOfResponse(FLD_DRUG_ID, i) = '') then
    707742    begin
    708       if not ContainsAlpha(Responses.IValueFor('INSTR', i)) then SetError(TX_DOSE_NUM);
    709       if Length(Responses.IValueFor('INSTR', i)) > 60       then SetError(TX_DOSE_LEN);
     743      if not ContainsAlpha(Responses.IValueFor('INSTR', i)) then
     744      begin
     745         SetError(TX_DOSE_NUM);
     746         if tabDose.TabIndex = TI_DOSE then
     747            cboDosage.SetFocus;    //CQ: 7467
     748      end;
     749      if Length(Responses.IValueFor('INSTR', i)) > 60       then
     750      begin
     751         SetError(TX_DOSE_LEN);
     752         cboDosage.SetFocus;  //CQ: 7467
     753      end;
    710754    end;
    711755    ValidateRoute(Responses.EValueFor('ROUTE', i), Responses.IValueFor('ROUTE', i) = '', i);
     
    713757    i := Responses.NextInstance('INSTR', i);
    714758  end;
     759  //AGP Change 26.45 Fix for then/and conjucntion PSI-04-069
     760  if self.tabDose.TabIndex = 1 then
     761    begin
     762       for i := 2 to self.grdDoses.RowCount do
     763         begin
     764           if ((ValFor(COL_DOSAGE, i-1) <> '') and (ValFor(COL_DOSAGE, i) <> '')) and (ValFor(COL_SEQUENCE,i-1) = '') then
     765             begin
     766              SetError(TX_NO_SEQ);
     767              Exit;
     768             end;
     769         end;
     770    end;
    715771  if not FInptDlg then                            // outpatient stuff
    716772  begin
     
    9531009    UniqueText := False;
    9541010  FFromSelf := True;
     1011  {AutoSelection is only based upon uniquely matching characters.
     1012   Several CQs have been resolved relating to this issue:
     1013   See CQ:
     1014   7326 - Auto complete does not work correctly if user has quick orders in Medication list
     1015   7328 - PSI-05-016: TAM-0205-31170  Med Error due to pre-populated med screen
     1016   6715 PSI-04-044 Orders: NJH-0804-20315  Physician unable to enter medication order
     1017  }
    9551018  if UniqueText then
    9561019  begin
     
    11291192  QOQuantityStr := '';
    11301193  btnSelect.SetFocus;                             // let the exit events finish
     1194
    11311195  if pnlMeds.Visible then                         // display the medication fields
    11321196  begin
     
    12941358  lblQtyMsg.Caption := '';
    12951359  lblQuantity.Caption := 'Quantity';
     1360  FSmplPRNChkd := chkPRN.Checked;  //  GE  CQ7585
    12961361  chkPRN.Checked := False;
    12971362  FLastUnits    := '';
     
    13181383  QOPiUnChk := False;
    13191384  PKIEnviron := False;
    1320   if GetPKISite and GetPKIUse then  //PKI check for crypto object on workstation
    1321     begin
    1322       try  //PKI object creation
    1323         crypto := CoXuDigSigS.Create;
    1324         crypto.GetCSP;
    1325         StatusText(crypto.Reason);
    1326         PKIEnviron := True;
    1327       except
    1328         on  E: Exception do
    1329           begin
    1330             {ShowMessage('An error has been encountered while trying to create PKI environment: '+ E.Message +
    1331             '.  This order will be processed without Digital Signature encryption.');}
    1332             PKIEnviron := False;
    1333           end;
    1334       end;
    1335       crypto := nil;
    1336     end;
    1337   if PKIEnviron = False then
    1338     if GetPKISite then PKIEnviron := True;
     1385  if GetPKISite then PKIEnviron := True;
    13391386  with CtrlInits do
    13401387  begin
     
    13811428      end;
    13821429      pnlTop.Height := pnlFields.Height - pnlBottom.Height;
    1383       chkDoseNow.Top := memComment.Top + memComment.Height + 4;
     1430      chkDoseNow.Top := memComment.Top + memComment.Height + 1;
    13841431      lblPriority.Top := memcomment.Top + memComment.Height + 1;
    13851432      cboPriority.Top := lblPriority.Top + lblPriority.Height;
    13861433      lblAdminTime.Left := chkDoseNow.Left;
    1387       lblAdminTime.Top := chkDoseNow.Top + chkDoseNow.Height + 1;
     1434      lblAdminTime.Top := chkDoseNow.Top + chkDoseNow.Height - 1;
    13881435    end else
    13891436    begin
     
    14561503        SetDosage(IValueFor('INSTR', i));
    14571504        with cboDosage do
    1458           if ItemIndex > -1 then x := Text + TAB + Items[ItemIndex] else x := Text;
     1505          if ItemIndex > -1 then x := Text + TAB + Items[ItemIndex]
     1506         else x := IValueFor('INSTR',i); //AGP Change 26.41 for CQ 9102 PSI-05-015 affect copy and edit functionality
    14591507        grdDoses.Cells[COL_DOSAGE, i] := x;
    14601508        SetControl(cboRoute,  'ROUTE', i);
     
    14741522          if ItemIndex > -1 then x := x + TAB + Items[ItemIndex];
    14751523        grdDoses.Cells[COL_SCHEDULE, i] := x;
     1524        if chkPRN.Checked = True then grdDoses.Cells[COL_CHKXPRN,i] := '1';
    14761525        grdDoses.Cells[COL_DURATION, i] := IValueFor('DAYS', i);
    14771526        if      IValueFor('CONJ', i) = 'A' then x := 'AND'
     
    15971646  txtMed.SetFocus;
    15981647  FDrugID := '';
    1599   ShowOrderMessage( False );
     1648  //ShowOrderMessage( False );
    16001649end;
    16011650
     
    16281677
    16291678procedure TfrmODMeds.ShowControlsSimple;
    1630 var
    1631   dosagetxt: string;
     1679//var
     1680  //dosagetxt: string;
    16321681begin
    16331682  //Commented out, no longer using CharsNeedMatch Property
     
    16611710procedure TfrmODMeds.ShowControlsComplex;
    16621711
    1663   procedure MoveCombo(SrcCombo, DestCombo: TORComboBox);
    1664   begin
    1665     DestCombo.Items.Clear;
    1666     DestCombo.Items.Assign(SrcCombo.Items);
    1667     DestCombo.ItemIndex := SrcCombo.ItemIndex;
    1668     DestCombo.Text := Piece(SrcCombo.Text, TAB, 1);
    1669   end;
    1670 
    1671 var
    1672   dosagetxt: string;
     1712  procedure MoveCombo(SrcCombo, DestCombo: TORComboBox; CompSch: boolean = false); //AGP Changes 26.12 PSI-04-63
     1713  var
     1714  cnt,i,index: integer;
     1715  node,text: string;
     1716  begin
     1717  if (CompSch = false) or not (FInptDlg)then
     1718    begin
     1719      DestCombo.Items.Clear;
     1720      DestCombo.Items.Assign(SrcCombo.Items);
     1721      DestCombo.ItemIndex := SrcCombo.ItemIndex;
     1722      DestCombo.Text := Piece(SrcCombo.Text, TAB, 1);
     1723    end;
     1724  if (CompSch = true) and (FInptDlg) then     // AGP Changes 26.12 PSI-04-63
     1725    begin
     1726    //AGP change 26.34 CQ 7201,6902 fix the problem with one time schedule still showing for inpatient complex orders
     1727    DestCombo.ItemIndex := -1;
     1728    Text := SrcCombo.Text;
     1729    index := SrcCombo.ItemIndex;
     1730    cnt := 0;
     1731    for i := 0 to SrcCombo.Items.Count - 1 do
     1732      begin
     1733        node := SrcCombo.Items.Strings[i];
     1734        if piece(node,U,3) <> 'O' then
     1735          begin
     1736            DestCombo.Items.Add(SrcCombo.Items.Strings[i]);
     1737            if Piece(node,U,1) = text then DestCombo.ItemIndex := index - cnt;
     1738          end
     1739        else cnt := cnt+1;
     1740      end;
     1741    end;
     1742  end;
     1743
     1744//var
     1745  //dosagetxt: string;
    16731746begin
    16741747  tabDose.TabIndex := TI_COMPLEX;
    16751748  MoveCombo(cboDosage,   cboXDosage);
    16761749  MoveCombo(cboRoute,    cboXRoute);
    1677   MoveCombo(cboSchedule, cboXSchedule);
     1750  MoveCombo(cboSchedule, cboXSchedule, true);  //AGP Changes 26.12 PSI-04-063
    16781751  grdDoses.Visible := True;
    16791752  btnXInsert.Visible := True;
     
    16891762  ActiveControl := grdDoses;
    16901763  //Commented out, no longer using CharsNeedMatch Property
    1691  { NumCharsForMatch := 0;
     1764{ NumCharsForMatch := 0;
    16921765  for i := 0 to cboXDosage.Items.Count - 1 do         //find the shortest unit dose text on fifth piece
    16931766  begin
     
    17191792        Break;
    17201793      end;
    1721     if ((DoseIndex < 0) and (not IsTransferAction)) then Text := x
    1722     else if ((DoseIndex < 0) and IsTransferAction) then Text := ''
     1794    if DoseIndex <0 then Text := x
     1795  (*  if ((DoseIndex < 0) and (not IsTransferAction)) then Text := x
     1796    else if ((DoseIndex < 0) and IsTransferAction) and (DosageTab = False) then Text := ''
     1797    else if ((DoseIndex < 0) and IsTransferAction) and (DosageTab = True) then Text := x *)
    17231798    else ItemIndex := DoseIndex;
    17241799  end;
     
    17401815procedure TfrmODMeds.SetSchedule(const x: string);
    17411816var
    1742   NonPRNPart: string;
     1817NonPRNPart: string;
    17431818begin
    17441819  cboSchedule.ItemIndex := -1;
    1745   if Pos('PRN', x) > 0 then
     1820  //AGP change CQ 10593, remove code to match the new expected first dose code
     1821  //PSI-05-026
     1822 (* if Pos('PRN', x) > 0 then
    17461823  begin
    17471824    NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1));
     
    17621839      chkPRN.Checked := True;
    17631840  end else
    1764   begin
     1841  begin  *)
    17651842    chkPRN.Checked := False;
    17661843    cboSchedule.SelectByID(x);
     
    17731850      else
    17741851      begin
    1775         cboSchedule.Items.Add(x);
    1776         cboSchedule.Text := x;
    1777         cboSchedule.SelectByID(x);
     1852      if Pos('PRN', x) > 0 then
     1853        begin
     1854         NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1));
     1855         chkPRN.Checked := True;
     1856         cboSchedule.SelectByID(NonPRNPart);
     1857         if cboSchedule.ItemIndex > -1 then  EXIT;
     1858         cboSchedule.Items.Add(NonPRNPart);
     1859         cboSchedule.Text := NonPRNPart;
     1860         cboSchedule.SelectByID(NonPRNPart);
     1861         EXIT;
     1862        end;
     1863         cboSchedule.Items.Add(x);
     1864         cboSchedule.Text := x;
     1865         cboSchedule.SelectByID(x);
    17781866      end;
    1779     end;
    17801867  end;
    17811868end;
    17821869
    17831870{ Medication edit --------------------------------------------------------------------------- }
    1784 
    17851871procedure TfrmODMeds.tabDoseChange(Sender: TObject);
    17861872var
    1787   x: string;
    1788 
    1789 begin
    1790   inherited;
     1873  //text,x, tmpsch: string;
     1874  text, x: string;
     1875  reset: integer;
     1876begin
     1877  inherited;
     1878  reset := 0;
     1879  //AGP change for CQ 6521 added warning message
     1880  //AGP Change for CQ 7508 added tab information
     1881  //GE  Change warning message functionality show only   cq 7590
     1882  //    when tab changes from complex to simple.
     1883  //AGP Change for CQ 7834 and 7832 change text and added check to see if some values have been completed in row 1
     1884  if (tabDose.TabIndex = 0) and ((ValFor(COL_DOSAGE, 1)<>'') or (ValFor(COL_SCHEDULE, 1)<>'') or (ValFor(COL_DURATION, 1)<>'') or
     1885      (ValFor(COL_SEQUENCE, 1)<>''))  then
     1886      begin
     1887        text := 'By switching to the Dosage Tab, ' ;
     1888         if (InfoBox(text +'you will lose all data on this screen. Click “OK” to continue or “Cancel”','Warning',MB_OKCANCEL)=IDCANCEL) then
     1889            begin
     1890             if tabDose.TabIndex = 1 then tabDose.TabIndex := 0
     1891             else tabDose.TabIndex := 1;
     1892             reset := 1;
     1893            end;
     1894      end;
    17911895  case tabDose.TabIndex of
    17921896  TI_DOSE:    begin
     1897                cboXSchedule.Clear;                       // Added to Fix CQ: 9603
    17931898                // clean up responses?
    17941899                FSuppressMsg := FOrigiMsgDisp;
    17951900                ShowControlsSimple;
    1796                 ResetOnTabChange;
     1901                if reset = 0 then ResetOnTabChange;
     1902                txtNss.Left := lblSchedule.Left + lblSchedule.Width + 2;
    17971903                if (FInptDlg) then txtNss.Visible := True
    17981904                else txtNss.Visible := False;
     
    18051911  TI_COMPLEX: begin
    18061912                FSuppressMsg := FOrigiMsgDisp;
     1913                if reset = 1 then exit;
    18071914                ShowControlsComplex;
    18081915                ResetOnTabChange;
     1916                txtNss.Left := grdDoses.Left + grdDoses.ColWidths[0] + grdDoses.ColWidths[1] + grdDoses.ColWidths[2] + 3;
    18091917                txtNss.Visible := False;
    1810                 if txtNss.Visible then txtNss.Visible := False;           
    18111918                x := cboXDosage.Text + TAB;
    18121919                with cboXDosage   do if ItemIndex > -1 then x := x + Items[ItemIndex];
     
    18181925                with cboXSchedule do if ItemIndex > -1 then x := x + Items[ItemIndex];
    18191926                grdDoses.Cells[COL_SCHEDULE, 1] := x;
     1927                UpdateStartExpires(ValFor(VAL_SCHEDULE,1));
    18201928                ControlChange(Self);
    18211929             end; {TI_COMPLEX}
    18221930  end; {case}
    18231931end;
     1932
    18241933
    18251934procedure TfrmODMeds.lblGuidelineClick(Sender: TObject);
     
    19012010
    19022011procedure TfrmODMeds.cboDosageChange(Sender: TObject);
    1903 var
    1904   tmpIdx: integer;
    1905   tmpTxt,tmpTxt1: string;
    1906 begin
    1907   inherited;
    1908   //if length(cboDosage.Text) < 1 then
    1909   //  cboDosage.ItemIndex := -1;
     2012begin
     2013  inherited;
    19102014  UpdateRelated;
    19112015end;
     
    19462050begin
    19472051  inherited;
    1948 //if cboRoute.Text = '' then
    1949 //  cboRoute.ItemIndex := -1;
    19502052  with cboRoute do
    19512053    if ItemIndex > -1 then
     
    19942096begin
    19952097  inherited;
    1996   if (FInptDlg) and (cboSchedule.Text = 'OTHER') then
     2098  if  (FInptDlg) and (cboSchedule.Text = 'OTHER') then
    19972099  begin
    19982100    othSch := CreateOtherScheduel;
     
    20042106    end;
    20052107  end;
    2006 //if cboSchedule.Text = '' then
    2007 //  cboSchedule.ItemIndex := -1;
    20082108//Remove Deletion of Text, since we are changing the validation to be on exit of the control.
    20092109{  if (Length(cboSchedule.Text)>0) and (cboSchedule.ItemIndex < 0) and FInptDlg then
     
    21162216      if Length(Route) = 0 then Route := ValueOf(FLD_ROUTE_NM);
    21172217      Schedule := ValueOf(FLD_SCHED_EX);
    2118       if Length(Schedule) = 0 then Schedule := ValueOf(FLD_SCHEDULE);
     2218      (* Schedule := Piece(Temp,U,1);
     2219      if Piece(Temp,U,3) = '1' then Schedule := Schedule + ' AS NEEDED';
     2220      if UpperCase(Copy(Schedule, Length(Schedule) - 18, Length(Schedule))) = 'AS NEEDED AS NEEDED'
     2221      then Schedule := Copy(Schedule, 1, Length(Schedule) - 10); *)
     2222      if Length(Schedule) = 0 then
     2223        begin
     2224          Schedule := ValueOf(FLD_SCHEDULE);
     2225          if RightStr(Schedule,3) = 'PRN' then
     2226             begin
     2227               Schedule := Copy(Schedule,1,Length(Schedule)-3); //Remove the Trailing PRN
     2228               if (RightStr(Schedule,1) = ' ') or (RightStr(Schedule,1) = '-') then
     2229               Schedule := Copy(Schedule,1,Length(Schedule)-1);
     2230               Schedule := Schedule + ' AS NEEDED'
     2231             end;
     2232        end;
    21192233      Result := FSIGVerb + ' ' + Dose + ' ' + Route + ' ' + Schedule;
    21202234    end;
     
    21402254        if Length(Route) = 0 then Route := ValueOf(FLD_ROUTE_NM, i);
    21412255        Schedule := ValueOf(FLD_SCHED_EX, i);
    2142         if Length(Schedule) = 0 then Schedule := ValueOf(FLD_SCHEDULE, i);
     2256        //if Length(Schedule) = 0 then Schedule := ValueOf(FLD_SCHEDULE, i);
     2257        if Length(Schedule) = 0 then
     2258        begin
     2259          Schedule := ValueOf(FLD_SCHEDULE);
     2260          if RightStr(Schedule,3) = 'PRN' then
     2261             begin
     2262               Schedule := Copy(Schedule,1,Length(Schedule)-3); //Remove the Trailing PRN
     2263               if (RightStr(Schedule,1) = ' ') or (RightStr(Schedule,1) = '-') then
     2264               Schedule := Copy(Schedule,1,Length(Schedule)-1);
     2265               Schedule := Schedule + ' AS NEEDED'
     2266             end;
     2267        end;
    21432268        Duration := ValueOf(FLD_DURATION, i);
    21442269        if Length(Duration) > 0 then Duration := 'FOR ' + Duration;
     
    22412366begin
    22422367  Result := Piece(Piece(grdDoses.Cells[COL_DOSAGE, ARow], TAB, 2), U, 4);
    2243   if (not FInptDlg) and (Length(FDrugID) > 0) then
     2368  //AGP CHANGE 26.33 change for Remedy ticket 87476 fix for quick orders for complex
     2369  //inpatient orders not displaying the correct unit dose in Pharmacy
     2370  //if (not FInptDlg) and (Length(FDrugID) > 0) then
     2371  if Length(FDrugID) > 0 then
    22442372  begin
    22452373    Result := '';
     
    24542582  TI_COMPLEX:
    24552583    begin
    2456       if txtNss.Visible then txtNss.Visible := False;
     2584      //if txtNss.Visible then txtNss.Visible := False;
    24572585      with grdDoses do for i := 1 to Pred(RowCount) do
    24582586      begin
     
    24912619                                   else Responses.Update('ROUTE',    i, '', x);
    24922620        x := ValueOf(FLD_SCHEDULE, i);  Responses.Update('SCHEDULE', i, x, x);
     2621        if FSmplPRNChkd then   // GE CQ7585  Carry PRN checked from simple to complex tab
     2622        begin
     2623           pnlXSchedule.Tag := 1;
     2624           chkXPRN.Checked := True;
     2625          //cboXScheduleClick(Self);// force onclick to fire when complex tab is entered
     2626           FSmplPRNChkd := False;
     2627        end;
    24932628        x := ValueOf(FLD_DURATION, i);  Responses.Update('DAYS',     i, UpperCase(x), x);
    24942629        x := ValueOf(FLD_SEQUENCE, i);
     
    25082643  begin
    25092644    Responses.Update('NOW',     1, ValueOf(FLD_NOW_ID), ValueOf(FLD_NOW_NM));
    2510     x := InpatientSig;                  Responses.Update('SIG',     1, TX_WPTYPE, x);
     2645    x := InpatientSig;
     2646    Responses.Update('SIG',     1, TX_WPTYPE, x);
    25112647  end else                                        // outpatient orders
    25122648  begin
     
    25482684    VAL_DURATION : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1);
    25492685    VAL_SEQUENCE : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1);
     2686    VAL_CHKXPRN  : Result := Cells[COL_CHKXPRN, ARow];
    25502687    end;
    25512688end;
     
    27292866procedure TfrmODMeds.ShowEditor(ACol, ARow: Integer; AChar: Char);
    27302867var
    2731   x, NonPRNPart: string;
     2868  x,tmpText: string;
    27322869
    27332870  procedure PlaceControl(AControl: TWinControl);
     
    27592896begin
    27602897  inherited;
     2898  txtNSS.Visible := False;
    27612899  //Make space just select editor.  This blows up as soon as some joker makes a
    27622900  //dosage starting with a space.
     
    27842922                      //grdDoses.Cells[COL_SCHEDULE, ARow] := grdDoses.Cells[COL_SCHEDULE, Pred(ARow)];
    27852923                    end;
    2786                     if grdDoses.Cells[COL_SEQUENCE, Pred(ARow)] = '' then
     2924                //AGP Change 26.45 remove auto-populate of the sequence field
     2925                {*    if grdDoses.Cells[COL_SEQUENCE, Pred(ARow)] = '' then
    27872926                    begin
    27882927                      if StrToIntDef(Piece(grdDoses.Cells[COL_DURATION, Pred(ARow)], ' ', 1), 0) > 0
    27892928                        then grdDoses.Cells[COL_SEQUENCE, Pred(ARow)] := 'THEN'
    27902929                        else grdDoses.Cells[COL_SEQUENCE, Pred(ARow)] := 'AND';
    2791                     end;
     2930                    end;  *}
    27922931                  end;
    27932932                  // set appropriate value for cboDosage
     
    28062945  COL_SCHEDULE: begin
    28072946                  // set appropriate value for cboSchedule
     2947                  if FInptDlg then txtNSS.Visible := True;
    28082948                  x := Piece(grdDoses.Cells[COL_SCHEDULE, ARow], TAB, 1);
    28092949                  Changing := TRUE;
    2810                   chkXPRN.Checked := False;
     2950                  if ValFor(VAL_CHKXPRN,Arow)='1' then chkXPRN.Checked := true
     2951                  else chkXPRN.Checked := False;
     2952                  if Pos('PRN',x)>0 then
     2953                    begin
     2954                      cboXSchedule.SelectByID(x);
     2955                      if cboXSchedule.ItemIndex <0 then
     2956                        begin
     2957                          x := Trim(Copy(x, 1, Pos('PRN', x) - 1));
     2958                          chkXPRN.Checked := true;
     2959                        end;
     2960                    end;
    28112961                  if Length(x) > 0 then
    28122962                  begin
     
    28152965                  end
    28162966                  else cboXSchedule.ItemIndex := -1;
    2817                   if Pos('PRN', x) > 0 then
     2967                (*  if Pos('PRN', x) > 0 then
    28182968                  begin
    28192969                    NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1));
     
    28252975                      if cboXSchedule.ItemIndex < 0 then cboXSchedule.Text := x;
    28262976                    end;
    2827                   end;
     2977                  end; *)
    28282978                  Changing := FALSE;
    28292979                  pnlXSequence.Tag := ARow;
     
    28442994                    btnXDuration.Caption := 'days';
    28452995                  end;
     2996                  tmpText := txtXDuration.Text;  //Fix for CQ: 8107 - Kloogy but works.
    28462997                  UpdateDurationControls(False);
    2847 
    28482998                  Changing := FALSE;
    28492999                  pnlXDuration.Tag := ARow;
    28503000                  PlaceControl(pnlXDuration);
    28513001                  txtXDuration.SetFocus;
     3002                  ARow1 := ARow;
     3003                  txtXDuration.Text := tmpText;  //Fix for CQ: 8107 - Kloogy but works.
    28523004                  if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_DURATION);
    28533005                end;
    28543006  COL_SEQUENCE: begin
    28553007                  x := ValFor(COL_SEQUENCE, ARow);
    2856                   if x = '' then x := 'then';
     3008                  //if x = '' then x := 'and';  AGP Change 26.46 remove for CQ 9535
    28573009                  btnXSequence.Caption := x;
    28583010                  pnlXSequence.Caption := btnXSequence.Caption;
    28593011                  pnlXSequence.Tag := ARow;
     3012                  ARow1 := ARow;
    28603013                  PlaceControl(pnlXSequence);
    2861                   btnXSequence.Width := pnlXSequence.Width;                 
     3014                  btnXSequence.Width := pnlXSequence.Width;
    28623015                end;
    28633016  end; {case ACol}
     
    29293082    then lblQtyMsg.Caption := TX_QTY_PRE + x + TX_QTY_POST
    29303083    else lblQtyMsg.Caption := '';
    2931 
    29323084end;
    29333085
     
    29853137    cboXRoute.ItemIndex := -1;
    29863138    Exit;
    2987   end;
     3139  end; 
    29883140  cboXRouteClick(Self);
    29893141  cboXRoute.Tag := -1;
     
    30133165procedure TfrmODMeds.cboXScheduleChange(Sender: TObject);
    30143166var
    3015   othSch, x, PRN: string;
     3167  othSch, x: string;
    30163168  idx : integer;
    30173169begin
     
    30313183      end;
    30323184    end;
    3033     if chkXPRN.Checked then PRN := ' PRN' else PRN := '';
     3185  (* if chkXPRN.Checked then PRN := ' PRN' else PRN := '';
    30343186    with cboXSchedule do if ItemIndex > -1
    30353187      then x := Text + PRN + TAB + Items[ItemIndex]
    3036       else x := Text + PRN;
     3188      else x := Text + PRN; *)
     3189    with cboXSchedule do if ItemIndex > -1
     3190      then x := Text + TAB + Items[ItemIndex]
     3191      else x := Text;
    30373192    grdDoses.Cells[COL_SCHEDULE, pnlXSchedule.Tag] := x;
     3193    self.cboSchedule.Text := x;
    30383194    UpdateRelated;
    30393195  end;
     
    30423198procedure TfrmODMeds.cboXScheduleClick(Sender: TObject);
    30433199var
    3044   x, PRN: string;
    3045 begin
    3046   inherited;
    3047   if chkXPRN.Checked then PRN := ' PRN' else PRN := '';
     3200  x: string;
     3201begin
     3202  inherited;
     3203  //if chkXPRN.Checked then PRN := ' PRN' else PRN := '';
     3204 (* with cboXSchedule do if ItemIndex > -1
     3205    then x := Text + PRN + TAB + Items[ItemIndex]
     3206    else x := Text + PRN;  *)
    30483207  with cboXSchedule do if ItemIndex > -1
    3049     then x := Text + PRN + TAB + Items[ItemIndex]
    3050     else x := Text + PRN;
    3051   if (Pos('PRN',X)>0) and (pnlXSchedule.Tag = 1) then
     3208    then x := Text + TAB + Items[ItemIndex]
     3209    else x := Text;
     3210   (* if (Pos('PRN',X)>0) and (pnlXSchedule.Tag = 1) then
    30523211    if lblAdmintime.visible then
    3053       lblAdmintime.Caption := '';
     3212      lblAdmintime.Caption := ''; *)
    30543213  grdDoses.Cells[COL_SCHEDULE, pnlXSchedule.Tag] := x;
     3214  UpdateStartExpires(x);
    30553215  UpdateRelated;
    30563216end;
    30573217
    30583218procedure TfrmODMeds.chkXPRNClick(Sender: TObject);
    3059 begin
    3060   inherited;
     3219var
     3220check: string;
     3221begin
     3222  inherited;
     3223  if self.chkXPRN.Checked = True then check := '1'
     3224  else check := '0';
     3225  self.grdDoses.Cells[COL_CHKXPRN, self.grdDoses.Row] := check;
    30613226  if not Changing then cboXScheduleClick(Self);
    30623227end;
     
    30963261var
    30973262  I, Code: Integer;
     3263  OrgValue: string;
    30983264begin
    30993265  inherited;
     
    31033269    Val(txtXDuration.Text, I, Code);
    31043270    UpdateDurationControls(Code <> 0);
    3105     if (Code <> 0) and (I=0) then
    3106     begin
    3107       ShowMessage('Free text input is not allowed!');
    3108       txtXDuration.Text := '0';
     3271    //Commented out the "and" to resolve CQ: 7557
     3272    if (Code <> 0) {and (I=0)} then
     3273    begin
     3274      ShowMessage('Please use numeric characters only.');
     3275      with txtXDuration do
     3276      begin
     3277        Text := IntToStr(I);
     3278        SelStart := Length(Text);
     3279      end;
    31093280      Exit;
    31103281      btnXDuration.Width := 8;
     
    31143285      PopDuration.Items.Tag := 0;
    31153286      btnXDuration.Caption := '';
    3116     end
     3287    end;
     3288   {AGP change 26.19 for PSI-05-018 cq #7322
    31173289    else if PopDuration.Items.Tag = 0 then
    31183290    begin
    31193291      PopDuration.Items.Tag := 3;  //Days selection
    31203292      btnXDuration.Caption := 'days';
    3121     end;
     3293    end; }
    31223294    grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := txtXDuration.Text + ' ' + Uppercase(btnXDuration.Caption);
    3123   end else grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := '';
     3295  end else   //AGP CHANGE ORDER
     3296       begin
     3297         if not(FInptDlg) then grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := '';
     3298         OrgValue := ValFor(COL_DURATION, pnlxDuration.tag);
     3299         //if ((txtXDuration.Text = '0') or (txtXDuration.Text = '')) and ((ValFor(COL_SEQUENCE, ARow1) = 'THEN') and (FInptDlg)) then //AGP CHANGE ORDER
     3300         //AGP change 26.33 Then/And conjunction requiring a duration to include outpatient orders also
     3301         if ((txtXDuration.Text = '0') or (txtXDuration.Text = '')) and (ValFor(COL_SEQUENCE, ARow1) = 'THEN') then //AGP CHANGE ORDER
     3302             begin
     3303               if (InfoBox('A duration is required when using "Then" as a sequence.'+CRLF+'"Then" will be remove from the sequence field if you continue'+
     3304                    CRLF+'Click "OK" to continue or click "Cancel"','Duration Warning', MB_OKCANCEL)=1) then
     3305                    begin
     3306                        grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := '';
     3307                        pnlXSequence.Tag := ARow1;
     3308                        pnlXSequence.Caption := '';
     3309                        grdDoses.Cells[COL_SEQUENCE, pnlXSequence.Tag] := '';
     3310                        btnXSequence.Click;
     3311                    end
     3312                    else
     3313                    grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := OrgValue;
     3314               end
     3315             else grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := txtXDuration.Text;
     3316       end;
     3317   // end;
    31243318  ControlChange(Self);
    31253319  UpdateRelated;
     
    31513345begin
    31523346  inherited;
     3347  inherited;
    31533348  with TSpeedButton(Sender) do APoint := ClientToScreen(Point(0, Height));
    31543349  popXSequence.Popup(APoint.X, APoint.Y);
    31553350  pnlXSequence.Caption := btnXSequence.Caption;
     3351  {
     3352  with TSpeedButton(Sender) do APoint := ClientToScreen(Point(0, Height));
     3353  popXSequence.Popup(APoint.X, APoint.Y);
     3354  pnlXSequence.Caption := btnXSequence.Caption;
     3355  if (pnlXSequence.Caption = 'then') and
     3356      ((ValFor(COL_DURATION, ARow1) = '') or
     3357       (ValFor(COL_DURATION, ARow1) = '0')) then
     3358     begin
     3359       InfoBox('A duration is required when using "Then" as a conjunction','Duration Warning',MB_OK);
     3360       pnlXSequence.Caption := '';
     3361       btnXSequence.Caption := '';
     3362     end;
     3363     }
    31563364end;
    31573365
     
    31623370  inherited;
    31633371  with TMenuItem(Sender) do if Tag > 0 then x := Caption else x := '';
     3372 //AGP Changes 26.12 PSI-04-63
     3373 //if ((x = 'then') and (FInptDlg)) and ((ValFor(COL_DURATION, ARow1) = '') or (ValFor(COL_DURATION, ARow1) = '0')) then
     3374 //AGP change 26.32 Then/And conjunction requiring a duration to include outpatient orders
     3375 if (x = 'then') and ((ValFor(COL_DURATION, ARow1) = '') or (ValFor(COL_DURATION, ARow1) = '0')) then
     3376     begin
     3377       InfoBox('A duration is required when using "Then" as a conjunction' + CRLF + CRLF+
     3378           'The patient will be instructed to take these doses consecutively, not concurrently.','Duration Warning',MB_OK);
     3379       x := '';
     3380     end;
    31643381  btnXSequence.Caption := x;
    31653382  pnlXSequence.Caption := btnXSequence.Caption;
     
    32793496    FLD_ROUTE_EX  : with cboRoute do
    32803497                     if ItemIndex > -1  then Result := Piece(Items[ItemIndex], U, 4);
    3281     FLD_SCHEDULE  : begin
     3498    FLD_SCHEDULE  : begin        //gary)
    32823499                      Result := UpperCase(Trim(cboSchedule.Text));
    32833500                      if chkPRN.Checked then Result := Result + ' PRN';
     
    32873504    FLD_SCHED_EX  : begin
    32883505                      with cboSchedule do
     3506                        begin
    32893507                        if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 2);
     3508                   (*     if (Length(Result)=0) and (ItemIndex > -1) then
     3509                            begin
     3510                              Result := Piece(Items[ItemIndex], U, 1);
     3511                              if Piece(Items[ItemIndex], U, 3) = 'P' then
     3512                              begin
     3513                                if RightStr(Result,3) = 'PRN' then
     3514                                  begin
     3515                                    Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
     3516                                    if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
     3517                                    Result := Copy(Result,1,Length(Result)-1);
     3518                                  end;
     3519                               Result := Result + ' AS NEEDED';
     3520                              end;
     3521                            end;
     3522                        end; *)
     3523                      if RightStr(Result,3) = 'PRN' then
     3524                           begin
     3525                              Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
     3526                              if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
     3527                              Result := Copy(Result,1,Length(Result)-1);
     3528                              Result := Result + ' AS NEEDED'
     3529                           end;
    32903530                      if (Length(Result) > 0) and chkPRN.Checked then Result := Result + ' AS NEEDED';
    32913531                      if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED'
    32923532                        then Result := Copy(Result, 1, Length(Result) - 10);
     3533                      if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then
     3534                          begin
     3535                            Result := Copy(Result, 1, Length(Result) - 13);
     3536                            if RightStr(Result,1)=' ' then Result := Result + 'AS NEEDED'
     3537                            else Result := Result + ' AS NEEDED';
     3538                          end;
     3539                    end;
    32933540                    end;
    32943541    FLD_SCHED_TYP : with cboSchedule do
     
    33303577      FLD_ROUTE_AB  : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 3);
    33313578      FLD_ROUTE_EX  : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 4);
    3332       FLD_SCHEDULE  : Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
     3579      FLD_SCHEDULE  : begin
     3580                         Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1);
     3581                         if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
     3582                         if valFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' PRN';
     3583                         if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' then
     3584                         Result := Copy(Result, 1, Length(Result) - 4);
     3585                      end;
    33333586      FLD_SCHED_EX  : begin
    3334                         Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 2);
     3587                        (*Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 2);
    33353588                        if Result = '' then //Added for CQ: 7639
    33363589                        begin
     
    33433596                           (Pos('PRN', Piece(Cells[COL_SCHEDULE, ARow], TAB, 1)) > 0)
    33443597                           then Result := Result + ' AS NEEDED';
     3598                      end;*)
     3599                        Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,2);
     3600                        if Result = '' then Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,1); //Added for CQ: 7639
     3601                        if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1);
     3602                        if RightStr(Result,3) = 'PRN' then
     3603                           begin
     3604                              Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN
     3605                              if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then
     3606                              Result := Copy(Result,1,Length(Result)-1);
     3607                              Result := Result + ' AS NEEDED';
     3608                           end;
     3609                        if valFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' AS NEEDED';
     3610                        if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED'
     3611                        then Result := Copy(Result, 1, Length(Result) - 10);
     3612                        if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then
     3613                          begin
     3614                            Result := Copy(Result, 1, Length(Result) - 13);
     3615                            if RightStr(Result,1)=' ' then Result := Result + 'AS NEEDED'
     3616                            else Result := Result + ' AS NEEDED';
     3617                          end;
    33453618                      end;
    33463619      FLD_SCHED_TYP : Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 3);
     
    35523825procedure TfrmODMeds.UpdateStartExpires(const CurSchedule: string);
    35533826var
    3554   ShowText, Duration, ASchedule: string;
     3827  CompSch, ShowText, Duration, ASchedule: string;
    35553828  AdminTime:    TFMDateTime;
    3556   Interval, PrnPos: Integer;
     3829  i, j, Interval, PrnPos: Integer;
    35573830begin
    35583831  if Length(CurSchedule)=0 then Exit;
    35593832  ASchedule := Trim(CurSchedule);
    3560   if (Pos('^',ASchedule)=0) then
    3561   begin
    3562     PrnPos := Pos('PRN',ASchedule);
    3563     if (PrnPos > 1) and (CharAt(ASchedule,PrnPos-1) <> ';') then
    3564       Delete(ASchedule, PrnPos, Length(ASchedule));
    3565   end
    3566   else if (Pos('^',ASchedule)>0) then
     3833  if (Pos('^',ASchedule)>0) then
    35673834  begin
    35683835    PrnPos := Pos('PRN',ASchedule);
     
    35713838  end;
    35723839  ASchedule := Trim(ASchedule);
     3840  if self.tabDose.TabIndex = TI_COMPLEX then
     3841    begin
     3842      CompSch := valFor(VAL_SCHEDULE,1);
     3843      if CompSch = '' then
     3844        begin
     3845          ASchedule := '';
     3846          AdminTime := -1;
     3847        end;
     3848      if CompSch <> '' then
     3849        begin
     3850          for i := 0 to self.cboXSchedule.Items.Count-1 do
     3851            begin
     3852              if (Piece(self.cboXSchedule.Items.Strings[i],U,1) = CompSch) and (Piece(self.cboXSchedule.Items.Strings[i],U,3)='P') then
     3853                begin
     3854                  AdminTime := -1;
     3855                  Aschedule := '';
     3856                end;
     3857            end;
     3858        end;
     3859        if valFor(VAL_CHKXPRN,1)='1' then
     3860          begin
     3861            AdminTime := -1;
     3862            Aschedule := '';
     3863          end;
     3864      if (ASchedule <> '') and (CompSch <> '') then ASchedule := ';' + CompSch;
     3865    end;
    35733866  if Length(ASchedule)>0 then
    3574       LoadAdminInfo(ASchedule, txtMed.Tag, ShowText, AdminTime, Duration)
    3575   else Exit;
     3867      LoadAdminInfo(ASchedule, txtMed.Tag, ShowText, AdminTime, Duration);
     3868  //else Exit;
     3869  if (AdminTime > 0) and (self.tabDose.TabIndex = TI_DOSE) then
     3870    begin
     3871     if self.cboSchedule.ItemIndex = -1 then
     3872       begin
     3873         for j := 0 to self.cboSchedule.items.Count -1 do
     3874           begin
     3875             if (Piece(self.cboSchedule.Items.Strings[j],U,1) = Piece(Aschedule,';',2)) and (Piece(self.cboSchedule.Items.Strings[j],U,3)='P') then
     3876               begin
     3877                 AdminTime := -1;
     3878                 break;
     3879               end;
     3880           end;
     3881       end;
     3882     if (self.cboSchedule.ItemIndex > -1) and (Piece(self.cboSchedule.Items.Strings[self.cboSchedule.ItemIndex],U,3)='P') then
     3883       AdminTime := -1;
     3884     if self.chkPRN.Checked = true then AdminTime := -1
     3885    end;
    35763886  if AdminTime > 0 then
    35773887  begin
     
    36303940  CurSupply, i, pNum, j: Integer;
    36313941  CurQuantity: double;
    3632   LackQtyInfo, SaveChanging: Boolean;
     3942  LackQtyInfo, SaveChanging, DispFirstDose: Boolean;
    36333943begin
    36343944  inherited;
     
    36373947  SaveChanging := Changing;
    36383948  Changing := TRUE;
     3949  DispFirstDose := FALSE;
    36393950  // don't allow Exit procedure so Changing gets reset appropriately
    36403951  CurUnits    := '';
     
    37004011      or ((Length(cboSchedule.Text)>0) and (cboSchedule.ItemIndex < 0)) then
    37014012    begin
    3702         if (chkDoseNow.Checked) and (chkDoseNow.Visible) then
     4013      if (chkDoseNow.Checked) and (chkDoseNow.Visible) then
     4014      begin
     4015        chkDoseNowClick(Self);
     4016        chkDoseNow.Checked := False;
     4017      end;
     4018      for i := 0 to cboSchedule.Items.Count-1 do
    37034019        begin
    3704           chkDoseNowClick(Self);
    3705           chkDoseNow.Checked := False;
     4020                  if Piece(cboSchedule.Items.Strings[i],U,1) = Uppercase(cboSchedule.Text) then
     4021            begin
     4022              DispFirstDose := True;
     4023              break;
     4024            end;
    37064025        end;
    3707         chkDoseNow.Visible := False;
    3708         lblAdminTime.Visible := False;
     4026      if not DispFirstDose then
     4027        begin
     4028          chkDoseNow.Visible := False;
     4029          lblAdminTime.Visible := False;
     4030        end;
    37094031    end
    37104032    else
     
    37154037    if Responses.EventType in ['A','D','T','M','O'] then lblAdminTime.Visible := False;
    37164038  end;
    3717   if not FInptDlg then
     4039    if not FInptDlg then
    37184040  begin
    37194041    CurSchedule := CurScheduleOut;
    3720     if CurInstruct <> FLastInstruct
     4042    if (CurInstruct <> FLastInstruct) and (CurUnits <> U) //AGP Change 26.48 Do not update quantity and day supply if no matching dose on the server
    37214043      then UpdateDefaultSupply(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity,
    37224044                               LackQtyInfo);
     
    37514073
    37524074procedure TfrmODMeds.cmdAcceptClick(Sender: TObject);
    3753 begin
    3754   if (cboSchedule.Text = 'OTHER') and (FInptDlg)then
     4075var
     4076i: integer;
     4077begin
     4078  if (FInptDlg) and (cboSchedule.Text = 'OTHER') then
    37554079  begin
    37564080    cboScheduleClick(Self);
    37574081    Exit;
    37584082  end;
     4083  //AGP Change for 26.45 PSI-04-069
     4084  if self.tabDose.TabIndex = 1 then
     4085    begin
     4086       for i := 2 to self.grdDoses.RowCount do
     4087         begin
     4088           if ((ValFor(COL_DOSAGE, i-1) <> '') and (ValFor(COL_DOSAGE, i) <> '')) and (ValFor(COL_SEQUENCE,i-1) = '') then
     4089             begin
     4090              infoBox('To be able to complete a complex order every row except for the last row must have a conjunction defined. ' + CRLF
     4091              + CRLF + 'Verify that all rows have a conjunction defined.','Sequence Error',MB_OK);
     4092              Exit;
     4093             end;
     4094           //text := Self.cboXDosage.Items.Strings[i];
     4095         end;
     4096    end;
    37594097  if FInptDlg and (not FOutptIV)
    37604098    then DisplayGroup := DisplayGroupByName('UD RX')
    37614099  else DisplayGroup := DisplayGroupByName('O RX');
     4100  //timCheckChangesTimer(Self);
    37624101  DropLastSequence;
    37634102  cmdAccept.SetFocus;
    37644103  inherited;
     4104  (*if self.Responses.Cancel = true then
     4105    begin
     4106      self.Destroy;
     4107      exit;
     4108    end; *)
    37654109end;
    37664110
     
    37914135    if length(theSch)>0 then
    37924136    begin
    3793       if (ValueOf(FLD_SCHED_TYP) <> 'O') and (InfoBox(T1+medNm+T+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) then
     4137      if ( (ValueOf(FLD_SCHED_TYP) <> 'O') and (InfoBox(T1+medNm+T+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) )then
    37944138      begin
    37954139        chkDoseNow.Checked := False;
     
    38084152  if (tabDose.TabIndex = TI_COMPLEX) and chkDoseNow.Checked  then
    38094153  begin
    3810     if (ValueOf(FLD_SCHED_TYP) <> 'O') and ( InfoBox('Give Additional Dose Now is in addition to those listed in the table.' + CRLF +
     4154    if ( (ValueOf(FLD_SCHED_TYP) <> 'O') and (InfoBox('Give Additional Dose Now is in addition to those listed in the table.' + CRLF +
    38114155                 'Please adjust the duration of the first row, if necessary.',
    3812                  'Give Additional Dose Now for Complex Order', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) then
     4156                 'Give Additional Dose Now for Complex Order', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) ) then
    38134157    begin
    38144158      chkDoseNow.Checked := False;
     
    39084252var
    39094253  tempSch: string;
    3910 begin
    3911   inherited;
    3912   if chkPRN.Checked then lblAdminTime.Caption := ''
     4254  PRNPos: integer;
     4255begin
     4256  inherited;
     4257  //GE  CQ 7552
     4258  if chkPRN.Checked then
     4259  begin
     4260     lblAdminTime.Caption := '';
     4261     PrnPos := Pos('PRN',cboSchedule.Text);
     4262     if (PrnPos < 1) then
     4263        UpdateStartExpires(cboSchedule.Text + ' PRN');
     4264  end
    39134265  else
    39144266  begin
     
    39184270      UpdateStartExpires(tempSch);
    39194271    end;
    3920     lblAdminTime.Caption := FAdminTimeLbl;
     4272    //lblAdminTime.Caption := FAdminTimeLbl;
    39214273    if txtQuantity.visible then
    39224274      cboScheduleClick(Self);
     
    40314383  end
    40324384  else if (Key = #13) and (ActiveControl = txtMed) then
    4033     Key := #0   //Don't let the base class turn it into a forward tab!
    4034   else
    4035     inherited;
     4385    Key := #0;   //Don't let the base class turn it into a forward tab!
    40364386end;
    40374387
     
    42844634  inherited;
    42854635  if MessageDlg('You can also select ' + '"' + 'Other' + '"' + ' from the schedule list'
    4286     + ' to create a day-of-week or admin-time only schedule.'
     4636    + ' to create a day-of-week schedule.'
    42874637    + #13#10 + 'Click OK to launch schedule builder',
    42884638    mtInformation, [mbOK, mbCancel],0) = mrOK then
     
    42924642      cboSchedule.SelectByID('OTHER');
    42934643      cboScheduleClick(Self);
     4644    end;
     4645    if  (tabDose.TabIndex = TI_COMPLEX) then
     4646    begin
     4647      cboXSchedule.SelectByID('OTHER');
     4648      CBOXScheduleChange(Self);
    42944649    end;
    42954650  end;
     
    43254680
    43264681procedure TfrmODMeds.ValidateInpatientSchedule(ScheduleCombo: TORComboBox);
    4327 begin
    4328   //CQ 7575  Schedule coming across lower-case, change all schedules to Upper-Case.
     4682var
     4683  tmpIndex : Integer;
     4684begin
     4685
     4686{CQ: 6690 - Orders - autopopulation of schedule field - overtyping only 1 character
     4687 CQ: 7280 - PTM 32-34, 42 Meds: NJH-0205-20901 MED DIALOG DROPPING FIRST LETTER (schedule)}
     4688
     4689 //CQ 7575  Schedule coming across lower-case, change all schedules to Upper-Case.
    43294690  if (Length(ScheduleCombo.Text) > 0) then
    4330      ScheduleCombo.Text := UpperCase(ScheduleCombo.Text);
     4691    ScheduleCombo.Text := TrimLeft(UpperCase(ScheduleCombo.Text));
     4692    {if user entered schedule verify it is in list}
     4693  if ScheduleCombo.ItemIndex < 0 then // CQ: 7397
     4694  begin //Fix for CQ: 9299 - Outpatient Med orders will not accept free text schedule
     4695    tmpIndex := GetSchedListIndex(ScheduleCombo,ScheduleCombo.Text);
     4696    if tmpIndex > -1 then
     4697      ScheduleCombo.ItemIndex := tmpIndex;
     4698  end;
    43314699  if (Length(ScheduleCombo.Text) > 0) and (ScheduleCombo.ItemIndex < 0) and FInptDlg then
    43324700  begin
    43334701    FShowPnlXScheduleOk := False; //Added for CQ: 7370
    43344702    Application.MessageBox('Please select a valid schedule from the list.'+#13+#13+
    4335                            'If you would like to create a non-standard schedule please'+
     4703                           'If you would like to create a Day-of-Week schedule please'+
    43364704                           ' select ''OTHER'' from the list.',
    43374705                           'Incorrect Schedule.');
     
    43444712
    43454713//Removed based on Site feeback. See CQ: 7518
    4346 {function TfrmODMeds.ValidateRoute(RouteCombo: TORComboBox) : Boolean;
    4347 begin
     4714(*function TfrmODMeds.ValidateRoute(RouteCombo: TORComboBox) : Boolean;
     4715begin
     4716{CQ: 7331 - Medications - Route - Can not enter any route not listed in Route field in window}
    43484717  Result := True;
    43494718  if (Length(RouteCombo.Text) > 0) and (RouteCombo.ItemIndex < 0) and (Not IsSupplyAndOutPatient) then
     
    43564725    Result := False;
    43574726  end;
    4358 end;}
     4727end;*)
    43594728
    43604729function TfrmODMeds.isUniqueQuickOrder(iText: string): Boolean;
     
    43734742function TfrmODMeds.IsSupplyAndOutPatient: boolean;
    43744743begin
     4744{CQ: 7331 - Medications - Route - Can not enter any route not listed in Route field in window}
    43754745  Result := False;
    43764746  if (MedIsSupply(txtMed.Tag)) and (not FInptDlg) then
     
    43784748end;
    43794749
     4750// CQ: 7397 - Inpatient med orders with PRN cancel due to invalid schedule.
     4751function TfrmODMeds.GetSchedListIndex(SchedCombo: TORComboBox; pSchedule: String):integer;
     4752var i: integer;
     4753begin
     4754    result := -1;
     4755    for i := 0 to SchedCombo.items.Count-1 do
     4756    begin
     4757         if pSchedule = SchedCombo.DisplayText[i] then
     4758         begin
     4759           result := i;   // match found
     4760           break;
     4761         end;
     4762    end;
     4763end;
     4764
    43804765
    43814766procedure TfrmODMeds.cboXScheduleExit(Sender: TObject);
    43824767begin
    43834768  inherited;
     4769{CQ: 7344 - Inconsistency with Schedule box: Allows free-text entry for Complex orders,
     4770            doesn't for simple orders }
    43844771  ValidateInpatientSchedule(cboXSchedule);
    43854772end;
    43864773
     4774procedure TfrmODMeds.cboDosageKeyUp(Sender: TObject; var Key: Word;
     4775  Shift: TShiftState);
     4776begin
     4777  inherited;
     4778  //Fix for CQ: 7545
     4779  if cboDosage.ItemIndex > -1 then
     4780    cboDosageClick(Sender);
     4781end;
     4782
     4783procedure TfrmODMeds.cboXDosageKeyUp(Sender: TObject; var Key: Word;
     4784  Shift: TShiftState);
     4785begin
     4786  inherited;
     4787  //Fix for CQ: 7545
     4788  if cboXDosage.ItemIndex > -1 then
     4789    cboXDosageClick(Sender);
     4790end;
     4791
     4792procedure TfrmODMeds.txtSupplyClick(Sender: TObject);
     4793begin
     4794  inherited;
     4795  Self.txtSupply.SelectAll;
     4796end;
     4797
     4798procedure TfrmODMeds.txtQuantityClick(Sender: TObject);
     4799begin
     4800  inherited;
     4801   self.txtQuantity.SelectAll;
     4802end;
     4803
     4804procedure TfrmODMeds.txtRefillsClick(Sender: TObject);
     4805begin
     4806  inherited;
     4807  self.txtRefills.SelectAll;
     4808end;
     4809
     4810procedure TfrmODMeds.WMClose(var Msg: TWMClose);
     4811begin
     4812   if self <> nil then
     4813     begin
     4814       if (self.tabDose.TabIndex = TI_Dose) then
     4815         begin
     4816            if Trim(cboSchedule.Text) = '' then cboSchedule.ItemIndex := -1;
     4817            ValidateInpatientSchedule(cboSchedule);
     4818            if self.cboSchedule.Focused = true then exit;
     4819         end;
     4820       if (self.tabDose.TabIndex = TI_Complex) then
     4821         begin
     4822           ValidateInpatientSchedule(cboXSchedule);
     4823           if self.cboXSchedule.Focused = true then exit;
     4824         end;
     4825     end;
     4826    inherited
     4827end;
     4828
     4829procedure TfrmODMeds.cboXScheduleEnter(Sender: TObject);
     4830begin
     4831  inherited;
     4832  //agp Change CQ 10719
     4833   self.chkXPRN.OnClick(self.chkXPRN);
     4834end;
     4835
    43874836end.
Note: See TracChangeset for help on using the changeset viewer.