Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (10 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/fODMeds.pas

    r829 r1679  
    189189    procedure cboXSequenceEnter(Sender: TObject);
    190190    procedure txtRefillsChange(Sender: TObject);
     191    procedure QuantityMessageCheck(Tag: integer)  ;
     192    procedure pnlXDurationButtonEnter(Sender: TObject);
     193    procedure cboRouteKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
     194    procedure cboScheduleKeyUp(Sender: TObject; var Key: Word;
     195      Shift: TShiftState);
     196    procedure cboXScheduleKeyUp(Sender: TObject; var Key: Word;
     197      Shift: TShiftState);
     198    procedure cboXSequenceKeyUp(Sender: TObject; var Key: Word;
     199      Shift: TShiftState);
     200    procedure cboPriorityKeyUp(Sender: TObject; var Key: Word;
     201      Shift: TShiftState);
    191202    //procedure btnNSSClick(Sender: TObject);
    192203  private
     
    289300    procedure UpdateDefaultSupply(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string;
    290301      var CurSupply: Integer; var CurQuantity: double; var SkipQtyCheck: Boolean);
    291     procedure UpdateSupplyQuantity(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string;
     302    procedure UpdateSupplyQuantity(const CurUnits, CurSchedule, CurDuration, CurDispDrug, CurInstruct: string;
    292303      var CurSupply: Integer; var CurQuantity: double);
    293304    procedure UpdateDurationControls( FreeText: boolean);
     
    397408  FLD_COMMENT   = 80;
    398409  FLD_PTINSTR   = 85;
     410  FLD_DRUG_ID_INT = 90;
    399411  {dosage type tab index values}
    400412  TI_DOSE       =  0;
     
    542554  end;
    543555  if self.EvtID > 0  then FAdminTimeText := 'To Be Determined';
     556  if (isIMO = True) then self.Caption := 'Clinic Orders Medications'
     557  else if FInptDlg = True then self.Caption := 'Inpatient Medications'
     558  else if DlgFormID = OD_MEDOUTPT then self.Caption := 'Outpatient Medications'
     559  else self.Caption := 'Medications Orders';
    544560  ListForOrderable(FCacheIEN, ListCount, x);
    545561  lstAll.Items.Count := ListCount;
     
    614630procedure TfrmODMeds.SetupDialog(OrderAction: Integer; const ID: string);
    615631var
    616   AnInstr, OrderID, nsSch, Text, tempOrder, tempSchString, tempSchType, AdminTime: string;
    617   ix: integer;
     632  AnInstr, OrderID, nsSch, Text, tempOrder, tempSchString, tempSchType, AdminTime, x: string;
     633  i, ix: integer;
    618634  LocChange: boolean;
    619635  AResponse: TResponse;
     
    631647  //AGP 27.72 Order Action behave similar to QO this is why Edit and Copy are setting FIsQuickOrder to true
    632648  //this is not the best approach but this should fix the problem with order edit losing the quantity value.
    633   if (OrderAction = ORDER_QUICK) or (OrderAction = ORDER_EDIT) or (OrderAction = ORDER_COPY) then
     649  if ((OrderAction = ORDER_QUICK) or (OrderAction = ORDER_EDIT) or (OrderAction = ORDER_COPY)) then
    634650  begin
    635651    FIsQuickOrder := True;
     
    647663    Changing := True;
    648664    txtMed.Tag  := StrToIntDef(Responses.IValueFor('ORDERABLE', 1), 0);
     665    if OrderAction = ORDER_QUICK then
     666      begin
     667        if DEACheckFailed(txtMed.Tag, FInptDlg) then
     668          begin
     669            //btnSelect.Visible := False;
     670            btnSelect.Enabled := False;
     671            InfoBox(TX_NO_DEA, TC_NO_DEA, MB_OK);
     672            AbortOrder := True;
     673            Exit;
     674          end;
     675      end;
    649676    if (OrderAction = ORDER_QUICK) and (uOrders.PassDrugTstCall = False) and
    650677     (uOrders.OutptDisp = OutptDisp) and (PassDrugTest(txtMed.Tag, 'Q', false) = False) then Exit;
     
    672699             if length(nsSch) > 0 then
    673700             begin
    674                 SetSchedule(nsSch);
     701                SetSchedule(UpperCase(nsSch));
    675702                {cboSchedule.SelectByID(nsSch);
    676703                if cboSchedule.ItemIndex < 0 then
     
    694721              AResponse := Responses.FindResponseByName('ADMIN', 1);
    695722              if AResponse <> nil then AdminTime := AResponse.EValue;
    696               if self.cboSchedule.ItemIndex > -1 then
     723              if (self.cboSchedule.ItemIndex > -1) and (AdminTime <> '') then
    697724                begin
    698725                  tempSchString := self.cboSchedule.Items.Strings[cboSchedule.itemindex];
     
    700727                  self.cboSchedule.Items.strings[cboSchedule.ItemIndex] := tempSchString;
    701728                end;
    702               if self.tabDose.TabIndex = TI_COMPLEX then
     729              if (self.tabDose.TabIndex = TI_COMPLEX) and (Responses.InstanceCount('INSTR') = 1) and (AdminTime <> '') then
    703730                begin
    704731                  if self.cboXSchedule.ItemIndex > -1 then
     
    722749                     end;
    723750                  end;
    724                if self.tabDose.TabIndex = TI_COMPLEX then
     751               if (self.tabDose.TabIndex = TI_COMPLEX) and (Responses.InstanceCount('INSTR') = 1) then
    725752                begin
    726753                  if self.cboXSchedule.ItemIndex > -1 then
     
    742769      end;
    743770    if ((OrderAction <> Order_COPY) and (OrderAction <> Order_EDIT)) or
    744     (XfInToOutNow = true) or (FIsQuickOrder) then UpdateRelated(FALSE); //AGP Change
     771       (XfInToOutNow = true) or (FIsQuickOrder) then
     772       begin
     773         UpdateRelated(FALSE); //AGP Change
     774         //Need to do the following code to reset the FLastUnits and FLastSchedule in case a free text Dose is found. If the following
     775         //code is not done than the quantity will reset to zero
     776         if not FInptDlg  then
     777         begin
     778           FLastUnits := '';
     779           FLastSchedule := '';
     780           FLastInstruct := '';
     781           //Lasti := Responses.InstanceCount('INSTR');
     782           //Lasti := Responses.NextInstance('DOSE', 0);
     783           for I := 1 to Responses.InstanceCount('INSTR') do
     784             begin
     785               x := ValueOfResponse(FLD_DOSEUNIT,  i);
     786               FLastUnits  := FLastUnits   + x  + U;
     787               x := Responses.IValueFor('INSTR',    i);
     788               FLastInstruct := FLastInstruct + x + U;
     789               x := ValueOfResponse(FLD_SCHEDULE,  i);
     790               FLastSchedule := FLastSchedule + x + U;
     791             end;
     792         end;
     793       end;
    745794    Changing := False;
    746795    if ((OrderAction = Order_Copy) or (OrderAction = Order_Edit)) and
     
    762811    memComment.Clear;  // sometimes the sig is in the comment
    763812  end;
     813  FQOInitial := False;
    764814  ControlChange(Self);
    765815  if Self.IsSupply then
     
    818868    ADrug  := ValueOfResponse(FLD_DRUG_ID,  AnInstance);
    819869    tmpX := x; //Changed for CQ: 7370 - it was tmpX := Trim(x);
     870    if Pos(CRLF, tmpX)> 0 then
     871      begin
     872        SetError('Schedule cannot contains control characters');
     873        Exit;
     874      end;
    820875    if (Length(tmpX) = 0) and (not FInptDlg) then SetError(TX_NO_SCHED)
    821876    else if (Length(tmpX) = 0) and FInptDlg and ScheduleRequired(txtMed.Tag, ARoute, ADrug)
     
    824879    begin
    825880      if FInptDlg then ValidLevel := ValidSchedule(tmpX) else ValidLevel := ValidSchedule(tmpX, 'O');
     881   (*   if FInptDlg and (tmpX <> '') and (cboSchedule.ItemIndex = -1) and
     882      (self.tabDose.TabIndex = TI_DOSE) then
     883         //SetError('Unique Schedule Selection Required');
     884         SetError('More than one schedule starts with "'+tmpX+'". Please select a schedule from the list.');  *)
    826885      if ValidLevel = SCH_NO_RTN then
    827886      begin
     
    857916      if Length(Responses.IValueFor('INSTR', i)) > 60       then
    858917      begin
    859          SetError(TX_DOSE_LEN);
    860          cboDosage.SetFocus;  //CQ: 7467
     918         if self.tabDose.TabIndex = TI_COMPLEX then
     919           begin
     920              SetError('Dosage: ' + Responses.IValueFor('INSTR', i) + CRLF + TX_DOSE_LEN);
     921           end
     922         else
     923           begin
     924              SetError(TX_DOSE_LEN);
     925              cboDosage.SetFocus;  //CQ: 7467
     926           end;
    861927      end;
    862928    end;
     
    889955                Exit;
    890956              end;
     957           if Uppercase(ValFor(Col_Sequence, i)) = 'THEN' then
     958             begin
     959                if ValFor(Col_Duration,i) = '' then
     960                  begin
     961                    SetError('A duration is required when using "Then" as a sequence.');
     962                    Exit;
     963                  end;
     964             end;
    891965         end;
    892966    end;
     
    13181392  chunk := GetCacheChunkIndex(Item.Index);
    13191393  list := TStringList(FMedCache[chunk]);
    1320   x := list[Item.Index mod MED_CACHE_CHUNK_SIZE];
    1321   Item.Caption := Piece(x, U, 2);
    1322   Item.Data := Pointer(StrToIntDef(Piece(x, U, 1), 0));
     1394  //This is to make sure that the index that is being used is not outside of the stringlist
     1395  If Item.Index mod MED_CACHE_CHUNK_SIZE < list.Count then begin
     1396   x := list[Item.Index mod MED_CACHE_CHUNK_SIZE];
     1397   Item.Caption := Piece(x, U, 2);
     1398   Item.Data := Pointer(StrToIntDef(Piece(x, U, 1), 0));
     1399  end;
    13231400end;
    13241401
     
    14151492        end; *)
    14161493      FAltChecked := True;
    1417       ;
    14181494      SetOnMedSelect;   // set up for this medication
    14191495      SetOnQuickOrder;  // insert quick order responses
     
    14241500      if (txtQuantity.Text = '0') and (Length(QOQuantityStr)>0) then
    14251501        txtQuantity.Text := QOQuantityStr;
     1502      //FQOInitial := False;
    14261503    end
    14271504    else if (FActiveMedList = lstAll) and (lstAll.Selected <> nil) then  // orderable item
     
    14531530      begin
    14541531        temp := self.MedName;
    1455         CheckFormularyOI(MedIEN, temp, FInptDlg);
     1532        CheckFormularyOI(medIEN, temp, FInptDlg);
    14561533        FAltChecked := True;
     1534        txtMed.Text := '';
    14571535      end;
    14581536      if MedIEN <> txtMed.Tag then
     
    14811559  else ShowMedSelect;                             // show the selection fields
    14821560  FNoZERO   := False;
     1561  if FQOInitial = True then FQOInitial := False;
     1562 
    14831563end;
    14841564
     
    15851665    // set up lists & initial values based on orderable item
    15861666    SetControl(txtMed,       'Medication');
    1587     if (self.MedName <> '') then
     1667        if (self.MedName <> '') then
    15881668       begin
    15891669         if (txtMed.Text <> self.MedName) then
     
    16031683    AResponse := Responses.FindResponseByName('SCHEDULE',1);
    16041684    if (AResponse <> nil) and (AResponse.EValue <> '') then  x := AResponse.EValue;
    1605     SetSchedule(x);
     1685    SetSchedule(UpperCase(x));
    16061686   (* if x <> '' then
    16071687    begin
     
    17161796var
    17171797  AResponse: TResponse;
    1718   x,LocRoute,TempSch,DispGrp: string;
     1798  x,LocRoute,TempSch,DispGrp, SchType: string;
    17191799  i, DispDrug: Integer;
    17201800begin
     
    17301810        SetDosage(IValueFor('INSTR', i));
    17311811        with cboDosage do
    1732           if ItemIndex > -1 then x := Text + TAB + Items[ItemIndex]
     1812          //agp change QO code to populate the Grid with the same fields after selection CQ 15933
     1813          //if ItemIndex > -1 then x := Text + TAB + Items[ItemIndex]
     1814          if ItemIndex > -1 then x := Piece(Text, TAB, 1) + TAB + Items[ItemIndex]
    17331815         else x := IValueFor('INSTR',i); //AGP Change 26.41 for CQ 9102 PSI-05-015 affect copy and edit functionality
    17341816        grdDoses.Cells[COL_DOSAGE, i] := x;
     
    17371819          if ItemIndex > -1 then x := Text + TAB + Items[ItemIndex] else x := Text;
    17381820        grdDoses.Cells[COL_ROUTE,  i] := x;
    1739         if FIsQuickOrder then TempSch := cboSchedule.Text;
    1740         SetSchedule(IValueFor('SCHEDULE', i));
    1741         if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = False) then
    1742         begin
    1743           cboSchedule.SelectByID(TempSch);
    1744           cboSchedule.Text := TempSch;
    1745         end;
     1821        SetSchedule(UpperCase(IValueFor('SCHEDULE', i)));
    17461822        if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = True) then cboSchedule.ItemIndex := -1;
    17471823        x := cboSchedule.Text;
     
    17551831          begin
    17561832            if IValueFor('ADMIN', i) <> '' then grdDoses.Cells[COL_ADMINTIME, i] := IValueFor('ADMIN', i)
    1757             else if cboSchedule.ItemIndex > -1 then
     1833            else if (cboSchedule.ItemIndex > -1) and (chkPRN.Checked = false) then
    17581834               grdDoses.Cells[COL_ADMINTIME, i] := Piece(cboSchedule.Items.Strings[cboSchedule.itemIndex],U,4)
    17591835            else grdDoses.Cells[COL_ADMINTIME, i] := '';
    17601836            if grdDoses.Cells[COL_ADMINTIME, i] = '' then grdDoses.Cells[COL_ADMINTIME, i] := 'Not Defined';
    17611837            if FAdminTimeText <> '' then grdDoses.Cells[COL_ADMINTIME, i] := FAdminTimeText;
     1838            //done to prevent admin time showing up in schedules that should not have admin times. Also remove Not Defined for schedule
     1839            //should not show the admin time
     1840            if (cboSchedule.ItemIndex > -1) or (chkPRN.Checked = True) then
     1841              begin
     1842                SchType := '';
     1843                if (cboSchedule.ItemIndex > -1) then SchType := Piece(cboSchedule.Items.Strings[cboSchedule.itemIndex],U,3);
     1844                if (SchType = 'P') or (SchType = 'O') or (SchType = 'OC') or (ChkPRN.Checked = True) then
     1845                  grdDoses.Cells[COL_ADMINTIME, i] := '';
     1846              end;
    17621847          end;
     1848        chkPRN.Checked := false;
    17631849        if      IValueFor('CONJ', i) = 'A' then x := 'AND'
    17641850        else if IValueFor('CONJ', i) = 'T' then x := 'THEN'
     
    17791865        SetDosage(IValueFor('INSTR', 1));
    17801866      SetControl(cboRoute,  'ROUTE',     1);
    1781       SetSchedule(IValueFor('SCHEDULE',  1));
     1867      SetSchedule(UpperCase(IValueFor('SCHEDULE',  1)));
    17821868      if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = False) then
    17831869      begin
     
    18451931    end; {if FInptDlg..else}
    18461932  end; {with}
    1847  if FInptDlg then
     1933 if (FInptDlg) then
    18481934  begin
    18491935    x := ValueOfResponse(FLD_SCHEDULE, 1);
     
    19011987  btnSelect.Default := False;
    19021988  cmdAccept.Visible := True;
    1903   cmdAccept.Default := True;
     1989  cmdAccept.Default := False;
    19041990  cmdAccept.Left := cmdQuit.Left;
    19051991  cmdAccept.Top := MemOrder.Top;
     
    19962082begin
    19972083  tabDose.TabIndex := TI_COMPLEX;
     2084  lblAdminSchSetTexT('');
    19982085  MoveCombo(cboDosage,   cboXDosage);
    19992086  MoveCombo(cboRoute,    cboXRoute);
     
    20792166      end;
    20802167    cboSchedule.ItemIndex := -1;
     2168    cboSchedule.Text := '';
    20812169    if chkPRN.Checked = True then chkPRN.Checked := False;
    20822170    cboSchedule.SelectByID(x);
    20832171    if cboSchedule.ItemIndex > -1 then exit;
     2172    if (X = ' PRN') or (X = 'PRN') then
     2173      begin
     2174        chkPRN.Checked := True;
     2175        Exit;
     2176      end;
    20842177   // if cboSchedule.ItemIndex < 0 then
    20852178    //begin
     
    24332526end;
    24342527
     2528procedure TfrmODMeds.cboRouteKeyUp(Sender: TObject; var Key: Word;
     2529  Shift: TShiftState);
     2530begin
     2531  inherited;
     2532  if (Key = VK_BACK) and (cboRoute.Text = '') then cboRoute.ItemIndex := -1;
     2533end;
     2534
    24352535{ cboSchedule ----------------------------------- }
    24362536
     
    24722572    if length(trim(othSch)) > 1 then
    24732573    begin
     2574      othSch := othSch + U + U + NSSScheduleType + U + NSSAdminTime;
    24742575      cboSchedule.Items.Add(othSch);
    2475       idx := cboSchedule.Items.IndexOf(OthSch);
     2576      idx := cboSchedule.Items.IndexOf(Piece(OthSch, U, 1));
    24762577      cboSchedule.ItemIndex := idx;
    24772578    end;
     
    25262627  txtXDurationChange(Sender);
    25272628  ControlChange(Sender);
     2629end;
     2630
     2631procedure TfrmODMeds.QuantityMessageCheck(tag: integer);
     2632var
     2633DispDrug: integer;
     2634x: string;
     2635
     2636begin
     2637  if FInptDlg then Exit;
     2638  DispDrug := StrToIntDef(ValueOf(FLD_DRUG_ID, tag), 0);
     2639  if DispDrug > 0 then
     2640  begin
     2641    if not FSuppressMsg then
     2642    begin
     2643      DispOrderMessage(DispenseMessage(DispDrug));
     2644      FSuppressMsg  := False;
     2645    end;
     2646    x := QuantityMessage(DispDrug);
     2647  end
     2648  else x := '';
     2649  if Length(x) > 0
     2650    then lblQtyMsg.Caption := TX_QTY_PRE + x + TX_QTY_POST
     2651    else lblQtyMsg.Caption := '';
    25282652end;
    25292653
     
    27422866    for i := 0 to Pred(FAllDoses.Count) do
    27432867    begin
    2744       if AnsiSameText(DoseDrug, Copy(FAllDoses[i], 1, Length(DoseDrug))) then
     2868       // CQ #16957 - Corrected code that would potentially mis-match drugs - JCS
     2869      //if AnsiSameText(DoseDrug, Copy(FAllDoses[i], 1, Length(DoseDrug))) then
     2870      if AnsiSameText(DoseDrug, Pieces(FAllDoses[i],U,1,2)) then
    27452871      begin
    27462872        Result := Piece(FAllDoses[i], U, 3);
     
    31423268      if Piece(x, ' ', 2) = 'MONTHS'  then DoseMinutes := ExtractInteger(x) * 43200;
    31433269      if Piece(x, ' ', 2) = 'WEEKS'   then DoseMinutes := ExtractInteger(x) * 10080;
    3144       if Piece(x, ' ', 2) = 'DAYS'    then DoseMinutes := ExtractInteger(x) * 1440;
     3270      if Pos('DAY',Piece(x, ' ', 2))>0    then DoseMinutes := ExtractInteger(x) * 1440;
    31453271      if Piece(x, ' ', 2) = 'HOURS'   then DoseMinutes := ExtractInteger(x) * 60;
    31463272      if Piece(x, ' ', 2) = 'MINUTES' then DoseMinutes := ExtractInteger(x);
     
    31823308  with grdDoses do
    31833309  begin
    3184     i := grdDoses.Width - 12;                 // 12 = 4 pixel margin + 8 pixel column 0
     3310    i := grdDoses.Width - 20;                 // 20 = 12 pixel margin + 8 pixel column 0
    31853311    i := i - GetSystemMetrics(SM_CXVSCROLL);  // compensate for appearance of scroll bar
    31863312    if (not FinptDlg) or (FAdminTimeText = 'Not defined for Clinic Locations') then
     
    34643590  DisableDefaultButton(self);
    34653591  DisableCancelButton(self);
     3592  QuantityMessageCheck(cboXDosage.Tag);
    34663593end;
    34673594
     
    37303857  str := str + CRLF + CRLF + AdminTimeHelpText;
    37313858  infoBox(str,'Administration Time Information',MB_OK);
     3859end;
     3860
     3861procedure TfrmODMeds.pnlXDurationButtonEnter(Sender: TObject);
     3862begin
     3863  inherited;
     3864  QuantityMessageCheck(self.grdDoses.Row);
    37323865end;
    37333866
     
    40744207    FLD_QUANTITY  :
    40754208    begin
    4076        if Pos(',', txtQuantity.Text)>0 then 
     4209       if Pos(',', txtQuantity.Text)>0 then
    40774210        Result := Piece(txtQuantity.Text,',',1) + Piece(txtQuantity.Text,',',2)
    40784211       else
     
    41294262begin
    41304263  Checked := false;
    4131   if ((StrToFloatDef(txtQuantity.Text, 0) = 0) and (StrToIntDef(txtSupply.Text, 0) = 0) and
     4264 if ((StrToFloatDef(txtQuantity.Text, 0) = 0) and (StrToIntDef(txtSupply.Text, 0) = 0) and
    41324265     (txtQuantity.Tag = 0) and (txtSupply.Tag = 0) and (cboDosage.Text <> ''))
    41334266     or ((cboDosage.ItemIndex < 0) and (not FIsQuickOrder)) or
     
    41374270    ADrug := Piece(CurDispDrug, U, 1);
    41384271    CurSupply := DefaultDays(ADrug, CurUnits, CurSchedule);
    4139     if CurSupply > 0 then
     4272    if CurSupply > 0 then           
    41404273    begin
    41414274      spnSupply.Position := CurSupply;
     
    41604293      SkipQtyCheck := TRUE;
    41614294    end;
    4162     if FQOInitial = true then FQOInitial := False;   
     4295    //if FQOInitial = true then FQOInitial := False;
    41634296  end;
    41644297  if (IsClozapineOrder = true) and (CurDispDrug <> '') and (CurDispDrug <> U)and (Checked = false) then
     
    41854318end;
    41864319
    4187 procedure TfrmODMeds.UpdateSupplyQuantity(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string;
     4320//add CURInstrcut to this procedure. This address a problem with an user starting with a free-text dosage and changing
     4321//to another free-text dose and the quantity value not updating.
     4322procedure TfrmODMeds.UpdateSupplyQuantity(const CurUnits, CurSchedule, CurDuration, CurDispDrug, CurInstruct: string;
    41884323  var CurSupply: Integer; var CurQuantity: double);
    41894324const
     
    41974332  ADrug: string;
    41984333  SaveChanging: Boolean;
    4199   tmpQuty: Double;
    4200 begin
    4201   tmpQuty := 0;
     4334  tmpQuantity: double;
     4335begin
    42024336  if (tabDose.TabIndex = TI_COMPLEX) and (txtSupply.Tag = 0) and (txtQuantity.Tag = 0) then
    42034337  begin
     
    42204354     (CurDuration = FLastDuration) and
    42214355     (CurQuantity = FLastQuantity) and
    4222      (CurSupply   = FLastSupply)   then Exit;
     4356     (CurSupply   = FLastSupply)   and
     4357     (CurInstruct = FLastInstruct) then Exit;
    42234358  // exit if supply & quantity have both been directly edited
    42244359  if (txtSupply.Tag > 0) and (txtQuantity.Tag > 0) then Exit;
     
    42294364  else if (CurSupply <> FLastSupply) and (txtQuantity.Tag = 0) then UpdateControl := UPD_QUANTITY
    42304365  else if (CurQuantity <> FLastQuantity) and (txtSupply.Tag = 0) then UpdateControl := UPD_SUPPLY;
    4231   if (UpdateControl = UPD_NONE) and ((CurUnits <> FLastUnits) or (CurSchedule <> FLastSchedule)) then
     4366  if (UpdateControl = UPD_NONE) and (((CurUnits <> FLastUnits) or (CurInstruct <> FLastInstruct)) or (CurSchedule <> FLastSchedule)) then
    42324367  begin
    42334368    if txtQuantity.Tag = 0    then UpdateControl := UPD_QUANTITY
     
    42394374                   if FIsQuickOrder and (CurQuantity > 0) and FQOInitial then
    42404375                   begin
    4241                      FQOInitial := False;
     4376                     txtQuantity.Text := FloatToStr(CurQuantity);
    42424377                     Exit;
    42434378                   end;
    4244                    if FIsQuickOrder and (CurQuantity > 0) then
    4245                      tmpQuty := CurQuantity;
    42464379                   CurQuantity := DaysToQty(CurSupply,   CurUnits, CurSchedule, CurDuration, ADrug);
    4247                    if (tmpQuty > 0) and (CurQuantity <= 0) then
    4248                    begin
    4249                      txtQuantity.Text := FloatToStr(tmpQuty);
    4250                      CurQuantity := tmpQuty;
    4251                    end else if (CurQuantity >= 0) then
     4380                   if (CurQuantity >= 0) then
    42524381                     txtQuantity.Text := FloatToStr(CurQuantity);
    42534382                 end;
     
    42584387  UPD_BOTH     : begin
    42594388                   txtSupply.Text     := IntToStr(CurSupply);
    4260                    tmpQuty := 0;
     4389                   spnSupply.Position := StrToIntDef(txtSupply.Text, 0);
     4390                   tmpQuantity := DaysToQty(CurSupply,   CurUnits, CurSchedule, CurDuration, ADrug);
    42614391                   if FIsQuickOrder and (CurQuantity > 0) and FQOInitial then
     4392                      begin
     4393                        txtQuantity.Text := FloatToStr(CurQuantity);
     4394                        Exit;
     4395                      end;
     4396                  (* if FIsQuickOrder and (CurQuantity > 0) and (tmpQuantity = 0) and FQOInitial then
    42624397                   begin
    4263                      FQOInitial := False;
     4398                     txtQuantity.Text := FloatToStr(CurQuantity);
    42644399                     Exit;
    4265                    end;
    4266                    if FIsQuickOrder and (CurQuantity > 0) then
    4267                      tmpQuty := CurQuantity;
    4268                    CurQuantity := DaysToQty(CurSupply,   CurUnits, CurSchedule, CurDuration, ADrug);
    4269                    if (tmpQuty > 0) and (CurQuantity <= 0) then
    4270                    begin
    4271                      txtQuantity.Text := FloatToStr(tmpQuty);
    4272                      CurQuantity := tmpQuty;
    4273                    end else if CurQuantity >= 0 then
     4400                   end;  *)
     4401                   //CurQuantity := DaysToQty(CurSupply,   CurUnits, CurSchedule, CurDuration, ADrug);
     4402                   CurQuantity := tmpQuantity;
     4403                   if CurQuantity >= 0 then
    42744404                     txtQuantity.Text := FloatToStr(CurQuantity);
    42754405                 end;
     
    45794709          lblAdminTime.Caption := '';
    45804710    end;
    4581    if (self.tabDose.TabIndex = TI_DOSE) and (CurSchedule <> FLastSchedule) then UpdateStartExpires(CurSchedule);
    4582    //AGP remove this code for CQ 11772
    4583   (*if (ValueOf(FLD_SCHED_TYP) = 'O')
    4584       or (Responses.EventType in ['A','D','T','M','O'])
    4585       or ((Length(cboSchedule.Text)>0) and (cboSchedule.ItemIndex < 0)) then
    4586     begin
    4587       if (chkDoseNow.Checked) and (chkDoseNow.Visible) then
    4588       begin
    4589         chkDoseNowClick(Self);
    4590         chkDoseNow.Checked := False;
    4591       end;
    4592           chkDoseNow.Visible := False;
    4593           lblAdminTime.Visible := False;
    4594     end
    4595     else
    4596       begin
    4597         chkDoseNow.Visible := TRUE;
    4598         lblAdminTime.Visible := not chkDoseNow.Checked;
    4599       end;  *)
     4711   if (self.tabDose.TabIndex = TI_DOSE) and (CurSchedule <> FLastSchedule) then
     4712     UpdateStartExpires(CurSchedule);
    46004713    if Responses.EventType in ['A','D','T','M','O'] then lblAdminTime.Visible := False;
    46014714  end;
    4602     if not FInptDlg then
     4715  if not FInptDlg then
    46034716  begin
    46044717    CurSchedule := CurScheduleOut;
    46054718    if ((CurInstruct <> FLastInstruct) and (CurUnits <> U)) or ((IsClozapineOrder = true) and (CurDispDrug <> '') and (CurDispDrug <> U)) //AGP Change 26.48 Do not update quantity and day supply if no matching dose on the server
     4719    //if ((CurInstruct <> FLastInstruct) and (CurUnits <> U))
    46064720      then UpdateDefaultSupply(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity,
    46074721                               LackQtyInfo);
     
    46114725    end
    46124726    else
    4613       UpdateSupplyQuantity(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity);
     4727      UpdateSupplyQuantity(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurInstruct, CurSupply, CurQuantity);
    46144728   // if (CurDispDrug <> FLastDispDrug) then UpdateSC(CurDispDrug);
    46154729    if ((CurDispDrug <> FLastDispDrug) or (CurSupply <> FLastSupply)) and ((CurDispDrug <> '') and (CurSupply > 0))  then
     
    46334747  if FUpdated then ControlChange(Self);
    46344748  FScheduleChanged := false;
     4749  //FQOInitial := False;
    46354750end;
    46364751
     
    46444759    Exit;
    46454760  end;
     4761  if timCheckChanges.Enabled = True then sleep(1500);
    46464762  //AGP Change for 26.45 PSI-04-069
    46474763  if self.tabDose.TabIndex = 1 then
     
    46904806  T  = '"';
    46914807  T1 = 'By checking the "Give additional dose now" box, you have actually entered two orders for the same medication "';
    4692   T2 = #13#13'The first order''s administrative schedule is "';
    4693   T3 = #13'The second order''s administrative schedule is "';
     4808  T2 = #13#13'The "Give additional dose now" order has an administration schedule of "';
     4809  T3 = #13'The "Ongoing" order has an administration schedule of "';
    46944810  T4 = #13#13'Do you want to continue?';
     4811  T5 = '" and a priority of "';           
    46954812  T1A = 'By checking the "Give additional dose now" box, you have actually entered a new order with the schedule "NOW"';
    46964813  T2A = ' in addition to the one you are placing for the same medication "';
     
    46984815  medNm: string;
    46994816  theSch: string;
     4817  ordPriority: string;
    47004818begin
    47014819  inherited;
     
    47044822    medNm := txtMed.Text;
    47054823    theSch := cboSchedule.Text;
     4824    ordPriority := cboPriority.SelText;
    47064825    if length(theSch)>0 then
    47074826    begin
    47084827      //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
    4709       if InfoBox(T1+medNm+T+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL then
     4828      //if InfoBox(T1+medNm+T+T2+theSch+T+T3+'NOW"'+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL then
     4829      if InfoBox(T1+medNm+T+T2+'NOW'+T5+ordPriority+T+T3+theSch+T5+ordPriority+T+T4, 'Warning', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL then
    47104830      begin
    47114831        chkDoseNow.Checked := False;
     
    48324952     lblAdminTime.Caption := '';
    48334953     PrnPos := Pos('PRN',cboSchedule.Text);
    4834      if (PrnPos < 1) then
     4954     if (PrnPos < 1) and (FQOInitial = false) then
    48354955        UpdateStartExpires(cboSchedule.Text + ' PRN');
    48364956  end
     
    48404960    begin
    48414961      tempSch := ';'+Trim(cboSchedule.Text);
    4842       UpdateStartExpires(tempSch);
     4962      if FQOInitial = false then UpdateStartExpires(tempSch);
    48434963    end;
    48444964    //lblAdminTime.Caption := FAdminTimeLbl;
     
    48464966      cboScheduleClick(Self);
    48474967  end;
     4968  if FQOInitial = false then updateRelated(False);
     4969  //updateRelated(False);
    48484970  ControlChange(Self);
    48494971end;
     
    49655087procedure TfrmODMeds.FormKeyPress(Sender: TObject; var Key: Char);
    49665088begin
    4967  (* if (Key = #13) and (ActiveControl = grdDoses{pnlXSequence}) then
    4968   begin
    4969     ShowEditor(grdDoses.Col, grdDoses.Row, #0);
    4970     Key := #0;  //Don't let the base class turn it into a forward tab!
    4971   end *)
    4972   //else
    4973   if (Key = #13) and (ActiveControl = txtMed) then
    4974     Key := #0;   //Don't let the base class turn it into a forward tab!
     5089 if (Key = #13) and (ActiveControl = txtMed) then
     5090  Key := #0   //Don't let the base class turn it into a forward tab!
     5091 else if (Key = #13) and (self.tabDose.TabIndex = TI_Complex) then
     5092      Key := #0
     5093 else
     5094  inherited;
    49755095end;
    49765096
     
    49935113  DisableDefaultButton(self);
    49945114  DisableCancelButton(self);
     5115  QuantityMessageCheck(self.grdDoses.Row);
    49955116end;
    49965117
     
    50415162  tempAdmin := lblAdminSchGetText;
    50425163  if tempAdmin <> '' then lblAdminSchSetText('Admin Time: ' + tempAdmin);
     5164  if not (FInptDLG) then
     5165    begin
     5166      if self.cboPriority.Left < (self.grpPickup.Left + self.grpPickup.Width) then
     5167        begin
     5168          self.cboPriority.Left := self.grpPickup.Left + self.grpPickup.Width + 2;
     5169          if self.Width < (self.cboPriority.Left + self.cboPriority.Width) then
     5170                begin
     5171                  self.Width := self.cboPriority.Left + self.cboPriority.Width + 9;
     5172                  self.cboPriority.Left := self.pnlBottom.Width - self.cboPriority.Width - 2;
     5173                end;
     5174          self.lblPriority.Left := self.cboPriority.Left;
     5175        end;
     5176    end;
    50435177end;
    50445178
     
    51345268  result := False;
    51355269  IsInptDlg := False;
    5136   Td := FMToday;
     5270  // CQ #15188 - changed to use function to determine Td value - TDP
     5271  //Td := FMToday;
     5272  Td := IMOTimeFrame;
    51375273  if DlgFormID = MedsInDlgFormId  then IsInptDlg := TRUE;
    51385274  IsIMOLocation := IsValidIMOLoc(Encounter.Location,Patient.DFN);
     5275
     5276  // CQ #15188 - allow IMO functionality 23 hours after encounter date/time - JCS
     5277  // CQ #15188 - changed to use function to set Td.  Reverted this line back to original - TDP
     5278  {if (IsInptDlg) and (not Patient.Inpatient) and IsIMOLocation and
     5279    (Encounter.DateTime > DateTimeToFMDateTime(FMDateTimeToDateTime(FMNow) - (23/24))) then}
    51395280  if (IsInptDlg) and (not Patient.Inpatient) and IsIMOLocation and (Encounter.DateTime > Td) then
    51405281    result := True;
     
    52715412    cboSchedule.ItemIndex := -1;
    52725413  ValidateInpatientSchedule(cboSchedule);
     5414  updateRelated(False);
     5415end;
     5416
     5417
     5418procedure TfrmODMeds.cboScheduleKeyUp(Sender: TObject; var Key: Word;
     5419  Shift: TShiftState);
     5420begin
     5421  inherited;
     5422  if (Key = VK_BACK) and (cboSchedule.Text = '') then cboSchedule.itemindex:= -1;
    52735423end;
    52745424
     
    52855435    ScheduleCombo.Text := TrimLeft(UpperCase(ScheduleCombo.Text));
    52865436    {if user entered schedule verify it is in list}
    5287   if ScheduleCombo.ItemIndex < 0 then // CQ: 7397
     5437  if (ScheduleCombo.ItemIndex < 0) and (not FInptDlg) then // CQ: 7397  and CQ 17934
    52885438  begin //Fix for CQ: 9299 - Outpatient Med orders will not accept free text schedule
    52895439    tmpIndex := GetSchedListIndex(ScheduleCombo,ScheduleCombo.Text);
     
    52985448                           ' select ''OTHER'' from the list.',
    52995449                           'Incorrect Schedule.');
     5450          ScheduleCombo.ItemIndex := -1;
     5451          ScheduleCombo.Text := '';
    53005452    FShowPnlXScheduleOk := True;  //Added for CQ: 7370
    53015453    if ScheduleCombo.CanFocus then
    53025454      ScheduleCombo.SetFocus;
    5303     ScheduleCombo.SelStart := Length(ScheduleCombo.Text);
     5455    //ScheduleCombo.SelStart := Length(ScheduleCombo.Text);
    53045456  end;
    53055457end;
     
    53695521            doesn't for simple orders }
    53705522  ValidateInpatientSchedule(cboXSchedule);
     5523end;
     5524
     5525
     5526procedure TfrmODMeds.cboXScheduleKeyUp(Sender: TObject; var Key: Word;
     5527  Shift: TShiftState);
     5528begin
     5529  inherited;
     5530  if (Key = VK_BACK) and (cboXSchedule.Text = '') then cboXSchedule.ItemIndex := -1;
    53715531end;
    53725532
     
    53965556  DisableDefaultButton(self);
    53975557  DisableCancelButton(self);
     5558  QuantityMessageCheck(self.grdDoses.Row);
    53985559end;
    53995560
     
    54275588end;
    54285589
     5590
     5591procedure TfrmODMeds.cboXSequenceKeyUp(Sender: TObject; var Key: Word;
     5592  Shift: TShiftState);
     5593begin
     5594  inherited;
     5595  if (Key = VK_BACK) and (cboXSequence.Text = '') then cboXSequence.ItemIndex := -1;
     5596end;
     5597
    54295598procedure TfrmODMeds.cboXSequence1Exit(Sender: TObject);
    54305599begin
     
    54375606begin
    54385607  inherited;
     5608  if (Key = VK_BACK) and (cboDosage.Text = '') then cboDosage.ItemIndex := -1;
    54395609  //Fix for CQ: 7545
    54405610  if cboDosage.ItemIndex > -1 then
     
    54445614end;
    54455615
     5616
     5617procedure TfrmODMeds.cboPriorityKeyUp(Sender: TObject; var Key: Word;
     5618  Shift: TShiftState);
     5619begin
     5620  inherited;
     5621  if (Key = VK_BACK) and (cboPriority.Text = '') then cboPriority.ItemIndex := -1;
     5622end;
     5623
    54465624procedure TfrmODMeds.cboXDosageKeyUp(Sender: TObject; var Key: Word;
    54475625  Shift: TShiftState);
    54485626begin
    54495627  inherited;
     5628  if (Key = VK_BACK) and (cboXDosage.Text = '') then cboXDosage.itemindex := -1;
    54505629  //Fix for CQ: 7545
    54515630  if cboXDosage.ItemIndex > -1 then
     
    55065685  //agp Change CQ 10719
    55075686   self.chkXPRN.OnClick(self.chkXPRN);
     5687   QuantityMessageCheck(self.grdDoses.Row);
    55085688end;
    55095689
Note: See TracChangeset for help on using the changeset viewer.