Changeset 829 for cprs/trunk/CPRS-Chart/Orders/fODMeds.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/Orders/fODMeds.pas
r456 r829 8 8 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 9 9 fODBase, StdCtrls, ComCtrls, ExtCtrls, ORCtrls, Grids, Buttons, uConst, ORDtTm, 10 Menus, XUDIGSIGSC_TLB ;10 Menus, XUDIGSIGSC_TLB, VA508AccessibilityManager, VAUtils, Contnrs; 11 11 12 12 const … … 26 26 cboXRoute: TORComboBox; 27 27 pnlXDuration: TPanel; 28 pnlXSequence: TKeyClickPanel;29 btnXSequence: TSpeedButton;30 28 timCheckChanges: TTimer; 31 29 popDuration: TPopupMenu; … … 34 32 hours1: TMenuItem; 35 33 minutes1: TMenuItem; 36 popXSequence: TPopupMenu;37 and1: TMenuItem;38 then1: TMenuItem;39 34 months1: TMenuItem; 40 35 weeks1: TMenuItem; … … 78 73 radPickClinic: TRadioButton; 79 74 cboPriority: TORComboBox; 80 chkSC: TCheckBox;81 lblAdminTime: TStaticText;82 75 stcPI: TStaticText; 83 76 chkPtInstruct: TCheckBox; … … 86 79 memDrugMsg: TMemo; 87 80 txtNSS: TLabel; 88 SpeedButton1: TSpeedButton; 81 pnlXAdminTime: TPanel; 82 cboXSequence: TORComboBox; 83 lblAdminSch: TMemo; 84 lblAdminTime: TVA508StaticText; 89 85 procedure FormCreate(Sender: TObject); 90 86 procedure btnSelectClick(Sender: TObject); … … 138 134 procedure cboXRouteChange(Sender: TObject); 139 135 procedure cboXScheduleChange(Sender: TObject); 140 procedure pnlXSequenceExit(Sender: TObject);141 procedure btnXSequenceClick(Sender: TObject);142 136 procedure grdDosesExit(Sender: TObject); 143 137 procedure ListViewEnter(Sender: TObject); 144 138 procedure timCheckChangesTimer(Sender: TObject); 145 139 procedure popDurationClick(Sender: TObject); 146 procedure popXSequenceClick(Sender: TObject);147 procedure chkSCEnter(Sender: TObject);148 procedure chkSCClick(Sender: TObject);149 140 procedure cmdAcceptClick(Sender: TObject); 150 141 procedure btnXInsertClick(Sender: TObject); … … 167 158 Shift: TShiftState); 168 159 procedure cboXRouteEnter(Sender: TObject); 169 procedure pnlXSequenceEnter(Sender: TObject);170 160 procedure pnlMessageEnter(Sender: TObject); 171 161 procedure pnlMessageExit(Sender: TObject); … … 174 164 procedure memPIClick(Sender: TObject); 175 165 procedure FormResize(Sender: TObject); 176 procedure spnQuantityChangingEx(Sender: TObject;177 var AllowChange: Boolean; NewValue: Smallint;178 Direction: TUpDownDirection);179 166 procedure memPIKeyDown(Sender: TObject; var Key: Word; 180 167 Shift: TShiftState); … … 196 183 procedure WMClose(var Msg : TWMClose); message WM_CLOSE; 197 184 procedure cboXScheduleEnter(Sender: TObject); 185 procedure pnlXAdminTimeClick(Sender: TObject); 186 procedure cboXSequenceChange(Sender: TObject); 187 procedure cboXSequence1Exit(Sender: TObject); 188 procedure cboXSequenceExit(Sender: TObject); 189 procedure cboXSequenceEnter(Sender: TObject); 190 procedure txtRefillsChange(Sender: TObject); 198 191 //procedure btnNSSClick(Sender: TObject); 199 192 private 193 FCloseCalled : Boolean; 200 194 FScheduleChanged : Boolean; 201 195 {selection} 202 FAllItems: TStringList; 203 FAllFirst: Integer; 204 FAllLast: Integer; 205 FAllList: Integer; 196 FMedCache: TObjectList; 197 FCacheIEN: Integer; 206 198 FQuickList: Integer; 207 199 FQuickItems: TStringList; … … 237 229 FNoZERO: boolean; 238 230 FIsQuickOrder: boolean; 239 FAdminTimeLbl: string;240 231 FDisabledDefaultButton: TButton; 241 232 FDisabledCancelButton: TButton; … … 250 241 FRemoveText : Boolean; 251 242 FSmplPRNChkd: Boolean; 243 {Admin Time} 244 FAdminTimeLbl: string; 245 FMedName: String; 246 FNSSAdminTime: string; 247 FNSSScheduleType: string; 248 FAdminTimeText: string; 249 //FOriginalAdminTime: string; 250 //FOriginalScheduleIndex: integer; 251 FOrderAction: integer; 252 JAWSON: boolean; 252 253 procedure ChangeDelayed; 253 254 function FindQuickOrder(const x: string): Integer; 254 255 function isUniqueQuickOrder(iText: string): Boolean; 256 function GetCacheChunkIndex(idx: integer): integer; 255 257 procedure LoadMedCache(First, Last: Integer); 256 258 procedure ScrollToVisible(AListView: TListView); … … 284 286 procedure UpdateRelated(DelayUpdate: Boolean = TRUE); 285 287 procedure UpdateRefills(const CurDispDrug: string; CurSupply: Integer); 286 procedure UpdateSC(const CurDispDrug: string);287 288 procedure UpdateStartExpires(const CurSchedule: string); 288 289 procedure UpdateDefaultSupply(const CurUnits, CurSchedule, CurDuration, CurDispDrug: string; … … 313 314 function IsSupplyAndOutPatient : boolean; 314 315 function GetSchedListIndex(SchedCombo: TORComboBox; pSchedule: String):integer; 316 procedure DisplayDoseNow(Status: boolean); 317 function lblAdminSchGetText: string; 318 procedure lblAdminSchSetText(str: string); 315 319 protected 320 procedure Loaded; override; 316 321 procedure InitDialog; override; 317 322 procedure Validate(var AnErrMsg: string); override; 323 procedure updateSig; override; 318 324 public 319 325 ARow1: integer; 320 326 procedure SetupDialog(OrderAction: Integer; const ID: string); override; 321 327 procedure CheckDecimal(var AStr: string); 328 property MedName: string read FMedName write FMedName; 329 property NSSAdminTime: string read FNSSAdminTime write FNSSAdminTime; 330 property NSSScheduleType: string read FNSSScheduleType write FNSSScheduleType; 322 331 end; 323 332 … … 331 340 332 341 uses rCore, uCore, ORFn, rODMeds, rODBase, rOrders, fRptBox, fODMedOIFA, 333 u AccessibleStringGrid, uOrders, fOtherSchedule, StrUtils, fFrame;342 uOrders, fOtherSchedule, StrUtils, fFrame, VA508AccessibilityRouter; 334 343 335 344 const 336 345 {grid columns for complex dosing} 337 COL_SELECT = 0; 338 COL_DOSAGE = 1; 339 COL_ROUTE = 2; 340 COL_SCHEDULE = 3; 341 COL_DURATION = 4; 342 COL_SEQUENCE = 5; 343 COL_CHKXPRN = 6; 344 VAL_DOSAGE = 10; 345 VAL_ROUTE = 20; 346 VAL_SCHEDULE = 30; 347 VAL_DURATION = 40; 348 VAL_SEQUENCE = 50; 349 VAL_CHKXPRN = 60; 350 TAB = #9; 346 COL_SELECT = 0; 347 COL_DOSAGE = 1; 348 COL_ROUTE = 2; 349 COL_SCHEDULE = 3; 350 COL_DURATION = 4; 351 COL_ADMINTIME = 5; 352 COL_SEQUENCE = 6; 353 COL_CHKXPRN = 7; 354 VAL_DOSAGE = 10; 355 VAL_ROUTE = 20; 356 VAL_SCHEDULE = 30; 357 VAL_DURATION = 40; 358 VAL_ADMINTIME = 50; 359 VAL_SEQUENCE = 60; 360 VAL_CHKXPRN = 70; 361 TAB = #9; 351 362 {field identifiers} 352 363 FLD_LOCALDOSE = 1; … … 395 406 TIMER_FROM_DAYS = 1; 396 407 TIMER_FROM_QTY = 2; 408 409 MED_CACHE_CHUNK_SIZE = 100; 397 410 {text constants} 398 411 TX_ADMIN = 'Requested Start: '; … … 440 453 AutoSizeDisabled := True; 441 454 inherited; 455 FAdminTimeText := ''; 442 456 btnXDuration.Align := alClient; 443 457 AllowQuickOrder := True; … … 475 489 //if (Self.EvtID > 0) then LoadSchedules(cboSchedule.Items) 476 490 //else LoadSchedules(cboSchedule.Items, FInptDlg); 477 LoadSchedules(cboSchedule.Items, FInptDlg); 491 LoadSchedules(cboSchedule.Items, FInptDlg); 478 492 StatusText(''); 479 493 if FInptDlg then SetControlsInpatient else SetControlsOutpatient; … … 482 496 FOrigiMsgDisp := FSuppressMsg; 483 497 InitDialog; 498 isIMO := IfisIMODialog; 499 if (isIMO) or ((FInptDlg) and (encounter.Location <> patient.Location)) then 500 FAdminTimeText := 'Not defined for Clinic Locations'; 484 501 if FInptDlg then 485 502 begin … … 489 506 end; 490 507 with grdDoses do 491 begin 508 begin 492 509 ColWidths[0] := 8; // select 493 510 ColWidths[1] := 160; // dosage … … 495 512 ColWidths[3] := 102; // schedule 496 513 ColWidths[4] := 70; // duration 497 ColWidths[5] := 58; // and/then 514 if (FInptDlg) and (FAdminTimeText <> 'Not defined for Clinic Locations') then 515 begin 516 ColWidths[5] := 102; // administration times 517 ColWidths[6] := 58; // and/then 518 end 519 else 520 ColWidths[5] := 0; 521 ColWidths[6] := 58; 498 522 Cells[1, 0] := 'Dosage'; 499 523 Cells[2, 0] := 'Route'; 500 524 Cells[3, 0] := 'Schedule'; 501 525 Cells[4, 0] := 'Duration (optional)'; 502 Cells[5, 0] := ' then/and';503 end;504 TAccessibleStringGrid.WrapControl(grdDoses);526 Cells[5, 0] := 'Admin. Times'; 527 Cells[6, 0] := 'then/and'; 528 end; 505 529 506 530 // medication selection 507 531 FRowHeight := MainFontHeight + 1; 508 532 509 IsIMO := IfIsIMODialog; //IMO533 //IsIMO := IfIsIMODialog; //IMO 510 534 if (Self.EvtID > 0) then IsIMO := False; // event order can not be IMO order. 511 535 if FInptDlg then x := 'UD RX' … … 517 541 x := 'IVM RX'; 518 542 end; 519 ListForOrderable(FAllList, ListCount, x); 543 if self.EvtID > 0 then FAdminTimeText := 'To Be Determined'; 544 ListForOrderable(FCacheIEN, ListCount, x); 520 545 lstAll.Items.Count := ListCount; 521 FAllItems := TStringList.Create; 522 FAllFirst := -1; 523 FAllLast := -1; 546 FMedCache := TObjectList.Create; 524 547 FQuickItems := TStringList.Create; 525 548 ListForQuickOrders(FQuickList, ListCount, x); … … 546 569 FShowPnlXScheduleOk := True; 547 570 FRemoveText := True; 571 JAWSON := True; 572 if ScreenReaderActive = false then 573 begin 574 lblAdminTime.TabStop := false; 575 lblAdminSch.TabStop := false; 576 memOrder.TabStop := false; 577 JAWSON := false; 578 end; 548 579 end; 549 580 … … 552 583 {selection} 553 584 FQuickItems.Free; 554 F AllItems.Free;585 FMedCache.Free; 555 586 {edit} 556 587 FGuideline.Free; 557 588 FAllDoses.Free; 558 589 FAllDrugs.Free; 559 TAccessibleStringGrid.UnwrapControl(grdDoses);560 590 frmFrame.pnlVisit.Enabled := true; 561 591 inherited; … … 584 614 procedure TfrmODMeds.SetupDialog(OrderAction: Integer; const ID: string); 585 615 var 586 AnInstr, OrderID, nsSch, Text : string;616 AnInstr, OrderID, nsSch, Text, tempOrder, tempSchString, tempSchType, AdminTime: string; 587 617 ix: integer; 588 begin 589 inherited; 618 LocChange: boolean; 619 AResponse: TResponse; 620 621 begin 622 inherited; 623 FOrderAction := OrderAction; 624 if self.EvtID > 0 then DisplayDoseNow(false); 590 625 if XfInToOutNow then DisplayGroup := DisplayGroupByName('O RX'); 591 if CharAt(ID,1)='X'then626 if (CharAt(ID,1)='X') or (CharAt(ID,1)='C') then 592 627 begin 593 628 OrderID := Copy(Piece(ID, ';', 1), 2, Length(ID)); 594 629 CheckExistingPI(OrderID, FPtInstruct); 595 630 end; 596 if OrderAction = ORDER_QUICK then 631 //AGP 27.72 Order Action behave similar to QO this is why Edit and Copy are setting FIsQuickOrder to true 632 //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 597 634 begin 598 635 FIsQuickOrder := True; … … 610 647 Changing := True; 611 648 txtMed.Tag := StrToIntDef(Responses.IValueFor('ORDERABLE', 1), 0); 649 if (OrderAction = ORDER_QUICK) and (uOrders.PassDrugTstCall = False) and 650 (uOrders.OutptDisp = OutptDisp) and (PassDrugTest(txtMed.Tag, 'Q', false) = False) then Exit; 651 if (OrderAction = ORDER_QUICK) and (uOrders.PassDrugTstCall = False) and 652 ((uOrders.ClinDisp = ClinDisp) or (uOrders.InptDisp = InptDisp)) and (PassDrugTest(txtMed.Tag, 'Q', true) = False) then Exit; 653 (* if (OrderAction = ORDER_QUICK) then 654 begin 655 tempAltIEN := GetQOAltOI; 656 if tempAltIEN > 0 then txtMed.Tag := tempAltIEN; 657 end; *) 612 658 SetOnMedSelect; // set up for this medication 613 659 SetOnQuickOrder; // insert quick order responses … … 638 684 end; 639 685 end; //nss 686 //if (FInptDlg) and (self.tabDose.TabIndex = TI_DOSE) and (OrderAction in [ORDER_COPY, ORDER_EDIT]) then 687 if (FInptDlg) and (OrderAction in [ORDER_COPY, ORDER_EDIT]) then 688 begin 689 TempOrder := Piece(id,';',1); 690 TempOrder := Copy(tempOrder, 2, Length(tempOrder)); 691 LocChange := DifferentOrderLocations(tempOrder, Patient.Location); 692 if LocChange = false then 693 begin 694 AResponse := Responses.FindResponseByName('ADMIN', 1); 695 if AResponse <> nil then AdminTime := AResponse.EValue; 696 if self.cboSchedule.ItemIndex > -1 then 697 begin 698 tempSchString := self.cboSchedule.Items.Strings[cboSchedule.itemindex]; 699 SetPiece(tempSchString,U,4,AdminTime); 700 self.cboSchedule.Items.strings[cboSchedule.ItemIndex] := tempSchString; 701 end; 702 if self.tabDose.TabIndex = TI_COMPLEX then 703 begin 704 if self.cboXSchedule.ItemIndex > -1 then 705 begin 706 tempSchString := self.cboXSchedule.Items.Strings[cboXSchedule.itemindex]; 707 SetPiece(tempSchString,U,4,AdminTime); 708 self.cboXSchedule.Items.strings[cboXSchedule.ItemIndex] := tempSchString; 709 end; 710 end; 711 AResponse := Responses.FindResponseByName('SCHTYPE', 1); 712 if AResponse <> nil then tempSchType := AResponse.EValue; 713 if self.cboSchedule.ItemIndex > -1 then 714 begin 715 if (Piece(self.cboSchedule.Items.Strings[self.cboSchedule.itemIndex], U, 3) = 'C') and (tempSchType = 'P') then 716 self.chkPRN.Checked := True 717 else 718 begin 719 tempSchString := self.cboSchedule.Items.Strings[cboSchedule.itemindex]; 720 SetPiece(tempSchString,U,3,tempSchType); 721 self.cboSchedule.Items.strings[cboSchedule.ItemIndex] := tempSchString; 722 end; 723 end; 724 if self.tabDose.TabIndex = TI_COMPLEX then 725 begin 726 if self.cboXSchedule.ItemIndex > -1 then 727 begin 728 if (Piece(self.cboXSchedule.Items.Strings[self.cboXSchedule.itemIndex], U, 3) = 'C') and (tempSchType = 'P') then 729 self.chkXPRN.Checked := True 730 else 731 begin 732 tempSchString := self.cboXSchedule.Items.Strings[cboXSchedule.itemindex]; 733 SetPiece(tempSchString,U,3,tempSchType); 734 self.cboXSchedule.Items.strings[cboXSchedule.ItemIndex] := tempSchString; 735 end; 736 end; 737 end; 738 end; 739 if (FAdminTimeText <> 'Not defined for Clinic Locations') and (self.tabDose.TabIndex = TI_COMPLEX) then 740 lblAdminSchSetText(''); 741 if (FAdminTimeText <> '') and (self.tabDose.TabIndex = TI_DOSE) then lblAdminSchSetText('Admin. Time: ' + FAdminTimeText); 742 end; 640 743 if ((OrderAction <> Order_COPY) and (OrderAction <> Order_EDIT)) or 641 (XfInToOutNow = true) then UpdateRelated(FALSE); //AGP Change744 (XfInToOutNow = true) or (FIsQuickOrder) then UpdateRelated(FALSE); //AGP Change 642 745 Changing := False; 746 if ((OrderAction = Order_Copy) or (OrderAction = Order_Edit)) and 747 (self.cboSchedule.ItemIndex > -1) then 748 UpdateStartExpires(Piece(self.cboSchedule.items.strings[self.cboSchedule.itemindex], U, 1)); 643 749 end; 644 750 { prevent the SIG from being part of the comments on pre-CPRS prescriptions } … … 663 769 procedure TfrmODMeds.Validate(var AnErrMsg: string); 664 770 var 665 i,ie,code: Integer; 771 i,ie,code, curSupply, tempRefills: Integer; 772 curDispDrug, tmpError, temp, x: string; 666 773 667 774 procedure SetError(const x: string); … … 736 843 if txtMed.Tag = 0 then SetError(TX_NO_MED); 737 844 if Responses.InstanceCount('INSTR') < 1 then SetError(TX_NO_DOSE); 845 if Pos(U, self.memComment.Text) > 0 then SetError('Comments cannot contain a "^".'); 738 846 i := Responses.NextInstance('INSTR', 0); 739 847 while i > 0 do … … 757 865 i := Responses.NextInstance('INSTR', i); 758 866 end; 867 if self.tabDose.TabIndex = TI_DOSE then 868 begin 869 if (LeftStr(cboDosage.Text,1)='.') then 870 begin 871 SetError('Dosage must have a leading numeric value'); 872 Exit; 873 end; 874 end; 759 875 //AGP Change 26.45 Fix for then/and conjucntion PSI-04-069 760 if self.tabDose.TabIndex = 1then761 begin 762 for i := 2to self.grdDoses.RowCount do876 if self.tabDose.TabIndex = TI_COMPLEX then 877 begin 878 for i := 1 to self.grdDoses.RowCount do 763 879 begin 764 if ((ValFor(COL_DOSAGE, i-1) <> '') and (ValFor(COL_DOSAGE, i) <> '')) and (ValFor(COL_SEQUENCE,i-1) = '') then 880 temp := ValFor(COL_DOSAGE, i); 881 if (LeftStr(temp,1) = '.') then 765 882 begin 766 SetError(TX_NO_SEQ);767 Exit;883 SetError('All dosage must have a leading numeric value'); 884 Exit; 768 885 end; 886 if (i > 1) and ((ValFor(COL_DOSAGE, i-1) <> '') and (ValFor(COL_DOSAGE, i) <> '')) and (ValFor(COL_SEQUENCE,i-1) = '') then 887 begin 888 SetError(TX_NO_SEQ); 889 Exit; 890 end; 769 891 end; 770 892 end; … … 772 894 begin 773 895 if Responses.IValueFor('PICKUP', 1) = '' then SetError(TX_NO_PICK); 774 if StrToIntDef(Responses.IValueFor('REFILLS', 1), 99) > spnRefills.Max 896 temp := Responses.IValueFor('REFILLS', 1); 897 for i := 1 to Length(temp) do if not (temp[i] in ['0'..'9']) then 898 begin 899 SetError('Refills can only be a number'); 900 Exit; 901 end; 902 tempRefills := StrToIntDef(temp, 0); 903 if (spnRefills.Max > 0) and (tempRefills > 0) then 904 begin 905 i := Responses.NextInstance('DOSE', 0); 906 while i > 0 do 907 begin 908 x := ValueOfResponse(FLD_DRUG_ID, i); 909 CurDispDrug := CurDispDrug + x + U; 910 i := Responses.NextInstance('DOSE', i); 911 end; 912 CurSupply := StrToIntDef(ValueOfResponse(FLD_SUPPLY) ,0); 913 UpdateRefills(CurDispDrug, CurSupply); 914 end; 915 if tempRefills > spnRefills.Max 775 916 then SetError(TX_RNG_REFILL + IntToStr(spnRefills.Max)); 776 917 with txtQuantity do 777 if not ValidQuantity(Responses.IValueFor('QTY', 1)) then SetError(TX_QTY_NV); 918 begin 919 if not ValidQuantity(Responses.IValueFor('QTY', 1)) then 920 SetError(TX_QTY_NV); 921 (* else 922 begin 923 Quantity := ValidateQuantityErrorMsg(StrtoIntDef(Responses.IValueFor('QTY', 1), 0)); 924 if Quantity <> '' then SetError(Quantity); 925 end; *) 926 end; 778 927 with txtSupply do 779 928 begin … … 787 936 if (StrToIntDef(Responses.IValueFor('SUPPLY', 1), 0) > 90) then SetError(TX_SUPPLY_LIM); 788 937 if (StrToIntDef(Responses.IValueFor('SUPPLY', 1), 0) < 1) then SetError(TX_SUPPLY_LIM1); 789 end; 938 //Supply := ValidateDaySupplyandQuantityErrorMsg(strtoInt(Responses.IValueFor('SUPPLY',1))); 939 //if Supply <> '' then SetError(Supply); 940 end; 941 tmpError := ValidateDaySupplyandQuantityErrorMsg(strtoInt(Responses.IValueFor('SUPPLY',1)),StrtoIntDef(Responses.IValueFor('QTY', 1), 0)); 942 if tmpError <> '' then SetError(tmpError) 943 else ClearMaxData; 790 944 end; 791 945 end; … … 815 969 lblPriority.Visible := True; 816 970 cboPriority.Visible := True; 817 chkSC.Visible := False;818 971 chkDoseNow.Visible := True; 819 972 lblAdminTime.Visible := True; 973 lblAdminSch.Visible := True; 974 lblAdminSch.Hint := AdminTimeHelpText; 975 if cboXSequence.Items.IndexOf('except') > -1 then cboXSequence.Items.Delete(cboXSequence.Items.IndexOf('except')); 820 976 end; 821 977 822 978 procedure TfrmODMeds.SetControlsOutpatient; 823 var824 ExceptItem: TMenuItem;825 979 begin 826 980 FillerID := 'PSO'; … … 833 987 lblQuantity.Visible := True; 834 988 txtQuantity.Visible := True; 989 //if IsClozapineOrder = True then txtQuantity.Enabled := false; 835 990 spnQuantity.Visible := True; 836 991 lblQtyMsg.Visible := True; … … 841 996 lblPriority.Visible := True; 842 997 cboPriority.Visible := True; 843 chkSC.Visible := True;844 998 chkDoseNow.Visible := False; 845 999 lblAdminTime.Visible := False; 846 ExceptItem := TMenuItem.Create(Self); 847 ExceptItem.Caption := 'except'; 848 ExceptItem.Tag := 3; 849 ExceptItem.OnClick := popXSequenceClick; 850 popXSequence.Items.Add(ExceptItem); 1000 lblAdminSch.Visible := False; 1001 if cboXSequence.Items.IndexOf('except') = -1 then cboXSequence.Items.Add('except'); 1002 851 1003 end; 852 1004 … … 906 1058 x: string; 907 1059 begin 908 if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then // navigation 1060 if txtMed.ReadOnly then // v27.50 - RV - CQ #15365 1061 begin 1062 if not (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_HOME, VK_END]) then // navigation 1063 begin 1064 Key := 0; 1065 Exit; 1066 end; 1067 end 1068 else if (Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN]) then // navigation 909 1069 begin 910 1070 FActiveMedList.Perform(WM_KEYDOWN, Key, 0); … … 931 1091 Shift: TShiftState); 932 1092 begin 933 if not (Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN]) then StartKeyTimer; 934 end; 1093 if txtMed.ReadOnly then exit; // v27.50 - RV - CQ #15365 1094 if not (Key in [VK_PRIOR, VK_NEXT, VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_HOME, VK_END]) then StartKeyTimer; 1095 end; 1096 935 1097 936 1098 procedure TfrmODMeds.txtMedChange(Sender: TObject); … … 968 1130 UserText := Copy(txtMed.Text, 1, txtMed.SelStart); 969 1131 QuickIndex := FindQuickOrder(UserText); // look in quick list first 970 AllIndex := IndexOfOrderable(F AllList, UserText); // but always synch the full list1132 AllIndex := IndexOfOrderable(FCacheIEN, UserText); // but always synch the full list 971 1133 if UserText <> Copy(txtMed.Text, 1, txtMed.SelStart) then Exit; // if typing during lookup 972 1134 if AllIndex > -1 then … … 1044 1206 begin 1045 1207 StopKeyTimer; 1208 if txtMed.ReadOnly then exit; // v27.50 - RV - CQ #15365 1046 1209 if not ((ActiveControl = lstAll) or (ActiveControl = lstQuick)) then ChangeDelayed; 1047 1210 end; … … 1112 1275 { lstAll Methods (lstAll is TListView) } 1113 1276 1277 procedure TfrmODMeds.Loaded; 1278 begin 1279 inherited; 1280 if ScreenReaderSystemActive then 1281 tabDose.TabStop := TRUE; 1282 end; 1283 1284 // Cache is a list of 100 string lists, starting at idx 0 1114 1285 procedure TfrmODMeds.LoadMedCache(First, Last: Integer); 1115 const 1116 MAX_CACHE_ITEMS = 1000; 1117 begin 1118 // if range is within cache range we don't need to update anything 1119 if (First >= FAllFirst) and (Last <= FAllLast) then Exit; 1120 // if range is outside of cache or a superset of cache, start over 1121 if (Last < Pred(FAllFirst)) or (First > Succ(FAllLast)) or 1122 ((First < FAllFirst) and (Last > FAllLast)) or 1123 (FAllItems.Count > MAX_CACHE_ITEMS) then 1124 begin 1125 FAllItems.Clear; 1126 FAllFirst := -1; 1127 FAllLast := -1; 1128 end; 1129 // if getting items immediately before cache range 1130 if (First < FAllFirst) and (Last >= FAllFirst) then Last := Pred(FAllFirst); 1131 // if getting items immediately after cache range 1132 if (Last > FAllLast) and (First <= FAllLast) then First := Succ(FAllLast); 1133 // retrieve the items and append (First>FAllLast) or prepend them to FAllItems 1134 SubsetOfOrderable(FAllItems, First>FAllLast, FAllList, First, Last); 1135 // reset FAllFirst & FAllLast indexes to reflect current FAllItems 1136 if FAllFirst < 0 then FAllFirst := First; 1137 if FAllLast < 0 then FAllLast := Last; 1138 if First < FAllFirst then FAllFirst := First; 1139 if Last > FAllLast then FAllLast := Last; 1286 var 1287 firstChunk, lastchunk, i: integer; 1288 list: TStringList; 1289 firstMed, LastMed: integer; 1290 1291 begin 1292 firstChunk := GetCacheChunkIndex(First); 1293 lastChunk := GetCacheChunkIndex(Last); 1294 for i := firstChunk to lastChunk do 1295 begin 1296 if (FMedCache.Count <= i) or (not assigned(FMedCache[i])) then 1297 begin 1298 while FMedCache.Count <= i do 1299 FMedCache.add(nil); 1300 list := TStringList.Create; 1301 FMedCache[i] := list; 1302 firstMed := i * MED_CACHE_CHUNK_SIZE; 1303 LastMed := firstMed + MED_CACHE_CHUNK_SIZE - 1; 1304 if LastMed >= lstAll.Items.Count then 1305 LastMed := lstAll.Items.Count - 1; 1306 SubsetOfOrderable(list, false, FCacheIEN, firstMed, lastMed); 1307 end; 1308 end; 1140 1309 end; 1141 1310 … … 1143 1312 var 1144 1313 x: string; 1145 begin 1146 if (FAllFirst = -1) or (Item.Index < FAllFirst) or (Item.Index > FAllLast) 1147 then LoadMedCache(Item.Index, Item.Index); 1148 x := FAllItems[Item.Index - FAllFirst]; 1314 chunk: integer; 1315 list: TStringList; 1316 begin 1317 LoadMedCache(Item.Index, Item.Index); 1318 chunk := GetCacheChunkIndex(Item.Index); 1319 list := TStringList(FMedCache[chunk]); 1320 x := list[Item.Index mod MED_CACHE_CHUNK_SIZE]; 1149 1321 Item.Caption := Piece(x, U, 2); 1150 1322 Item.Data := Pointer(StrToIntDef(Piece(x, U, 1), 0)); … … 1185 1357 var 1186 1358 MedIEN: Integer; 1187 MedName: string;1359 //MedName: string; 1188 1360 QOQuantityStr: string; 1189 ErrMsg : string;1361 ErrMsg, Temp: string; 1190 1362 begin 1191 1363 inherited; 1192 1364 QOQuantityStr := ''; 1193 1365 btnSelect.SetFocus; // let the exit events finish 1194 1366 self.MedName := ''; 1195 1367 if pnlMeds.Visible then // display the medication fields 1196 1368 begin … … 1204 1376 Responses.QuickOrder := Integer(lstQuick.Selected.Data); 1205 1377 txtMed.Tag := StrToIntDef(Responses.IValueFor('ORDERABLE', 1), 0); 1378 if (not FInptDLG) and (PassDrugTest(TXTmED.Tag, 'N', false) = false) then exit; 1379 if (FInptDLG) and (PassDrugTest(TXTmED.Tag, 'N', true) = false) then exit; 1206 1380 IsActivateOI(ErrMsg, txtMed.Tag); 1207 1381 if Length(ErrMsg)>0 then … … 1209 1383 //btnSelect.Visible := False; 1210 1384 btnSelect.Enabled := False; 1211 ShowM essage(ErrMsg);1385 ShowMsg(ErrMsg); 1212 1386 Exit; 1213 1387 end; … … 1228 1402 Exit; 1229 1403 end; 1404 (* temp := self.MedName; 1405 tempIEN := txtMed.Tag; 1406 QOIEN := GetQOOrderableItem(InttoStr(Responses.QuickOrder)); 1407 if QOIEN > 0 then 1408 begin 1409 CheckFormularyOI(tempIEN, temp, FInptDlg); 1410 if tempIEN <> txtMed.Tag then 1411 begin 1412 txtMed.Tag := tempIEN; 1413 txtMed.Text := temp; 1414 end; 1415 end; *) 1416 FAltChecked := True; 1417 ; 1230 1418 SetOnMedSelect; // set up for this medication 1231 1419 SetOnQuickOrder; // insert quick order responses … … 1233 1421 QOQuantityStr := txtQuantity.Text; 1234 1422 ShowMedFields; 1423 if self.tabDose.TabIndex = TI_COMPLEX then self.lblAdminSch.Visible := false; 1235 1424 if (txtQuantity.Text = '0') and (Length(QOQuantityStr)>0) then 1236 1425 txtQuantity.Text := QOQuantityStr; … … 1239 1428 begin 1240 1429 MedIEN := Integer(lstAll.Selected.Data); 1241 MedName := lstAll.Selected.Caption; 1430 self.MedName := lstAll.Selected.Caption; 1431 if (not FInptDLG) and (PassDrugTest(MedIEN, 'N', false) = false) then exit; 1432 if (FInptDLG) and (PassDrugTest(MedIEN, 'N', true) = false) then exit; 1242 1433 txtMed.Tag := MedIEN; 1243 1434 ErrMsg := ''; … … 1247 1438 //btnSelect.Visible := False; 1248 1439 btnSelect.Enabled := False; 1249 ShowM essage(ErrMsg);1440 ShowMsg(ErrMsg); 1250 1441 Exit; 1251 1442 end; … … 1259 1450 Exit; 1260 1451 end; 1261 if Pos(' NF', MedName) > 0 then 1262 begin 1263 CheckFormularyOI(MedIEN, MedName, FInptDlg); 1452 if Pos(' NF', self.MedName) > 0 then 1453 begin 1454 temp := self.MedName; 1455 CheckFormularyOI(MedIEN, temp, FInptDlg); 1264 1456 FAltChecked := True; 1265 1457 end; … … 1267 1459 begin 1268 1460 txtMed.Tag := MedIEN; 1269 txtMed.Text := MedName; 1461 temp := self.MedName; 1462 self.MedName := txtMed.Text; 1463 txtMed.Text := Temp; 1270 1464 end; 1271 1465 SetOnMedSelect; … … 1352 1546 cboSchedule.ItemIndex := -1; 1353 1547 cboSchedule.Text := ''; // leave items intact 1548 if FAdminTimeText <> 'Not defined for Clinic Locations' then lblAdminSchSetText(''); 1354 1549 txtSupply.Text := ''; 1355 1550 txtSupply.Tag := 0; … … 1371 1566 var 1372 1567 i,j: Integer; 1373 x: string;1568 temp,x: string; 1374 1569 QOPiUnChk: boolean; 1375 1570 PKIEnviron: boolean; 1571 AResponse: TResponse; 1376 1572 begin 1377 1573 // clear controls? … … 1380 1576 txtQuantity.Tag := 0; 1381 1577 spnQuantity.Tag := 0; 1382 chkSC.Tag := 0; 1383 QOPiUnChk := False; 1578 QOPiUnChk := False; 1384 1579 PKIEnviron := False; 1385 1580 if GetPKISite then PKIEnviron := True; … … 1390 1585 // set up lists & initial values based on orderable item 1391 1586 SetControl(txtMed, 'Medication'); 1587 if (self.MedName <> '') then 1588 begin 1589 if (txtMed.Text <> self.MedName) then 1590 begin 1591 temp := self.MedName; 1592 self.MedName := txtMed.Text; 1593 txtMed.Text := temp; 1594 end 1595 else MedName := ''; 1596 end; 1392 1597 SetControl(cboDosage, 'Dosage'); 1393 1598 SetControl(cboRoute, 'Route'); … … 1395 1600 cboRouteChange(Self); 1396 1601 x := DefaultText('Schedule'); 1397 if x <> '' then 1602 //AGP Change 27.72 trying to centralized the schedule setting code 1603 AResponse := Responses.FindResponseByName('SCHEDULE',1); 1604 if (AResponse <> nil) and (AResponse.EValue <> '') then x := AResponse.EValue; 1605 SetSchedule(x); 1606 (* if x <> '' then 1398 1607 begin 1399 1608 cboSchedule.SelectByID(x); 1609 if cboSchedule.ItemIndex > -1 then 1610 AdminTime := Piece(cboSchedule.Items.Strings[cboSchedule.itemindex],U,4); 1611 if (cboSchedule.ItemIndex < 0) and (RightStr(x,3) = 'PRN') then 1612 begin 1613 self.chkPRN.Checked := true; 1614 x := Copy(x,1,(Length(x)-3)); 1615 if RightStr(X,1) = ' ' then x := Copy(x,1,(Length(x)-1)) 1616 end; 1400 1617 cboSchedule.Text := x; 1401 end; 1618 end; *) 1402 1619 if Length(ValueOf(FLD_QTYDISP))>10 then 1403 1620 begin … … 1431 1648 lblPriority.Top := memcomment.Top + memComment.Height + 1; 1432 1649 cboPriority.Top := lblPriority.Top + lblPriority.Height; 1433 lblAdminTime.Left := chkDoseNow.Left; 1434 lblAdminTime.Top := chkDoseNow.Top + chkDoseNow.Height - 1; 1650 lblAdminSch.Left := chkDoseNow.Left; 1651 lblAdminSch.Top := chkDoseNow.Top + chkDoseNow.Height - 1; 1652 lblAdminSch.Height := (MainFontHeight * 3) + 3; 1653 lblAdminSch.Width := cboPriority.Left - lblAdminSch.Left - 5; 1654 lblAdminTime.Left := lblAdminSch.Left; 1655 lblAdminTime.top := lblAdminSch.Top + lblAdminSch.Height -1; 1656 if self.tabDose.TabIndex = TI_Dose then lblAdminSchSetText('') 1657 else 1658 begin 1659 if FAdminTimeText = 'Not defined for Clinic Locations' then lblAdminSchSetText('Admin. Time: ' + FAdminTimeText) 1660 else self.lblAdminSch.Visible := False; 1661 end; 1435 1662 end else 1436 1663 begin … … 1448 1675 end; 1449 1676 //if Length(FPtInstruct) = 0 then 1450 FPtInstruct := TextOf('PtInstr');1677 if FPtInstruct = '' then FPtInstruct := TextOf('PtInstr'); 1451 1678 for i := 1 to Length(FPtInstruct) do if Ord(FPtInstruct[i]) < 32 then FPtInstruct[i] := ' '; 1452 1679 FPtInstruct := TrimRight(FPtInstruct); … … 1512 1739 if FIsQuickOrder then TempSch := cboSchedule.Text; 1513 1740 SetSchedule(IValueFor('SCHEDULE', i)); 1514 if (cboSchedule.Text = '') and FIsQuickOrderthen1741 if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = False) then 1515 1742 begin 1516 1743 cboSchedule.SelectByID(TempSch); 1517 1744 cboSchedule.Text := TempSch; 1518 1745 end; 1746 if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = True) then cboSchedule.ItemIndex := -1; 1519 1747 x := cboSchedule.Text; 1520 1748 if chkPRN.Checked then x := x + ' PRN'; … … 1524 1752 if chkPRN.Checked = True then grdDoses.Cells[COL_CHKXPRN,i] := '1'; 1525 1753 grdDoses.Cells[COL_DURATION, i] := IValueFor('DAYS', i); 1754 if FInptDlg then 1755 begin 1756 if IValueFor('ADMIN', i) <> '' then grdDoses.Cells[COL_ADMINTIME, i] := IValueFor('ADMIN', i) 1757 else if cboSchedule.ItemIndex > -1 then 1758 grdDoses.Cells[COL_ADMINTIME, i] := Piece(cboSchedule.Items.Strings[cboSchedule.itemIndex],U,4) 1759 else grdDoses.Cells[COL_ADMINTIME, i] := ''; 1760 if grdDoses.Cells[COL_ADMINTIME, i] = '' then grdDoses.Cells[COL_ADMINTIME, i] := 'Not Defined'; 1761 if FAdminTimeText <> '' then grdDoses.Cells[COL_ADMINTIME, i] := FAdminTimeText; 1762 end; 1526 1763 if IValueFor('CONJ', i) = 'A' then x := 'AND' 1527 1764 else if IValueFor('CONJ', i) = 'T' then x := 'THEN' … … 1543 1780 SetControl(cboRoute, 'ROUTE', 1); 1544 1781 SetSchedule(IValueFor('SCHEDULE', 1)); 1545 if (cboSchedule.Text = '') and FIsQuickOrderthen1782 if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = False) then 1546 1783 begin 1547 1784 cboSchedule.SelectByID(TempSch); 1548 1785 cboSchedule.Text := TempSch; 1549 1786 end; 1787 if (cboSchedule.Text = '') and (FIsQuickOrder) and (NSSchedule = True) then cboSchedule.ItemIndex := -1; 1550 1788 if ((cboSchedule.Text = 'OTHER') and FIsQuickOrder) then 1551 1789 FNSSOther := True; … … 1588 1826 AResponse := Responses.FindResponseByName('PICKUP', 1); 1589 1827 if AResponse <> nil then SetPickup(AResponse.IValue); 1590 if FIsQuickOrderthen1828 if (FIsQuickOrder) and (FOrderAction = ORDER_QUICK) then 1591 1829 begin 1592 1830 if not QOHasRouteDefined(Responses.QuickOrder) then … … 1603 1841 end; 1604 1842 if ValueOf(FLD_PICKUP) = '' then SetPickup(FLastPickup); 1605 AResponse := Responses.FindResponseByName('SC', 1);1606 if AResponse <> nil then chkSC.Checked := AResponse.IValue = '1';1843 // AResponse := Responses.FindResponseByName('SC', 1); 1844 Responses.FindResponseByName('SC', 1); 1607 1845 end; {if FInptDlg..else} 1608 1846 end; {with} 1609 1847 if FInptDlg then 1610 1848 begin 1611 1849 x := ValueOfResponse(FLD_SCHEDULE, 1); … … 1704 1942 lblSchedule.Visible := True; 1705 1943 cboSchedule.Visible := True; 1944 if FInptDlg = True then lblAdminSch.Visible := True 1945 else lblAdminSch.Visible := false; 1706 1946 chkPRN.Visible := True; 1707 1947 ActiveControl := cboDosage; … … 1718 1958 begin 1719 1959 DestCombo.Items.Clear; 1720 DestCombo.Items.Assign(SrcCombo.Items);1960 FastAssign(SrcCombo.Items, DestCombo.Items); 1721 1961 DestCombo.ItemIndex := SrcCombo.ItemIndex; 1722 1962 DestCombo.Text := Piece(SrcCombo.Text, TAB, 1); … … 1739 1979 else cnt := cnt+1; 1740 1980 end; 1981 if (index = -1) and (Text <> '') then 1982 begin 1983 for I := 0 to DestCombo.Items.Count - 1 do 1984 if Piece(DestCombo.Items.Strings[i],U,1) = Text then 1985 begin 1986 DestCombo.ItemIndex := i; 1987 DestCombo.Text := Text; 1988 Exit; 1989 end; 1990 end; 1741 1991 end; 1742 1992 end; … … 1815 2065 procedure TfrmODMeds.SetSchedule(const x: string); 1816 2066 var 1817 NonPRNPart: string; 1818 begin 1819 cboSchedule.ItemIndex := -1; 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 1823 begin 1824 NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1)); 1825 cboSchedule.SelectByID(NonPRNPart); 1826 if cboSchedule.ItemIndex < 0 then 1827 begin 1828 if NSSchedule then 1829 begin 1830 chkPRN.Checked := False; 1831 cboSchedule.Text := ''; 1832 end else 1833 begin 1834 chkPRN.Checked := True; 1835 cboSchedule.Items.Add(NonPRNPart); 1836 cboSchedule.Text := NonPRNPart; 2067 NonPRNPart,tempSch, tempText: string; 2068 begin 2069 //AGP Change 27.72 if schedule matches why goes through and reprocess the same info? 2070 if cboSchedule.ItemIndex > -1 then 2071 begin 2072 tempText := Piece(cboSchedule.Items.Strings[cboSchedule.itemindex], U, 1); 2073 if tempText = x then exit; 2074 if (Pos('PRN',x)>0) and (chkPRN.Checked = true) then 2075 begin 2076 NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1)); 2077 if nonPRNPart = tempText then exit; 2078 end; 1837 2079 end; 1838 end else 1839 chkPRN.Checked := True; 1840 end else 1841 begin *) 1842 chkPRN.Checked := False; 2080 cboSchedule.ItemIndex := -1; 2081 if chkPRN.Checked = True then chkPRN.Checked := False; 1843 2082 cboSchedule.SelectByID(x); 1844 if cboSchedule.ItemIndex < 0 then 1845 begin 1846 if NSSchedule then 1847 begin 1848 cboSchedule.Text := ''; 2083 if cboSchedule.ItemIndex > -1 then exit; 2084 // if cboSchedule.ItemIndex < 0 then 2085 //begin 2086 //if NSSchedule then 2087 //begin 2088 // cboSchedule.Text := ''; 2089 //end 2090 if FInptDlg then 2091 begin 2092 if (Pos('@', x) > 0) then 2093 begin 2094 tempSch := Piece(x, '@', 2); 2095 cboSchedule.SelectByID(tempSch); 2096 if cboSchedule.ItemIndex > -1 then 2097 begin 2098 tempSch := Piece(x, '@', 1) + '@' + cboSchedule.Items.Strings[cboSchedule.itemindex]; 2099 cboSchedule.Items.Add(tempSch); 2100 cboSchedule.Text := (Piece(tempSch,U,1)); 2101 cboSchedule.SelectByID(Piece(tempSch,u,1)); 2102 EXIT; 2103 end; 2104 if Pos('PRN', tempSch) > 0 then 2105 begin 2106 NonPRNPart := Trim(Copy(tempSch, 1, Pos('PRN', tempSch) - 1)); 2107 cboSchedule.SelectByID(NonPRNPart); 2108 if cboSchedule.ItemIndex > -1 then 2109 begin 2110 tempSch := Piece(x, '@', 1) + '@' + cboSchedule.Items.Strings[cboSchedule.itemindex]; 2111 cboSchedule.Items.Add(tempSch); 2112 cboSchedule.Text := (Piece(tempSch,U,1)); 2113 cboSchedule.SelectByID(Piece(tempSch,u,1)); 2114 chkPRN.Checked := True; 2115 EXIT; 2116 end 2117 else 2118 begin 2119 NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1)); 2120 chkPRN.Checked := true; 2121 tempSch := NonPRNPart + U + U + U + Piece(NonPRNPart, '@', 2); 2122 cboSchedule.Items.Add(tempSch); 2123 cboSchedule.SelectByID(Piece(tempSch, U, 1)); 2124 EXIT; 2125 end; 2126 end; 2127 cboSchedule.Items.Add(X + U + U + U + Piece(x, '@', 2)); 2128 cboSchedule.Text := x; 2129 cboSchedule.SelectByID(x); 2130 EXIT; 2131 end 2132 else if Pos('PRN', x) > 0 then 2133 begin 2134 NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1)); 2135 chkPRN.Checked := True; 2136 cboSchedule.SelectByID(NonPRNPart); 2137 if cboSchedule.ItemIndex > -1 then EXIT; 2138 end; 1849 2139 end 1850 else 1851 begin 1852 if Pos('PRN', x) > 0 then 2140 else if Pos('PRN', x) > 0 then 1853 2141 begin 1854 2142 NonPRNPart := Trim(Copy(x, 1, Pos('PRN', x) - 1)); … … 1861 2149 EXIT; 1862 2150 end; 1863 cboSchedule.Items.Add(x); 1864 cboSchedule.Text := x; 1865 cboSchedule.SelectByID(x); 1866 end; 1867 end; 2151 cboSchedule.Items.Add(x); 2152 cboSchedule.Text := x; 2153 cboSchedule.SelectByID(x); 1868 2154 end; 1869 2155 … … 1872 2158 var 1873 2159 //text,x, tmpsch: string; 1874 text, x: string;2160 text, tmpAdmin, x: string; 1875 2161 reset: integer; 1876 2162 begin … … 1896 2182 TI_DOSE: begin 1897 2183 cboXSchedule.Clear; // Added to Fix CQ: 9603 2184 cboXDosage.Clear; 1898 2185 // clean up responses? 1899 2186 FSuppressMsg := FOrigiMsgDisp; … … 1912 2199 FSuppressMsg := FOrigiMsgDisp; 1913 2200 if reset = 1 then exit; 2201 (* AGP Change admin wrap 27.73 2202 tmpAdmin := Piece(self.lblAdminSch.text, ':', 2); 2203 tmpAdmin := Copy(tmpAdmin,2,Length(tmpAdmin)); *) 2204 tmpAdmin := lblAdminSchGetText; 2205 if FAdminTimeText <> '' then 2206 begin 2207 tmpAdmin := FAdminTimeText; 2208 if FAdminTimeText <> 'Not defined for Clinic Locations' then self.lblAdminSch.Visible := False; 2209 end; 1914 2210 ShowControlsComplex; 1915 2211 ResetOnTabChange; … … 1917 2213 txtNss.Visible := False; 1918 2214 x := cboXDosage.Text + TAB; 2215 if LeftStr(x,1) = '.' then x := ''; 1919 2216 with cboXDosage do if ItemIndex > -1 then x := x + Items[ItemIndex]; 1920 2217 grdDoses.Cells[COL_DOSAGE, 1] := x; … … 1925 2222 with cboXSchedule do if ItemIndex > -1 then x := x + Items[ItemIndex]; 1926 2223 grdDoses.Cells[COL_SCHEDULE, 1] := x; 1927 UpdateStartExpires(ValFor(VAL_SCHEDULE,1)); 2224 //AGP Change 27.1 handle PRN not showing in schedule panel if a dose is not selected. 2225 if FSmplPRNChkd then 2226 begin 2227 pnlXSchedule.Tag := 1; 2228 self.chkXPRN.Checked := True; 2229 end; 2230 if FInptDLG then UpdateStartExpires(ValFor(VAL_SCHEDULE,1)); 1928 2231 ControlChange(Self); 1929 2232 end; {TI_COMPLEX} 1930 2233 end; {case} 1931 end; 1932 2234 if ScreenReaderSystemActive then 2235 GetScreenReader.Speak(tabDose.Tabs[tabDose.TabIndex] + ' tab'); 2236 end; 2237 2238 2239 function TfrmODMeds.lblAdminSchGetText: string; 2240 var 2241 tempstr: string; 2242 i: integer; 2243 begin 2244 result := ''; 2245 if self.lblAdminSch.Text = '' then exit; 2246 tempstr := ''; 2247 if self.lblAdminSch.Lines.Count > 1 then 2248 begin 2249 for i := 0 to self.lblAdminSch.Lines.Count - 1 do 2250 tempstr := tempStr + self.lblAdminSch.Lines.Strings[i]; 2251 end 2252 else if self.lblAdminSch.Lines.Count = 1 then 2253 begin 2254 tempstr := self.lblAdminSch.Text; 2255 end; 2256 Result := Piece(tempStr,':',2); 2257 Result := Copy(Result,2,Length(Result)); 2258 end; 2259 2260 procedure TfrmODMeds.lblAdminSchSetText(str: string); 2261 var 2262 cutoff: integer; 2263 begin 2264 cutoff := lblAdminSch.width div MainFontWidth; 2265 if Length(str) > cutoff then self.lblAdminSch.Text := Copy(str, 1, cutoff) + CRLF + 2266 Copy(str, cutoff + 1, Length(str)) 2267 else self.lblAdminSch.Text := str; 2268 end; 1933 2269 1934 2270 procedure TfrmODMeds.lblGuidelineClick(Sender: TObject); … … 2010 2346 2011 2347 procedure TfrmODMeds.cboDosageChange(Sender: TObject); 2012 begin 2013 inherited; 2348 var 2349 temp1,temp2: string; 2350 Count: integer; 2351 begin 2352 inherited; 2353 Count := Pos(U,cboDosage.Text); 2354 if Count > 0 then 2355 begin 2356 temp1 := copy(cboDosage.Text,0,count-1); 2357 temp2 := copy(cboDosage.Text,count+1,Length(cboDosage.text)); 2358 infoBox('An ^ is not allowed in the dosage value', 'Dosage Warning', MB_OK); 2359 cboDosage.Text := temp1 + temp2; 2360 end; 2014 2361 UpdateRelated; 2015 2362 end; 2016 2363 2017 2364 procedure TfrmODMeds.cboDosageExit(Sender: TObject); 2018 begin 2019 inherited; 2365 var 2366 str: string; 2367 begin 2368 inherited; 2369 str := cboDosage.Text; 2020 2370 if (length(cboDosage.Text)<1) then 2021 cboDosage.ItemIndex := -1; 2371 cboDosage.ItemIndex := -1; 2372 (* Probably not needed here since this on validation check on accept 2373 if (LeftStr(cboDosage.Text,1)='.') then 2374 begin 2375 infoBox('Dosage must have a leading numeric value','Invalid Dosage',MB_OK); 2376 if self.tabDose.TabIndex = TI_DOSE then cboDosage.SetFocus; 2377 Exit; 2378 end; *) 2379 if (length(cbodosage.Text)>0) and (cboDosage.ItemIndex > -1) and 2380 (Piece(cboDosage.Items.Strings[cboDosage.ItemIndex],U,5) <> Piece(cboDosage.Text,tab,1)) then 2381 begin 2382 cboDosage.ItemIndex := -1; 2383 cboDosage.Text := Piece(str, tab, 1); 2384 UpdateRelated(false); 2385 end; 2022 2386 if ActiveControl = memMessage then 2023 2387 begin … … 2082 2446 if length(trim(othSch)) > 1 then 2083 2447 begin 2448 othSch := othSch + U + U + NSSScheduleType + U + NSSAdminTime; 2449 cboSchedule.Items.Add(othSch); 2450 idx := cboSchedule.Items.IndexOf(Piece(OthSch, U, 1)); 2451 cboSchedule.ItemIndex := idx; 2452 end; 2453 end 2454 else 2455 begin 2456 NSSAdminTime := ''; 2457 FNSSScheduleType := ''; 2458 end; 2459 UpdateRelated(False); 2460 end; 2461 2462 2463 procedure TfrmODMeds.cboScheduleChange(Sender: TObject); 2464 var 2465 othSch: string; 2466 idx : integer; 2467 begin 2468 inherited; 2469 if (FInptDlg) and (cboSchedule.Text = 'OTHER') then 2470 begin 2471 othSch := CreateOtherScheduel; 2472 if length(trim(othSch)) > 1 then 2473 begin 2084 2474 cboSchedule.Items.Add(othSch); 2085 2475 idx := cboSchedule.Items.IndexOf(OthSch); … … 2087 2477 end; 2088 2478 end; 2089 UpdateRelated(False);2090 end;2091 2092 procedure TfrmODMeds.cboScheduleChange(Sender: TObject);2093 var2094 othSch: string;2095 idx : integer;2096 begin2097 inherited;2098 if (FInptDlg) and (cboSchedule.Text = 'OTHER') then2099 begin2100 othSch := CreateOtherScheduel;2101 if length(trim(othSch)) > 1 then2102 begin2103 cboSchedule.Items.Add(othSch);2104 idx := cboSchedule.Items.IndexOf(OthSch);2105 cboSchedule.ItemIndex := idx;2106 end;2107 end;2108 //Remove Deletion of Text, since we are changing the validation to be on exit of the control.2109 { if (Length(cboSchedule.Text)>0) and (cboSchedule.ItemIndex < 0) and FInptDlg then2110 cboSchedule.Text := '';}2111 2479 FScheduleChanged := true; 2112 2480 UpdateRelated; … … 2178 2546 inherited; 2179 2547 if Changing then Exit; 2180 if not Showing then Exit; 2548 if not Showing then 2549 begin 2550 if (FISQuickOrder = true) and (txtQuantity.Text = '0') and (FLastQuantity > 0) and (FLastQuantity <> StrtoInt64(txtQuantity.text)) then 2551 begin 2552 Changing := True; 2553 txtQuantity.Text := FloattoStr(FLastQuantity); 2554 Changing := False; 2555 end; 2556 Exit; 2557 end; 2181 2558 if FNoZERO = False then FNoZERO := True; 2182 2559 // if value = 0, change probably caused by the spin button 2183 2560 if txtQuantity.Text <> '0' then txtQuantity.Tag := 1; 2184 2561 UpdateRelated; 2185 end;2186 2187 procedure TfrmODMeds.chkSCEnter(Sender: TObject);2188 begin2189 inherited;2190 pnlMessage.TabOrder := chkSC.TabOrder+1;2191 DispOrderMessage(RatedDisabilities);2192 end;2193 2194 procedure TfrmODMeds.chkSCClick(Sender: TObject);2195 begin2196 inherited;2197 chkSC.Tag := 1;2198 2562 end; 2199 2563 … … 2315 2679 end; 2316 2680 2681 2317 2682 function TfrmODMeds.ConstructedDoseFields(const ADose: string; PrependName: Boolean = FALSE): string; 2318 2683 var … … 2441 2806 begin 2442 2807 Result := ''; 2443 2808 if FInptDlg then // inpatient dialog 2444 2809 begin 2445 2810 DrugOK := True; … … 2491 2856 end 2492 2857 else DoseUnits := Piece(DoseFields, '&', 2); 2493 if not AnsiSameText(DoseUnits, DrugUnits) then DrugOK := False;2858 if (not AnsiSameText(DoseUnits, DrugUnits)) then DrugOK := False; 2494 2859 end; 2495 2860 if not DrugOK then … … 2536 2901 FUpdated := FALSE; 2537 2902 Responses.Clear; 2538 Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), txtMed.Text); 2903 if self.MedName = '' then Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), txtMed.Text) 2904 else Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), self.MedName); 2539 2905 DoseList := TStringList.Create; 2540 2906 case tabDose.TabIndex of … … 2579 2945 else Responses.Update('ROUTE', 1, '', x); 2580 2946 x := ValueOf(FLD_SCHEDULE); Responses.Update('SCHEDULE', 1, x, x); 2947 if FInptDlg then 2948 begin 2949 (* AGP Change Admin Time Wrap 27.73 2950 x := Piece(self.lblAdminSch.text,':',2); 2951 x := Copy(x,2,Length(x)); *) 2952 x := lblAdminSchGetText; 2953 if FAdminTimeText <> '' then x := ''; 2954 if x = 'Not Defined' then x := ''; 2955 Responses.Update('ADMIN',1,x,x); 2956 X := Valueof(FLD_SCHED_TYP); 2957 if self.chkPRN.Checked = true then x := 'P'; 2958 Responses.Update('SCHTYPE',1,x,x); 2959 end; 2581 2960 end; 2582 2961 TI_COMPLEX: … … 2627 3006 end; 2628 3007 x := ValueOf(FLD_DURATION, i); Responses.Update('DAYS', i, UpperCase(x), x); 3008 if FInptDlg then 3009 begin 3010 x := ValFor(VAL_ADMINTIME,i); 3011 if FAdminTimeText <> '' then x := ''; 3012 if x = 'Not Defined' then x := ''; 3013 Responses.Update('ADMIN',i,x,x); 3014 x := Valueof(FLD_SCHED_TYP, i); 3015 if ValFor(VAL_CHKXPRN, i) = '1' then x := 'P'; 3016 Responses.Update('SCHTYPE', i, x, x); 3017 end; 2629 3018 x := ValueOf(FLD_SEQUENCE, i); 2630 3019 if Uppercase(x) = 'THEN' then x := 'T' … … 2674 3063 with grdDoses do 2675 3064 case FieldID of 2676 COL_DOSAGE : Result := Piece(Cells[COL_DOSAGE, ARow], TAB, 1); 2677 COL_ROUTE : Result := Piece(Cells[COL_ROUTE, ARow], TAB, 1); 2678 COL_SCHEDULE : Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 2679 COL_DURATION : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1); 2680 COL_SEQUENCE : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1); 2681 VAL_DOSAGE : Result := Piece(Cells[COL_DOSAGE, ARow], TAB, 2); 2682 VAL_ROUTE : Result := Piece(Cells[COL_ROUTE, ARow], TAB, 2); 2683 VAL_SCHEDULE : Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 2684 VAL_DURATION : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1); 2685 VAL_SEQUENCE : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1); 2686 VAL_CHKXPRN : Result := Cells[COL_CHKXPRN, ARow]; 3065 COL_DOSAGE : Result := Piece(Cells[COL_DOSAGE, ARow], TAB, 1); 3066 COL_ROUTE : Result := Piece(Cells[COL_ROUTE, ARow], TAB, 1); 3067 COL_SCHEDULE : Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3068 COL_DURATION : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1); 3069 COL_SEQUENCE : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1); 3070 VAL_DOSAGE : Result := Piece(Cells[COL_DOSAGE, ARow], TAB, 2); 3071 VAL_ROUTE : Result := Piece(Cells[COL_ROUTE, ARow], TAB, 2); 3072 VAL_SCHEDULE : Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3073 VAL_DURATION : Result := Piece(Cells[COL_DURATION, ARow], TAB, 1); 3074 VAL_ADMINTIME : Result := Piece(Cells[COL_ADMINTIME, ARow], TAB, 1); 3075 VAL_SEQUENCE : Result := Piece(Cells[COL_SEQUENCE, ARow], TAB, 1); 3076 VAL_CHKXPRN : Result := Cells[COL_CHKXPRN, ARow]; 2687 3077 end; 2688 3078 end; … … 2730 3120 function TfrmODMeds.DurationToDays: Integer; 2731 3121 var 2732 i, DoseMinutes, TotalMinutes: Integer;3122 i, DoseMinutes, AndMinutes, TotalMinutes: Integer; 2733 3123 AllRows: Boolean; 2734 3124 Days: Extended; … … 2743 3133 if not AllRows then Exit; 2744 3134 3135 AndMinutes := 0; 2745 3136 TotalMinutes := 0; 2746 3137 with grdDoses do for i := 1 to Pred(RowCount) do … … 2754 3145 if Piece(x, ' ', 2) = 'HOURS' then DoseMinutes := ExtractInteger(x) * 60; 2755 3146 if Piece(x, ' ', 2) = 'MINUTES' then DoseMinutes := ExtractInteger(x); 2756 TotalMinutes := TotalMinutes + DoseMinutes; 2757 end; 3147 // Determine how TotalMinutes should be calculated based on conjunction 3148 if ValFor(COL_SEQUENCE, i) <> 'AND' then // 'THEN', 'EXCEPT', or '' 3149 begin 3150 if AndMinutes = 0 then TotalMinutes := TotalMinutes + DoseMinutes; 3151 if AndMinutes > 0 then 3152 begin 3153 if AndMinutes < DoseMinutes then AndMinutes := DoseMinutes; 3154 TotalMinutes := TotalMinutes + AndMinutes; 3155 AndMinutes := 0; 3156 end; 3157 if ValFor(COL_SEQUENCE, i) = 'EXCEPT' then break; //quit out of For Loop to stop counting TotalMinutes 3158 end; 3159 if (ValFor(COL_SEQUENCE, i) = 'AND') then 3160 if AndMinutes < DoseMinutes then AndMinutes := DoseMinutes; 3161 end; 3162 if AndMinutes > 0 then TotalMinutes := TotalMinutes + AndMinutes; 3163 2758 3164 Days := TotalMinutes / 1440; 2759 3165 if Days > Int(Days) then Days := Days + 1; … … 2768 3174 REL_DURATION = 0.16; 2769 3175 REL_ANDTHEN = 0.10; 3176 REL_ADMINTIME = 0.16; 2770 3177 var 2771 3178 i, ht, RowCountShowing: Integer; … … 2777 3184 i := grdDoses.Width - 12; // 12 = 4 pixel margin + 8 pixel column 0 2778 3185 i := i - GetSystemMetrics(SM_CXVSCROLL); // compensate for appearance of scroll bar 2779 ColWidths[1] := Round(REL_DOSAGE * i); // dosage 2780 ColWidths[2] := Round(REL_ROUTE * i); // route 2781 ColWidths[3] := Round(REL_SCHEDULE * i); // schedule 2782 ColWidths[4] := Round(REL_DURATION * i); // duration 2783 ColWidths[5] := Round(REL_ANDTHEN * i); // and/then 3186 if (not FinptDlg) or (FAdminTimeText = 'Not defined for Clinic Locations') then 3187 begin 3188 ColWidths[1] := Round(REL_DOSAGE * i); // dosage 3189 ColWidths[2] := Round(REL_ROUTE * i); // route 3190 ColWidths[3] := Round(REL_SCHEDULE * i); // schedule 3191 ColWidths[4] := Round(REL_DURATION * i); // duration 3192 ColWidths[5] := Round(0 * i); // administration time 3193 grdDoses.TabStops[5] := False; 3194 ColWidths[6] := Round(REL_ANDTHEN * i); // and/then 3195 end 3196 else 3197 begin 3198 ColWidths[1] := Round(0.35 * i); // dosage 3199 ColWidths[2] := Round(0.10 * i); // route 3200 ColWidths[3] := Round(0.19 * i); // schedule 3201 ColWidths[4] := Round(0.12 * i); // duration 3202 ColWidths[5] := Round(0.16 * i); // administration time 3203 grdDoses.TabStops[5] := True; 3204 ColWidths[6] := Round(0.08 * i); // and/then 3205 end; 2784 3206 // adjust height of grid to not show partial rows 2785 3207 ht := pnlBottom.Top - Top - 6; … … 2796 3218 COL_SCHEDULE:ColControl := pnlXSchedule; 2797 3219 COL_DURATION:ColControl := pnlXDuration; 2798 COL_SEQUENCE:ColControl := pnlXSequence; 3220 COL_ADMINTIME:ColControl := pnlXAdminTime; 3221 COL_SEQUENCE:ColControl := cboXSequence; 2799 3222 end; {case} 2800 3223 … … 2844 3267 COL_ROUTE: with cboXRoute do if Items.Count > 0 then DroppedDown := True; 2845 3268 COL_SCHEDULE: with cboXSchedule do if Items.Count > 0 then DroppedDown := True; 3269 COL_SEQUENCE: with cboXSequence do if Items.Count > 0 then DroppedDown := True; 3270 2846 3271 end; 2847 3272 FDropColumn := -1; … … 2977 3402 end; *) 2978 3403 Changing := FALSE; 2979 pnlXSequence.Tag := ARow;3404 cboXSequence.Tag := ARow; 2980 3405 PlaceControl(pnlXSchedule); 2981 //cboXSchedule.SetFocus;2982 3406 FDropColumn := COL_SCHEDULE; 2983 3407 if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_SCHEDULE); … … 3005 3429 end; 3006 3430 COL_SEQUENCE: begin 3007 x := ValFor(COL_SEQUENCE, ARow); 3008 //if x = '' then x := 'and'; AGP Change 26.46 remove for CQ 9535 3009 btnXSequence.Caption := x; 3010 pnlXSequence.Caption := btnXSequence.Caption; 3011 pnlXSequence.Tag := ARow; 3431 SynchCombo(cboXSequence, ValFor(VAL_SEQUENCE, ARow), ValFor(COL_SEQUENCE, ARow)); 3432 cboXSequence.Tag := ARow; 3012 3433 ARow1 := ARow; 3013 PlaceControl(pnlXSequence); 3014 btnXSequence.Width := pnlXSequence.Width; 3434 PlaceControl(cboXSequence); 3435 FDropColumn := COL_SEQUENCE; 3436 if AChar <> #0 then PostMessage(Handle, UM_DELAYEVENT, Ord(AChar), COL_SEQUENCE); 3015 3437 end; 3438 COL_ADMINTIME: BEGIN 3439 pnlXAdminTime.OnClick(pnlXAdminTime); 3440 end; 3016 3441 end; {case ACol} 3017 3442 end; … … 3028 3453 txtXDuration.SelStart := 1; 3029 3454 end; 3455 COL_SEQUENCE : FindInCombo(Chr(Message.WParam), cboXSequence); 3030 3456 end; 3031 3457 end; … … 3041 3467 3042 3468 procedure TfrmODMeds.cboXDosageChange(Sender: TObject); 3469 var 3470 temp1,temp2: string; 3471 count: integer; 3043 3472 begin 3044 3473 inherited; 3045 3474 if not Changing and (cboXDosage.ItemIndex < 0) then 3046 3475 begin 3476 Count := Pos(U,cboXDosage.Text); 3477 if Count > 0 then 3478 begin 3479 temp1 := copy(cboXDosage.Text,0,count-1); 3480 temp2 := copy(cboXDosage.Text,count+1,Length(cboXDosage.text)); 3481 infoBox('An ^ is not allowed in the dosage value', 'Dosage Warning', MB_OK); 3482 cboXDosage.Text := temp1 + temp2; 3483 end; 3047 3484 grdDoses.Cells[COL_DOSAGE, cboXDosage.Tag] := cboXDosage.Text; 3048 3485 UpdateRelated; … … 3085 3522 3086 3523 procedure TfrmODMeds.cboXDosageExit(Sender: TObject); 3087 begin 3088 inherited; 3089 cboXDosageClick(Self); 3090 cboXDosage.Tag := -1; 3091 cboXDosage.Hide; 3092 UpdateRelated; 3093 RestoreDefaultButton; 3094 RestoreCancelButton; 3095 if (pnlMessage.Visible) and (memMessage.TabStop) then 3096 begin 3097 pnlMessage.Parent := grdDoses.Parent; 3098 pnlMessage.TabOrder := grdDoses.TabOrder; 3099 ActiveControl := memMessage; 3100 end 3101 else if grdDoses.Showing then 3102 ActiveControl := grdDoses 3103 else 3104 ActiveControl := cboDosage; 3105 end; 3524 var 3525 //tempTag: integer; 3526 str: string; 3527 begin 3528 inherited; 3529 if cboXDosage.Showing then 3530 begin 3531 cboXDosageClick(Self); 3532 str := cboXDosage.Text; 3533 //tempTag := cboXDosage.Tag; 3534 //cboXDosage.Tag := -1; 3535 cboXDosage.Hide; 3536 UpdateRelated; 3537 RestoreDefaultButton; 3538 RestoreCancelButton; 3539 (*Probably not needed here since on validation check on accept 3540 if (LeftStr(cboXDosage.Text,1)='.') and (self.tabDose.TabIndex = TI_COMPLEX) then 3541 begin 3542 infoBox('Dosage must have a leading numeric value','Invalid Dosage',MB_OK); 3543 //cboXDosage.Tag := tempTag; 3544 cboXDosage.Show; 3545 cboXDosage.SetFocus; 3546 Exit; 3547 end; *) 3548 if (length(cboxdosage.Text)>0) and (cboxDosage.ItemIndex > -1) and 3549 (Piece(cboxDosage.Items.Strings[cboxDosage.ItemIndex],U,5) <> Piece(cboxDosage.Text,'#',1)) then 3550 begin 3551 cboXDosage.ItemIndex := -1; 3552 cboXDosage.Text := Piece(str, '#', 1); 3553 self.grdDoses.Cells[COL_DOSAGE,self.grdDoses.row] := cboXDosage.Text; 3554 UpdateRelated(false); 3555 end; 3556 if (pnlMessage.Visible) and (memMessage.TabStop) then 3557 begin 3558 pnlMessage.Parent := grdDoses.Parent; 3559 pnlMessage.TabOrder := grdDoses.TabOrder; 3560 ActiveControl := memMessage; 3561 end 3562 else if grdDoses.Showing then 3563 ActiveControl := grdDoses 3564 else 3565 ActiveControl := cboDosage; 3566 end 3567 else 3568 cmdQuit.Click; 3569 end; 3106 3570 3107 3571 procedure TfrmODMeds.cboXRouteChange(Sender: TObject); … … 3175 3639 if (FInptDlg) and (cboXSchedule.Text = 'OTHER') then 3176 3640 begin 3641 cboXSchedule.SelectByID('OTHER'); 3177 3642 othSch := CreateOtherScheduelComplex; 3178 3643 if length(trim(othSch)) > 1 then 3179 3644 begin 3645 othSch := othSch + U + U + NSSScheduleType + U + NSSAdminTime; 3180 3646 cboXSchedule.Items.Add(othSch); 3181 idx := cboXSchedule.Items.IndexOf( OthSch);3647 idx := cboXSchedule.Items.IndexOf(Piece(OthSch, U, 1)); 3182 3648 cboXSchedule.ItemIndex := idx; 3183 3649 end; 3184 3650 end; 3185 (* if chkXPRN.Checked then PRN := ' PRN' else PRN := ''; 3186 with cboXSchedule do if ItemIndex > -1 3187 then x := Text + PRN + TAB + Items[ItemIndex] 3188 else x := Text + PRN; *) 3651 if pnlXSchedule.Tag = -1 then pnlXSchedule.Tag := self.grdDoses.Row; 3652 //if pnlXSchedule.Tag = -1 then pnlXSchedule.Tag := self.grdDoses.Row; 3189 3653 with cboXSchedule do if ItemIndex > -1 3190 3654 then x := Text + TAB + Items[ItemIndex] … … 3192 3656 grdDoses.Cells[COL_SCHEDULE, pnlXSchedule.Tag] := x; 3193 3657 self.cboSchedule.Text := x; 3658 //AGP Start Expired uncommented out the line 3659 if FInptDlg then UpdateStartExpires(Piece(x, tab, 1)); 3194 3660 UpdateRelated; 3195 3661 end; … … 3198 3664 procedure TfrmODMeds.cboXScheduleClick(Sender: TObject); 3199 3665 var 3200 x: string; 3201 begin 3202 inherited; 3203 //if chkXPRN.Checked then PRN := ' PRN' else PRN := ''; 3666 PRN,x: string; 3667 begin 3668 inherited; 3669 //agp change CQ 11015 3670 if (chkXPRN.Checked) then PRN := ' PRN' else PRN := ''; 3671 with cboXSchedule do 3672 begin 3673 if RightStr(Text,3) = 'PRN' then PRN := ''; 3674 if ItemIndex > -1 then x := Text + PRN + TAB + Items[ItemIndex] 3675 else x := Text + PRN; 3676 end; 3204 3677 (* with cboXSchedule do if ItemIndex > -1 3205 then x := Text + PRN + TAB + Items[ItemIndex]3206 else x := Text + PRN; *)3207 with cboXSchedule do if ItemIndex > -13208 3678 then x := Text + TAB + Items[ItemIndex] 3209 else x := Text; 3210 (* if (Pos('PRN',X)>0) and (pnlXSchedule.Tag = 1) then 3211 if lblAdmintime.visible then 3212 lblAdmintime.Caption := ''; *) 3679 else x := Text; *) 3213 3680 grdDoses.Cells[COL_SCHEDULE, pnlXSchedule.Tag] := x; 3214 UpdateStartExpires(x); 3681 //AGP Start Expired uncommented out the line 3682 UpdateStartExpires(Piece(x, tab, 1)); 3215 3683 UpdateRelated; 3216 3684 end; … … 3248 3716 else 3249 3717 ActiveControl := cboDosage; 3718 //AGP Start Expired commented out the line 3719 //updateStartExpires(valFor(COL_SCHEDULE,self.grdDoses.Row)); 3720 end; 3721 3722 procedure TfrmODMeds.pnlXAdminTimeClick(Sender: TObject); 3723 var 3724 Str: string; 3725 begin 3726 inherited; 3727 if not FInptDlg then Exit; 3728 3729 str := 'The Administration Times for this dose are: ' + CRLF + CRLF + VALFOR(VAL_ADMINTIME,grddoses.Row); 3730 str := str + CRLF + CRLF + AdminTimeHelpText; 3731 infoBox(str,'Administration Time Information',MB_OK); 3250 3732 end; 3251 3733 … … 3272 3754 if (Code <> 0) {and (I=0)} then 3273 3755 begin 3274 ShowM essage('Please use numeric characters only.');3756 ShowMsg('Please use numeric characters only.'); 3275 3757 with txtXDuration do 3276 3758 begin … … 3305 3787 begin 3306 3788 grdDoses.Cells[COL_DURATION, pnlXDuration.Tag] := ''; 3307 pnlXSequence.Tag := ARow1;3308 pnlXSequence.Caption:= '';3309 grdDoses.Cells[COL_SEQUENCE, pnlXSequence.Tag]:= '';3310 btnXSequence.Click;3789 cboXSequence.Tag := ARow1; 3790 grdDoses.Cells[COL_SEQUENCE, cboXSequence.Tag] := ''; 3791 cboXSequence.Text := ''; 3792 cboXSequence.ItemIndex := -1; 3311 3793 end 3312 3794 else … … 3340 3822 end; 3341 3823 3342 procedure TfrmODMeds.btnXSequenceClick(Sender: TObject);3343 var3344 APoint: TPoint;3345 begin3346 inherited;3347 inherited;3348 with TSpeedButton(Sender) do APoint := ClientToScreen(Point(0, Height));3349 popXSequence.Popup(APoint.X, APoint.Y);3350 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') and3356 ((ValFor(COL_DURATION, ARow1) = '') or3357 (ValFor(COL_DURATION, ARow1) = '0')) then3358 begin3359 InfoBox('A duration is required when using "Then" as a conjunction','Duration Warning',MB_OK);3360 pnlXSequence.Caption := '';3361 btnXSequence.Caption := '';3362 end;3363 }3364 end;3365 3366 procedure TfrmODMeds.popXSequenceClick(Sender: TObject);3367 var3368 x: string;3369 begin3370 inherited;3371 with TMenuItem(Sender) do if Tag > 0 then x := Caption else x := '';3372 //AGP Changes 26.12 PSI-04-633373 //if ((x = 'then') and (FInptDlg)) and ((ValFor(COL_DURATION, ARow1) = '') or (ValFor(COL_DURATION, ARow1) = '0')) then3374 //AGP change 26.32 Then/And conjunction requiring a duration to include outpatient orders3375 if (x = 'then') and ((ValFor(COL_DURATION, ARow1) = '') or (ValFor(COL_DURATION, ARow1) = '0')) then3376 begin3377 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;3381 btnXSequence.Caption := x;3382 pnlXSequence.Caption := btnXSequence.Caption;3383 grdDoses.Cells[COL_SEQUENCE, pnlXSequence.Tag] := Uppercase(x);3384 ControlChange(Sender);3385 end;3386 3387 procedure TfrmODMeds.pnlXSequenceExit(Sender: TObject);3388 begin3389 inherited;3390 grdDoses.Cells[COL_SEQUENCE, pnlXSequence.Tag] := Uppercase(btnXSequence.Caption);3391 if ActiveControl = grdDoses then3392 begin3393 //This next condition seldom occurs, since entering the dosage on the last3394 // row adds another row3395 if grdDoses.Row = grdDoses.RowCount - 1 then3396 grdDoses.RowCount := grdDoses.RowCount + 1;3397 end;3398 pnlXSequence.Tag := -1;3399 pnlXSequence.Hide;3400 RestoreDefaultButton;3401 RestoreCancelButton;3402 if (pnlMessage.Visible) and (memMessage.TabStop) then3403 begin3404 pnlMessage.Parent := grdDoses.Parent;3405 pnlMessage.TabOrder := grdDoses.TabOrder;3406 ActiveControl := memMessage;3407 end3408 else if grdDoses.Showing then3409 ActiveControl := grdDoses3410 else3411 ActiveControl := cboDosage;3412 end;3413 3824 3414 3825 procedure TfrmODMeds.btnXInsertClick(Sender: TObject); … … 3463 3874 Schedule <TAB> (nothing) 3464 3875 Duration <TAB> Duration^Units } 3876 3877 // the following functions were created to get rid of a compile warning saying the 3878 // return value may be undefined - too much branching logic in the case statements 3879 // for the compiler to handle 3880 3881 function GetSingleDoseSchedule: string; 3882 begin 3883 Result := UpperCase(Trim(cboSchedule.Text)); 3884 if chkPRN.Checked then Result := Result + ' PRN'; 3885 if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' 3886 then Result := Copy(Result, 1, Length(Result) - 4); 3887 end; 3888 3889 function GetSingleDoseScheduleEX: string; 3890 begin 3891 Result := ''; 3892 with cboSchedule do 3893 begin 3894 if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 2); 3895 (* if (Length(Result)=0) and (ItemIndex > -1) then 3896 begin 3897 Result := Piece(Items[ItemIndex], U, 1); 3898 if Piece(Items[ItemIndex], U, 3) = 'P' then 3899 begin 3900 if RightStr(Result,3) = 'PRN' then 3901 begin 3902 Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN 3903 if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then 3904 Result := Copy(Result,1,Length(Result)-1); 3905 end; 3906 Result := Result + ' AS NEEDED'; 3907 end; 3908 end; 3909 end; *) 3910 if RightStr(Result,3) = 'PRN' then 3911 begin 3912 Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN 3913 if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then 3914 Result := Copy(Result,1,Length(Result)-1); 3915 Result := Result + ' AS NEEDED' 3916 end; 3917 if (Length(Result) > 0) and chkPRN.Checked then 3918 Result := Result + ' AS NEEDED'; 3919 if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' then 3920 Result := Copy(Result, 1, Length(Result) - 10); 3921 if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then 3922 begin 3923 Result := Copy(Result, 1, Length(Result) - 13); 3924 if RightStr(Result,1)=' ' then 3925 Result := Result + 'AS NEEDED' 3926 else 3927 Result := Result + ' AS NEEDED'; 3928 end; 3929 end; 3930 end; 3931 3932 function GetComplexDoseSchedule: string; 3933 begin 3934 with grdDoses do 3935 begin 3936 Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1); 3937 if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3938 if valFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' PRN'; 3939 if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' then 3940 Result := Copy(Result, 1, Length(Result) - 4); 3941 end; 3942 end; 3943 3944 function GetComplexDoseScheduleEX: string; 3945 begin 3946 with grdDoses do 3947 begin 3948 (*Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 2); 3949 if Result = '' then //Added for CQ: 7639 3950 begin 3951 Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3952 if RightStr(Result,4) = ' PRN' then 3953 Result := Copy(Result,1,Length(Result)-4); //Remove the Trailing PRN 3954 end; 3955 if (Piece(Cells[COL_SCHEDULE, ARow], TAB, 1) <> 3956 Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1)) and 3957 (Pos('PRN', Piece(Cells[COL_SCHEDULE, ARow], TAB, 1)) > 0) 3958 then Result := Result + ' AS NEEDED'; 3959 end;*) 3960 Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,2); 3961 if Result = '' then Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2),U,1); //Added for CQ: 7639 3962 if Result = '' then Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3963 if RightStr(Result,3) = 'PRN' then 3964 begin 3965 Result := Copy(Result,1,Length(Result)-3); //Remove the Trailing PRN 3966 if (RightStr(Result,1) = ' ') or (RightStr(Result,1) = '-') then 3967 Result := Copy(Result,1,Length(Result)-1); 3968 Result := Result + ' AS NEEDED'; 3969 end; 3970 if valFor(VAL_CHKXPRN,ARow)='1' then Result := Result + ' AS NEEDED'; 3971 if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' 3972 then Result := Copy(Result, 1, Length(Result) - 10); 3973 if UpperCase(Copy(Result, Length(Result) - 12, Length(Result))) = 'PRN AS NEEDED' then 3974 begin 3975 Result := Copy(Result, 1, Length(Result) - 13); 3976 if RightStr(Result,1)=' ' then Result := Result + 'AS NEEDED' 3977 else Result := Result + ' AS NEEDED'; 3978 end; 3979 end; 3980 end; 3981 3465 3982 begin 3466 3983 Result := ''; … … 3496 4013 FLD_ROUTE_EX : with cboRoute do 3497 4014 if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 4); 3498 FLD_SCHEDULE : begin //gary) 3499 Result := UpperCase(Trim(cboSchedule.Text)); 3500 if chkPRN.Checked then Result := Result + ' PRN'; 3501 if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' 3502 then Result := Copy(Result, 1, Length(Result) - 4); 4015 FLD_SCHEDULE : begin 4016 Result := GetSingleDoseSchedule; 3503 4017 end; 3504 4018 FLD_SCHED_EX : begin 3505 with cboSchedule do 3506 begin 3507 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; 3530 if (Length(Result) > 0) and chkPRN.Checked then Result := Result + ' AS NEEDED'; 3531 if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' 3532 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; 4019 Result := GetSingleDoseScheduleEX; 3540 4020 end; 3541 4021 FLD_SCHED_TYP : with cboSchedule do … … 3578 4058 FLD_ROUTE_EX : Result := Piece(Piece(Cells[COL_ROUTE, ARow], TAB, 2), U, 4); 3579 4059 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); 4060 Result := GetComplexDoseSchedule; 3585 4061 end; 3586 4062 FLD_SCHED_EX : begin 3587 (*Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 2); 3588 if Result = '' then //Added for CQ: 7639 3589 begin 3590 Result := Piece(Cells[COL_SCHEDULE, ARow], TAB, 1); 3591 if RightStr(Result,4) = ' PRN' then 3592 Result := Copy(Result,1,Length(Result)-4); //Remove the Trailing PRN 3593 end; 3594 if (Piece(Cells[COL_SCHEDULE, ARow], TAB, 1) <> 3595 Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 1)) and 3596 (Pos('PRN', Piece(Cells[COL_SCHEDULE, ARow], TAB, 1)) > 0) 3597 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; 4063 Result := GetComplexDoseScheduleEX; 3618 4064 end; 3619 4065 FLD_SCHED_TYP : Result := Piece(Piece(Cells[COL_SCHEDULE, ARow], TAB, 2), U, 3); … … 3641 4087 FLD_PRIOR_NM : Result := cboPriority.Text; 3642 4088 FLD_COMMENT : Result := memComment.Text; 3643 FLD_SC : if chkSC.Visible then 3644 begin 3645 if chkSC.Checked then Result := '1' else Result := '0'; 3646 end; 4089 3647 4090 FLD_NOW_ID : if chkDoseNow.Visible and chkDoseNow.Checked then Result := '1' else Result := ''; 3648 4091 FLD_NOW_NM : if chkDoseNow.Visible and chkDoseNow.Checked then Result := 'NOW' else Result := ''; … … 3682 4125 var 3683 4126 ADrug: string; 3684 begin 4127 Checked: boolean; 4128 tmpSupply: integer; 4129 begin 4130 Checked := false; 3685 4131 if ((StrToFloatDef(txtQuantity.Text, 0) = 0) and (StrToIntDef(txtSupply.Text, 0) = 0) and 3686 4132 (txtQuantity.Tag = 0) and (txtSupply.Tag = 0) and (cboDosage.Text <> '')) 3687 or ((cboDosage.ItemIndex < 0) and not FIsQuickOrder ) then 3688 begin 4133 or ((cboDosage.ItemIndex < 0) and (not FIsQuickOrder)) or 4134 ((IsClozapineOrder = true) and (FISQuickOrder) and (FQOInitial)) then 4135 begin 4136 Checked := True; 3689 4137 ADrug := Piece(CurDispDrug, U, 1); 3690 4138 CurSupply := DefaultDays(ADrug, CurUnits, CurSchedule); … … 3694 4142 if (txtSupply.Text = '') or (StrToInt(txtSupply.Text)<>CurSupply) then 3695 4143 txtSupply.Text := IntToStr(CurSupply); 3696 if (FIsQuickOrder and FQOInitial) then4144 if (FIsQuickOrder) and (FQOInitial) and (IsClozapineOrder = false) then 3697 4145 begin 3698 4146 if StrToFloatDef(txtSupply.Text,0) > 0 then … … 3712 4160 SkipQtyCheck := TRUE; 3713 4161 end; 3714 end; 4162 if FQOInitial = true then FQOInitial := False; 4163 end; 4164 if (IsClozapineOrder = true) and (CurDispDrug <> '') and (CurDispDrug <> U)and (Checked = false) then 4165 begin 4166 ADrug := Piece(CurDispDrug, U, 1); 4167 tmpSupply := DefaultDays(ADrug, CurUnits, CurSchedule); 4168 if (tmpSupply > 0) and (CurSupply > tmpSupply) then 4169 begin 4170 CurSupply := tmpSupply; 4171 spnSupply.Position := CurSupply; 4172 if (txtSupply.Text = '') or (StrToInt(txtSupply.Text)<>CurSupply) then 4173 txtSupply.Text := IntToStr(CurSupply); 4174 end; 4175 CurQuantity := DaysToQty(CurSupply, CurUnits, CurSchedule, CurDuration, ADrug); 4176 if CurQuantity >= 0 then 4177 begin 4178 //spnQuantity.Position := CurQuantity; 4179 if (txtQuantity.Text <> '') and (CurQuantity > 0) then 4180 txtQuantity.Text := FloatToStr(CurQuantity); 4181 if (txtQuantity.Text = '') or (StrToInt(txtQuantity.Text) <> CurQuantity) and (CurQuantity > 0) then 4182 txtQuantity.Text := FloatToStr(CurQuantity); 4183 end; 4184 end; 3715 4185 end; 3716 4186 … … 3808 4278 end; 3809 4279 3810 procedure TfrmODMeds.UpdateSC(const CurDispDrug: string); 3811 var 3812 Dispense: Integer; 3813 begin 3814 Dispense := StrToIntDef(Piece(CurDispDrug, U, 1), 0); // just use first dispense drug for now 3815 if Patient.ServiceConnected and RequiresCopay(Dispense) then 3816 begin 3817 chkSC.Visible := True; 3818 if chkSC.Tag = 0 then chkSC.Checked := Patient.SCPercent > 50; 3819 if chkSC.Hint = '' then chkSC.Hint := RatedDisabilities; 3820 end 3821 else chkSC.Visible := False; 3822 FUpdated := True; 4280 procedure TfrmODMeds.updateSig; 4281 begin 4282 inherited; 4283 if self.tabDose.TabIndex = TI_DOSE then self.cboDosage.OnExit(cboDosage); 4284 if self.tabDose.TabIndex = TI_COMPLEX then self.cboxDosage.OnExit(cboxDosage); 3823 4285 end; 3824 4286 3825 4287 procedure TfrmODMeds.UpdateStartExpires(const CurSchedule: string); 3826 4288 var 3827 CompSch, ShowText, Duration, ASchedule: string;4289 CompSch, CompDose, LastSch, ShowText, Duration, ASchedule, TempSch, schType, Admin, tempAdmin: string; 3828 4290 AdminTime: TFMDateTime; 3829 i, j, Interval, PrnPos: Integer; 3830 begin 4291 j, r, Interval, PrnPos, SchID: Integer; 4292 EndCheck, rowCheck, DoseNow: boolean; 4293 begin 4294 if not FInptDlg then Exit; 3831 4295 if Length(CurSchedule)=0 then Exit; 3832 4296 ASchedule := Trim(CurSchedule); 4297 DoseNow := True; 4298 if self.EvtID > 0 then DoseNow := false; 3833 4299 if (Pos('^',ASchedule)>0) then 3834 4300 begin … … 3837 4303 Delete(ASchedule, PrnPos-1, 4); 3838 4304 end; 4305 if (FAdminTimeText = '') and (self.EvtID > 0) then FAdminTimeText := 'To Be Determined'; 4306 AdminTime := 0; 3839 4307 ASchedule := Trim(ASchedule); 4308 //AGP Change for CQ 9906 4309 EndCheck := False; 4310 lastSch := ''; 3840 4311 if self.tabDose.TabIndex = TI_COMPLEX then 3841 4312 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 4313 tempSch := ASchedule; 4314 ASchedule := ''; 4315 for r := 1 to self.grdDoses.RowCount-1 do 4316 begin 4317 CompSch := valFor(VAL_SCHEDULE,r); 4318 CompDose := valFor(VAL_DOSAGE,r); 4319 RowCheck := valFor(VAL_CHKXPRN,r)='1'; 4320 if (RowCheck = True) then 4321 begin 4322 if EndCheck = false then AdminTime := -1; 4323 if FAdminTimeText = '' then self.grdDoses.cells[COL_ADMINTIME, r] := '' 4324 else Self.grdDoses.Cells[COL_ADMINTIME, r] := FAdminTimeText; 4325 end 4326 else 4327 begin 4328 if CompSch <> '' then 4329 begin 4330 //cboXSchedule.Items.IndexOfName(CompSch); 4331 //cboXSchedule.SelectByID(CompSch); 4332 SchID := -1; 4333 for j := 0 to cboXSchedule.Items.Count - 1 do 4334 begin 4335 if Piece(cboXSchedule.Items.Strings[j], U, 1) = CompSch then 4336 begin 4337 schID := j; 4338 break; 4339 end; 4340 end; 4341 //if cboXSchedule.ItemIndex > -1 then 4342 if SchID > -1 then 4343 begin 4344 //SchID := cboXSchedule.ItemIndex; 4345 if (Piece(self.cboXSchedule.Items.Strings[SchID],U,1) = CompSch) then 4346 begin 4347 SchType := Piece(self.cboXSchedule.Items.Strings[SchID],U,3); 4348 if (SchType = 'P') or (SchType = 'O') or (SchType = 'OC') then 4349 self.grdDoses.Cells[COL_ADMINTIME, r] := '' 4350 else if FAdminTimeText <> '' then self.grdDoses.Cells[COL_ADMINTIME, r] := FAdminTimeText 4351 else 4352 begin 4353 self.grdDoses.Cells[COL_ADMINTIME, r] := Piece(self.cboXSchedule.Items.Strings[SchID],U,4); 4354 if self.grdDoses.Cells[COL_ADMINTIME, r] = '' then self.grdDoses.Cells[COL_ADMINTIME, r] := 'Not Defined'; 4355 4356 end; 4357 if CompDose <> '' then 4358 begin 4359 lastSch := CompSch; 4360 if (EndCheck = False) and ((SchType = 'P') or (SchType = 'O')) then AdminTime := -1 4361 //else Aschedule := ';' + CompSch; 4362 end; 4363 end; 4364 4365 end; 4366 end; 4367 end; 4368 if ((valFor(VAL_SEQUENCE,r) = 'AND') or (valFor(VAL_SEQUENCE,r) = '')) and (AdminTime > -1) and (EndCheck = false) then 4369 begin 4370 //if (CompSch = '') and (LastSch <> '') and (Aschedule <> '') then CompSch := LastSch; 4371 if (ASchedule <> '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ASchedule + ';' + CompSch; 4372 if (ASchedule = '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ';' + CompSch; 4373 end 4374 else if ValFor(VAL_SEQUENCE, r) = 'THEN' then 4375 begin 4376 // if (CompSch = '') and (LastSch <> '') and (Aschedule <> '') then CompSch := LastSch; 4377 if (ASchedule <> '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ASchedule + ';' + CompSch; 4378 if (ASchedule = '') and (CompSch <> '') and (RowCheck = False) then ASchedule := ';' + CompSch; 4379 EndCheck := True; 4380 end 4381 end; 4382 end; 4383 if self.tabDose.TabIndex = TI_DOSE then 4384 begin 4385 if LeftStr(ASchedule, 1) = ';' then tempSch := Piece(ASchedule, ';', 2) 4386 else tempSch := ASchedule; 4387 if self.chkPRN.Checked = True then 4388 begin 4389 AdminTime := -1; 4390 lblAdminSchSetText(''); 4391 if (cboSchedule.ItemIndex > -1) and (Piece(self.cboSchedule.Items.Strings[cboSchedule.itemIndex], U, 3) = 'O') then 4392 DoseNow := false; 4393 end 4394 else begin 4395 //cboSchedule.SelectByID(tempSch); 4396 SchID := -1; 4397 for j := 0 to cboSchedule.Items.Count - 1 do 4398 begin 4399 if Piece(cboSchedule.Items.Strings[j], U, 1) = tempSch then 3853 4400 begin 3854 AdminTime := -1;3855 Aschedule := '';4401 schID := j; 4402 break; 3856 4403 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; 3866 if Length(ASchedule)>0 then 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 4404 end; 4405 if schID > -1 then 3874 4406 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 4407 SchType := Piece(self.cboSchedule.Items.Strings[schID], U, 3); 4408 if (SchType = 'P') or (SchType = 'OC') or (SchType = 'O') then 3876 4409 begin 3877 AdminTime := -1; 3878 break; 4410 lblAdminSchSetText(''); 4411 if (SchType = 'P') or (SchType = 'OC') or (SchType = 'O') then AdminTime := -1; 4412 if SchType = 'O' then DoseNow := false; 4413 end 4414 else 4415 begin 4416 if FAdminTimeText <> '' then tempAdmin := 'Admin. Time: ' + FAdminTimeText 4417 else 4418 begin 4419 if Piece(self.cboSchedule.Items.Strings[schID], U, 4) <> '' then 4420 tempAdmin := 'Admin. Time: ' + Piece(self.cboSchedule.Items.Strings[schID], U, 4) 4421 else tempAdmin := 'Admin. Time: Not Defined'; 4422 end; 4423 lblAdminSchSetText(tempAdmin); 4424 (* if FAdminTimeText <> '' then self.lblAdminSch.text := 'Admin. Time: ' + FAdminTimeText 4425 else 4426 begin 4427 if Piece(self.cboSchedule.Items.Strings[schID], U, 4) <> '' then 4428 self.lblAdminSch.text := 'Admin. Time: ' + Piece(self.cboSchedule.Items.Strings[schID], U, 4) 4429 else self.lblAdminSch.text := 'Admin. Time: Not Defined'; 4430 end; *) 4431 3879 4432 end; 3880 4433 end; 3881 4434 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; 4435 end; 4436 if (Length(ASchedule)>0) and (AdminTime > -1) then 4437 begin 4438 if LeftStr(Aschedule, 1) <> ';' then ASchedule := ';'+ASchedule; 4439 Admin := ''; 4440 if (self.lblAdminSch.visible = True) and (self.lblAdminSch.text <> '') and (self.tabDose.TabIndex = TI_DOSE) then 4441 begin 4442 //AGP Change Admin Time Wrap 27.73 4443 //Admin := Copy(self.lblAdminSch.text, 14, (Length(self.lblAdminSch.text)-1)); 4444 Admin := lblAdminSchGetText; 4445 if (Admin <> '') and (not (Admin[1] in ['0'..'9'])) then Admin := ''; 4446 end 4447 else if self.tabDose.TabIndex = TI_COMPLEX then 4448 begin 4449 Admin := Self.grdDoses.Cells[COL_ADMINTIME, 1]; 4450 if (Admin <> '') and (not (Admin[1] in ['0'..'9'])) then Admin := ''; 4451 end; 4452 LoadAdminInfo(ASchedule, txtMed.Tag, ShowText, AdminTime, Duration, Admin); 4453 end; 3886 4454 if AdminTime > 0 then 3887 4455 begin … … 3906 4474 end 3907 4475 else lblAdminTime.Caption := ''; 4476 if (lblAdminTime.Caption <> '') and (lblAdminTime.Visible = True) and (JAWSON = true) then lblAdminTime.TabStop := true 4477 else lblAdminTime.TabStop := false; 4478 if (lblAdminSch.text <> '') and (lblAdminSch.Visible = True) and (JAWSON = true) then lblAdminSch.TabStop := true 4479 else lblAdminSch.TabStop := false; 4480 DisplayDoseNow(DoseNow); 3908 4481 end; 3909 4482 … … 3914 4487 else 3915 4488 spnRefills.Max := CalcMaxRefills(CurDispDrug, CurSupply, txtMed.Tag, Responses.EventType = 'D'); 3916 if StrToIntDef(txtRefills.Text, 0) > spnRefills.Maxthen4489 if (StrToIntDef(txtRefills.Text, 0) > spnRefills.Max) then 3917 4490 begin 3918 4491 txtRefills.Text := IntToStr(spnRefills.Max); … … 3940 4513 CurSupply, i, pNum, j: Integer; 3941 4514 CurQuantity: double; 3942 LackQtyInfo, SaveChanging , DispFirstDose: Boolean;4515 LackQtyInfo, SaveChanging: Boolean; 3943 4516 begin 3944 4517 inherited; … … 3947 4520 SaveChanging := Changing; 3948 4521 Changing := TRUE; 3949 DispFirstDose := FALSE;3950 4522 // don't allow Exit procedure so Changing gets reset appropriately 3951 4523 CurUnits := ''; … … 3997 4569 CurQuantity := StrToFloatDef(ValueOfResponse(FLD_QUANTITY), 0); 3998 4570 CurSupply := StrToIntDef(ValueOfResponse(FLD_SUPPLY) ,0); 4571 //CurRefill := StrToIntDef(ValueOfResponse(FLD_REFILLS) , 0); 3999 4572 if FInptDlg then 4000 4573 begin … … 4006 4579 lblAdminTime.Caption := ''; 4007 4580 end; 4008 if CurSchedule <> FLastSchedule then UpdateStartExpires(CurSchedule); 4009 if (ValueOf(FLD_SCHED_TYP) = 'O') 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') 4010 4584 or (Responses.EventType in ['A','D','T','M','O']) 4011 4585 or ((Length(cboSchedule.Text)>0) and (cboSchedule.ItemIndex < 0)) then … … 4016 4590 chkDoseNow.Checked := False; 4017 4591 end; 4018 for i := 0 to cboSchedule.Items.Count-1 do4019 begin4020 if Piece(cboSchedule.Items.Strings[i],U,1) = Uppercase(cboSchedule.Text) then4021 begin4022 DispFirstDose := True;4023 break;4024 end;4025 end;4026 if not DispFirstDose then4027 begin4028 4592 chkDoseNow.Visible := False; 4029 4593 lblAdminTime.Visible := False; 4030 end;4031 4594 end 4032 4595 else … … 4034 4597 chkDoseNow.Visible := TRUE; 4035 4598 lblAdminTime.Visible := not chkDoseNow.Checked; 4036 end; 4599 end; *) 4037 4600 if Responses.EventType in ['A','D','T','M','O'] then lblAdminTime.Visible := False; 4038 4601 end; … … 4040 4603 begin 4041 4604 CurSchedule := CurScheduleOut; 4042 if ( CurInstruct <> FLastInstruct) and (CurUnits <> U) //AGP Change 26.48 Do not update quantity and day supply if no matching dose on the server4605 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 4043 4606 then UpdateDefaultSupply(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity, 4044 4607 LackQtyInfo); … … 4049 4612 else 4050 4613 UpdateSupplyQuantity(CurUnits, CurSchedule, CurDuration, CurDispDrug, CurSupply, CurQuantity); 4051 if (CurDispDrug <> FLastDispDrug) then UpdateSC(CurDispDrug);4052 if ( CurDispDrug <> FLastDispDrug) or (CurSupply <> FLastSupply)then4614 // if (CurDispDrug <> FLastDispDrug) then UpdateSC(CurDispDrug); 4615 if ((CurDispDrug <> FLastDispDrug) or (CurSupply <> FLastSupply)) and ((CurDispDrug <> '') and (CurSupply > 0)) then 4053 4616 UpdateRefills(CurDispDrug, CurSupply); 4054 4617 end; … … 4098 4661 then DisplayGroup := DisplayGroupByName('UD RX') 4099 4662 else DisplayGroup := DisplayGroupByName('O RX'); 4663 (* if (Not FInptDlg) then 4664 begin 4665 if (ValidateDaySupplyandQuantity(strtoInt(txtSupply.Text), strtoInt(txtQuantity.text)) = false) then Exit 4666 else ClearMaxData; 4667 end; *) 4668 //if (Not FInptDlg) and (ValidateMaxQuantity(strtoInt(txtQuantity.Text)) = false) then Exit; 4669 4670 4100 4671 //timCheckChangesTimer(Self); 4101 4672 DropLastSequence; … … 4135 4706 if length(theSch)>0 then 4136 4707 begin 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 4708 //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 4138 4710 begin 4139 4711 chkDoseNow.Checked := False; … … 4152 4724 if (tabDose.TabIndex = TI_COMPLEX) and chkDoseNow.Checked then 4153 4725 begin 4154 if ( (ValueOf(FLD_SCHED_TYP) <> 'O') and (InfoBox('Give Additional Dose Now is in addition to those listed in the table.' + CRLF +4726 if (InfoBox('Give Additional Dose Now is in addition to those listed in the table.' + CRLF + 4155 4727 'Please adjust the duration of the first row, if necessary.', 4156 'Give Additional Dose Now for Complex Order', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) )then4728 'Give Additional Dose Now for Complex Order', MB_OKCANCEL or MB_ICONWARNING) = IDCANCEL) then 4157 4729 begin 4158 4730 chkDoseNow.Checked := False; … … 4283 4855 case Key of 4284 4856 // VK_RETURN: //moved to form key press 4857 VK_RIGHT: 4858 begin 4859 if (not FInptDlg) and (self.grdDoses.Col = COL_DURATION) then 4860 begin 4861 self.grdDoses.Col := COL_SEQUENCE; 4862 Key := 0; 4863 end; 4864 end; 4865 VK_LEFT: 4866 begin 4867 if (not FInptDlg) and (self.grdDoses.Col = COL_SEQUENCE) then 4868 begin 4869 self.grdDoses.Col := COL_DURATION; 4870 Key := 0; 4871 end; 4872 end; 4285 4873 VK_ESCAPE: 4286 4874 begin … … 4377 4965 procedure TfrmODMeds.FormKeyPress(Sender: TObject; var Key: Char); 4378 4966 begin 4379 if (Key = #13) and (ActiveControl = grdDoses{pnlXSequence}) then4967 (* if (Key = #13) and (ActiveControl = grdDoses{pnlXSequence}) then 4380 4968 begin 4381 4969 ShowEditor(grdDoses.Col, grdDoses.Row, #0); 4382 4970 Key := #0; //Don't let the base class turn it into a forward tab! 4383 end 4384 else if (Key = #13) and (ActiveControl = txtMed) then 4971 end *) 4972 //else 4973 if (Key = #13) and (ActiveControl = txtMed) then 4385 4974 Key := #0; //Don't let the base class turn it into a forward tab! 4386 4975 end; … … 4406 4995 end; 4407 4996 4408 procedure TfrmODMeds.pnl XSequenceEnter(Sender: TObject);4997 procedure TfrmODMeds.pnlMessageEnter(Sender: TObject); 4409 4998 begin 4410 4999 inherited; … … 4413 5002 end; 4414 5003 4415 procedure TfrmODMeds.pnlMessageEnter(Sender: TObject);4416 begin4417 inherited;4418 DisableDefaultButton(self);4419 DisableCancelButton(self);4420 end;4421 4422 5004 procedure TfrmODMeds.pnlMessageExit(Sender: TObject); 4423 5005 begin … … 4441 5023 begin 4442 5024 inherited; 4443 ShowM essage('The patient instruction field may not be edited.');5025 ShowMsg('The patient instruction field may not be edited.'); 4444 5026 chkPtInstruct.SetFocus; 4445 5027 end; … … 4448 5030 var 4449 5031 aftHeight: integer; 5032 tempAdmin: string; 4450 5033 begin 4451 5034 inherited; … … 4456 5039 if pnlMessage.Visible then 4457 5040 pnlMessage.Top := pnlFields.Top + pnlTop.Height + 8; 4458 end; 4459 4460 procedure TfrmODMeds.spnQuantityChangingEx(Sender: TObject; 4461 var AllowChange: Boolean; NewValue: Smallint; 4462 Direction: TUpDownDirection); 4463 var 4464 tempQuant: double; 4465 begin 4466 inherited; 4467 if Direction = updUp then 4468 begin 4469 tempQuant := StrToFloatDef(txtQuantity.Text,0) + 1; 4470 txtQuantity.Text := FloatToStr(tempQuant); 4471 end else if Direction = updDown then 4472 begin 4473 tempQuant := StrToFloatDef(txtQuantity.Text,0) - 1 ; 4474 if tempQuant < 0 then tempQuant := 0; 4475 txtQuantity.Text := FloatToStr(tempQuant); 4476 end; 4477 spnQuantity.Tag := 1; 4478 txtQuantity.Tag := 1; 5041 tempAdmin := lblAdminSchGetText; 5042 if tempAdmin <> '' then lblAdminSchSetText('Admin Time: ' + tempAdmin); 4479 5043 end; 4480 5044 … … 4483 5047 begin 4484 5048 inherited; 4485 ShowM essage('The patient instruction field may not be edited.');5049 ShowMsg('The patient instruction field may not be edited.'); 4486 5050 chkPtInstruct.SetFocus; 4487 5051 end; … … 4553 5117 cboSchedule.ItemIndex := -1; 4554 5118 cboSchedule.Text := ''; 4555 end; 4556 Result := aSchedule; 5119 end 5120 else 5121 begin 5122 Result := Piece(aSchedule,U,1); 5123 NSSAdminTime := Piece(aschedule,u,2); 5124 NSSScheduleType := Piece(aSchedule, U, 3); 5125 if FAdminTimeText <> '' then NSSAdminTime := FAdminTimeText; 5126 end; 4557 5127 end; 4558 5128 … … 4579 5149 (Assigned(lstQuick.Items[lstQuick.ItemIndex].Data)) and 4580 5150 (Integer(lstQuick.Selected.Data) > 0)) ; 5151 if (btnSelect.Enabled) and (FOrderAction = ORDER_EDIT) then btnSelect.Enabled := false; 4581 5152 if (btnSelect.Enabled) and (FRemoveText) then 4582 5153 txtMed.Text := ''; 4583 5154 end; 4584 5155 5156 5157 procedure TfrmODMeds.DisplayDoseNow(Status: boolean); 5158 begin 5159 if not FinptDlg then Status := False; 5160 if Status = false then 5161 begin 5162 if (self.chkDoseNow.Visible = true) and (self.chkDoseNow.Checked = true) then self.chkDoseNow.Checked := false; 5163 self.chkDoseNow.Visible := false; 5164 end; 5165 if status = true then self.chkDoseNow.Visible := true; 5166 end; 4585 5167 4586 5168 procedure TfrmODMeds.DispOrderMessage(const AMessage: string); … … 4613 5195 procedure TfrmODMeds.FormClose(Sender: TObject; var Action: TCloseAction); 4614 5196 begin 5197 if FCloseCalled then Exit; //Temporary Hack: Close is called 2x for some reason & errors out 5198 FCloseCalled := true; 4615 5199 FResizedAlready := False; 4616 5200 inherited; … … 4626 5210 cboXSchedule.ItemIndex := -1; 4627 5211 cboXSchedule.Text := ''; 4628 end; 4629 Result := aSchedule; 5212 end 5213 else 5214 begin 5215 Result := Piece(aSchedule,U,1); 5216 NSSAdminTime := Piece(aschedule,u,2); 5217 NSSScheduleType := Piece(ASchedule, U, 3); 5218 if FAdminTimeText <> '' then NSSAdminTime := FAdminTimeText; 5219 end; 4630 5220 end; 4631 5221 … … 4660 5250 procedure TfrmODMeds.FormShow(Sender: TObject); 4661 5251 begin 5252 FCloseCalled := false; 4662 5253 inherited; 4663 5254 if ( (cboSchedule.Text = 'OTHER') and FNSSOther and FInptDlg )then 4664 5255 PostMessage(Handle, UM_NSSOTHER, 0, 0); 5256 5257 //I was using btnSelect.Top for the following, but it gets moved around 5258 Constraints.MinHeight := Constraints.MinHeight + ((Self.Height - cmdQuit.Top) * 2); 4665 5259 end; 4666 5260 … … 4697 5291 ScheduleCombo.ItemIndex := tmpIndex; 4698 5292 end; 4699 if (Length(ScheduleCombo.Text) > 0) and (ScheduleCombo.ItemIndex < 0) and FInptDlg then4700 begin4701 FShowPnlXScheduleOk := False; //Added for CQ: 73704702 Application.MessageBox('Please select a valid schedule from the list.'+#13+#13+5293 if (Length(ScheduleCombo.Text) > 0) and (ScheduleCombo.ItemIndex < 0) and FInptDlg then 5294 begin 5295 FShowPnlXScheduleOk := False; //Added for CQ: 7370 5296 Application.MessageBox('Please select a valid schedule from the list.'+#13+#13+ 4703 5297 'If you would like to create a Day-of-Week schedule please'+ 4704 5298 ' select ''OTHER'' from the list.', … … 4749 5343 4750 5344 // CQ: 7397 - Inpatient med orders with PRN cancel due to invalid schedule. 5345 function TfrmODMeds.GetCacheChunkIndex(idx: integer): integer; 5346 begin 5347 Result := idx div MED_CACHE_CHUNK_SIZE; 5348 end; 5349 4751 5350 function TfrmODMeds.GetSchedListIndex(SchedCombo: TORComboBox; pSchedule: String):integer; 4752 5351 var i: integer; … … 4772 5371 end; 4773 5372 5373 procedure TfrmODMeds.cboXSequenceChange(Sender: TObject); 5374 var 5375 x: string; 5376 begin 5377 inherited; 5378 x := cboXSequence.Text; 5379 if (x = 'then') and ((ValFor(COL_DURATION, ARow1) = '') or (ValFor(COL_DURATION, ARow1) = '0')) then 5380 begin 5381 InfoBox('A duration is required when using "Then" as a conjunction' + CRLF + CRLF+ 5382 'The patient will be instructed to take these doses consecutively, not concurrently.','Duration Warning',MB_OK); 5383 x := ''; 5384 end; 5385 cboXSequence.text := x; 5386 cboXSequence.ItemIndex := cboXSequence.Items.IndexOf(x); 5387 grdDoses.Cells[COL_SEQUENCE, cboXSequence.Tag] := Uppercase(x); 5388 //AGP Start Expire add line 5389 UpdateStartExpires(valFor(COL_SCHEDULE,self.grdDoses.Row)); 5390 ControlChange(Sender); 5391 end; 5392 5393 procedure TfrmODMeds.cboXSequenceEnter(Sender: TObject); 5394 begin 5395 inherited; 5396 DisableDefaultButton(self); 5397 DisableCancelButton(self); 5398 end; 5399 5400 procedure TfrmODMeds.cboXSequenceExit(Sender: TObject); 5401 begin 5402 inherited; 5403 grdDoses.Cells[COL_SEQUENCE, cboXSequence.Tag] := Uppercase(cboXSequence.Text); 5404 if ActiveControl = grdDoses then 5405 begin 5406 //This next condition seldom occurs, since entering the dosage on the last 5407 // row adds another row 5408 if grdDoses.Row = grdDoses.RowCount - 1 then 5409 grdDoses.RowCount := grdDoses.RowCount + 1; 5410 end; 5411 cboXSequence.Tag := -1; 5412 cboXSequence.Hide; 5413 RestoreDefaultButton; 5414 RestoreCancelButton; 5415 if (pnlMessage.Visible) and (memMessage.TabStop) then 5416 begin 5417 pnlMessage.Parent := grdDoses.Parent; 5418 pnlMessage.TabOrder := grdDoses.TabOrder; 5419 ActiveControl := memMessage; 5420 end 5421 else if grdDoses.Showing then 5422 ActiveControl := grdDoses 5423 else 5424 ActiveControl := cboDosage; 5425 //AGP Start Expire commented out line 5426 //UpdateStartExpires(valFor(COL_SCHEDULE,self.grdDoses.Row)); 5427 end; 5428 5429 procedure TfrmODMeds.cboXSequence1Exit(Sender: TObject); 5430 begin 5431 inherited; 5432 cboxSequence.Hide; 5433 end; 5434 4774 5435 procedure TfrmODMeds.cboDosageKeyUp(Sender: TObject; var Key: Word; 4775 5436 Shift: TShiftState); … … 4778 5439 //Fix for CQ: 7545 4779 5440 if cboDosage.ItemIndex > -1 then 4780 cboDosageClick(Sender); 5441 cboDosageClick(Sender) 5442 else 5443 UpdateRelated; 4781 5444 end; 4782 5445 … … 4787 5450 //Fix for CQ: 7545 4788 5451 if cboXDosage.ItemIndex > -1 then 4789 cboXDosageClick(Sender); 5452 cboXDosageClick(Sender) 5453 else 5454 begin 5455 grdDoses.Cells[COL_DOSAGE, cboXDosage.Tag] := cboXDosage.Text; 5456 UpdateRelated; 5457 end; 4790 5458 end; 4791 5459 … … 4800 5468 inherited; 4801 5469 self.txtQuantity.SelectAll; 5470 end; 5471 5472 procedure TfrmODMeds.txtRefillsChange(Sender: TObject); 5473 begin 5474 inherited; 5475 ControlChange(sender); 4802 5476 end; 4803 5477 … … 4830 5504 begin 4831 5505 inherited; 4832 //agp Change CQ 10719 5506 //agp Change CQ 10719 4833 5507 self.chkXPRN.OnClick(self.chkXPRN); 4834 5508 end; 4835 5509 5510 4836 5511 end.
Note:
See TracChangeset
for help on using the changeset viewer.