Changeset 460 for cprs/branches/foia-cprs/CPRS-Chart/Orders/fODDiet.pas
- Timestamp:
- Jul 6, 2008, 8:20:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/foia-cprs/CPRS-Chart/Orders/fODDiet.pas
r459 r460 96 96 cmdOPRemove: TButton; 97 97 chkOPCancelTubefeeding: TCheckBox; 98 calOPTFStart: TORDateBox; 99 lblOPTFStart: TLabel; 100 lblOPAOStart: TLabel; 101 calOPAOStart: TORDateBox; 102 cboOPAORecurringMeals: TORComboBox; 103 cboOPTFRecurringMeals: TORComboBox; 104 cboOPELRecurringMeals: TORComboBox; 98 105 procedure nbkDietChanging(Sender: TObject; 99 106 var AllowChange: Boolean); … … 137 144 procedure FormKeyDown(Sender: TObject; var Key: Word; 138 145 Shift: TShiftState); 139 // Outpatient meal additions140 procedure cboOPDietAvailNeedData(Sender: TObject;141 const StartFrom: String; Direction, InsertAt: Integer);142 146 procedure cboOPDietAvailMouseClick(Sender: TObject); 143 147 procedure cboOPDietAvailExit(Sender: TObject); … … 149 153 procedure grpOPMealClick(Sender: TObject); 150 154 procedure cmdOPRemoveClick(Sender: TObject); 155 procedure cboOPDietAvailKeyDown(Sender: TObject; var Key: Word; 156 Shift: TShiftState); 151 157 private 152 158 FNextCol: Integer; … … 177 183 function TFStrengthCode(const x: string): Integer; 178 184 // Outpatient meal additions 185 function FMDOW(AnFMDate: TFMDateTime): integer; 186 function FMDays(AStart, AEnd: TFMDateTime): string; 179 187 function GetOPDaysOfWeek: string; 180 procedure SetEnableOPDOW(AllowUse: Boolean );188 procedure SetEnableOPDOW(AllowUse: Boolean; OneTimeDay: integer; DaysToCheck: string = ''); 181 189 procedure ResetControlsOP; 182 190 procedure SetValuesFromResponsesOP; … … 184 192 procedure OPDietCheckForNPO; 185 193 procedure OPDietCheckForTF; 194 function PatientHasRecurringMeals(var MealList: TStringList; MealType: string = ''): boolean; 186 195 protected 187 196 procedure InitDialog; override; … … 195 204 uDialogName: string; 196 205 uFHAUTH: boolean; 206 uRecurringMealList: TStringList; 197 207 198 208 implementation … … 200 210 {$R *.DFM} 201 211 202 uses uCore, rODBase, rODDiet, rCore, rOrders, fODDietLT, uAccessibleStringGrid ;212 uses uCore, rODBase, rODDiet, rCore, rOrders, fODDietLT, uAccessibleStringGrid, DateUtils; 203 213 204 214 const … … 209 219 TX_DIET_PRC = 'This diet conflicts with '; 210 220 TC_DIET_ERR = 'Unable to Add Diet'; 211 TX_INPT_ONLY = 'Diets may be entered for inpatients only.'; 212 //TX_INPT_ONLY = 'This type of diet may be entered for inpatients only.'; 221 TX_INPT_ONLY = 'This type of diet may be entered for inpatients only.'; 213 222 TC_INPT_ONLY = 'Ordering Restriction'; 214 223 TX_CANCEL_TF = 'Cancel the current tubefeeding order?' + CRLF + CRLF; … … 221 230 TX_TFQTY = 'A quantity must be entered for '; 222 231 TX_TFAMT = 'The quantity is invalid for '; 223 TX_TF5000 = 'The total quantity ordered may not exceed 5000 cc.';232 TX_TF5000 = 'The total quantity ordered may not exceed 5000ml.'; 224 233 TX_HLPQTY = CRLF + 'The following may be entered for quantity:' + CRLF + 225 ' Units may be K for Kcals, C for cc''s, O for oz. or U for units (e.g. cans).' + CRLF +234 ' Units may be K for Kcals, C for cc''s, M for ml, O for oz. or U for units (e.g. cans).' + CRLF + 226 235 ' Frequency may be DAY, HOUR, QD, QH, BID, TID, QID, Q2H, Q3H, Q4H, or Q6H.' + CRLF + 227 236 ' May also input 100CC/HR X 16 for 16 hours. Valid quantity for powder form' + CRLF + … … 242 251 TX_AONONE = 'Text for additional order has not been entered.'; 243 252 TX_ACCEPT = 'Accept the following order?' + CRLF + CRLF; 253 TX_CONTINUE = 'Continue editing the following order?' + CRLF + CRLF; 254 TX_DISCARD = CRLF + CRLF + 'Answering NO will discard all changes.'; 244 255 TC_ACCEPT = 'Unsaved Order'; 245 256 TX_EL_SAVE_ERR = 'An error occurred while saving this late tray order.'; … … 274 285 'coordinator enters times for E/L trays for this location.'; 275 286 TC_NO_PARAMS = 'Unable to Order Early/Late Tray'; 287 TX_NOSTART = 'A valid start date must be entered.'; 288 TC_NOSTART = 'Start date required'; 289 TX_NOT_THIS_LOC = 'This location has not been configured to' + CRLF + 290 'allow ordering of meals for outpatients.' + CRLF + CRLF + 291 'Please contact your IRM diet package coordinator.'; 292 TC_NOT_THIS_LOC = 'Unable to order from this location'; 293 TX_NO_OUTPT_ORDERS = 'Diet orders may only be entered for inpatients.'; 294 TC_NO_OUTPT_ORDERS = 'Ordering Restriction'; 295 TX_NO_MEALS_DEFINED = 'No diet types have been defined to be orderable for outpatients.' + CRLF + CRLF + 296 'Please contact your IRM diet package coordinator.'; 297 TC_NO_MEALS_DEFINED = 'Unable to order outpatient meals'; 298 299 FMDayLetters: array[1..7] of string[1] = ('M', 'T', 'W', 'R', 'F', 'S', 'X'); 276 300 277 301 type … … 290 314 begin 291 315 inherited; 316 AbortOrder := False; 317 uRecurringMealList := TStringList.Create; 292 318 if OrderForInpatient then 293 319 begin … … 302 328 else // this block will go away after FH patch installed everywhere 303 329 begin 304 InfoBox(TX_ INPT_ONLY, TC_INPT_ONLY, MB_OK);305 Close;330 InfoBox(TX_NO_OUTPT_ORDERS, TC_NO_OUTPT_ORDERS, MB_OK); 331 AbortOrder := True; 306 332 Exit; 307 333 end; … … 313 339 if StrToIntDef(ALocation, 0) < 1 then 314 340 ALocation := IntToStr(Encounter.Location); 315 LoadDietParams(uDietParams, ALocation); 316 if pgeOutPt.TabVisible then 317 with uDietParams, cboOPDelivery do 318 begin 319 if Tray then Items.Add('T^Tray'); 320 if Cafeteria then Items.Add('C^Cafeteria'); 321 if DiningRm then Items.Add('D^Dining Room'); 322 //if Bagged then Items.Add('B^Bagged'); // ???? 323 ItemIndex := 0; 324 chkBagged.Visible := uDietParams.Bagged; // ???? 341 if (not OrderForInpatient) and OutpatientPatchInstalled and (not OutpatientLocationConfigured(ALocation)) then 342 begin 343 InfoBox(TX_NOT_THIS_LOC, TC_NOT_THIS_LOC, MB_OK or MB_ICONINFORMATION); 344 AbortOrder := True; 325 345 end 326 346 else 327 with uDietParams, cboDelivery do 328 begin 329 if Tray then Items.Add('T^Tray'); 330 if Cafeteria then Items.Add('C^Cafeteria'); 331 if DiningRm then Items.Add('D^Dining Room'); 332 ItemIndex := 0; 333 chkBagged.Visible := uDietParams.Bagged; 347 begin 348 LoadDietParams(uDietParams, ALocation); 349 if pgeOutPt.TabVisible then 350 with uDietParams, cboOPDelivery do 351 begin 352 if Tray then Items.Add('T^Tray'); 353 if Cafeteria then Items.Add('C^Cafeteria'); 354 if DiningRm then Items.Add('D^Dining Room'); 355 ItemIndex := 0; 356 chkBagged.Visible := uDietParams.Bagged; 357 end 358 else 359 with uDietParams, cboDelivery do 360 begin 361 if Tray then Items.Add('T^Tray'); 362 if Cafeteria then Items.Add('C^Cafeteria'); 363 if DiningRm then Items.Add('D^Dining Room'); 364 ItemIndex := 0; 365 chkBagged.Visible := uDietParams.Bagged; 366 end; 334 367 end; 335 368 TAccessibleStringGrid.WrapControl(grdSelected); … … 340 373 TAccessibleStringGrid.UnwrapControl(grdSelected); 341 374 TFClearGrid; 375 uRecurringMealList.Free; 342 376 inherited; 343 377 end; … … 350 384 ColWidths[1] := Canvas.TextWidth('XFULLX') + GetSystemMetrics(SM_CXVSCROLL); 351 385 ColWidths[2] := Canvas.TextWidth('100 GRAMS/HOUR X 24'); 352 ColWidths[3] := Canvas.TextWidth('55000 cc');386 ColWidths[3] := Canvas.TextWidth('55000ml'); 353 387 ColWidths[0] := ClientWidth - ColWidths[1] - ColWidths[2] - ColWidths[3] - 3; 354 388 lblTFStrength.Left := Left + ColWidths[0] + 3; … … 368 402 procedure TfrmODDiet.SetupDialog(OrderAction: Integer; const ID: string); 369 403 begin 404 if AbortOrder then exit; 370 405 inherited; 371 406 uDialogName := ExternalName(DialogIEN, 101.41); … … 396 431 end; 397 432 'T': begin 433 if (not OrderForInpatient) and (not PatientHasRecurringMeals(uRecurringMealList)) then 434 begin 435 Close; 436 Exit; 437 end; 398 438 nbkDiet.ActivePage := pgeTubefeeding; 399 439 nbkDietChange(Self); … … 401 441 end; 402 442 'E': begin 443 if (not OrderForInpatient) and (not PatientHasRecurringMeals(uRecurringMealList)) then 444 begin 445 Close; 446 Exit; 447 end; 403 448 nbkDiet.ActivePage := pgeEarlyLate; 404 449 nbkDietChange(Self); … … 411 456 end; 412 457 'A': begin 458 if (not OrderForInpatient) and (not PatientHasRecurringMeals(uRecurringMealList)) then 459 begin 460 Close; 461 Exit; 462 end; 413 463 nbkDiet.ActivePage := pgeAdditional; 414 464 nbkDietChange(Self); … … 442 492 nbkDietChange(Self); 443 493 if OrderAction <> ORDER_NEW then SetValuesFromResponsesDO; 494 ActiveControl := cboOPDietAvail; 444 495 end; 445 496 end; … … 517 568 end; 518 569 if Sum > 5000 then SetError(TX_TF5000); 570 if not OrderForInpatient then 571 if not calOPTFStart.IsValid then SetError(TX_BAD_START); 519 572 end; 520 573 if nbkDiet.ActivePage = pgeEarlyLate then 521 574 begin 522 575 if grpMeal.ItemIndex = 3 then SetError(TX_ELMEAL); 523 if GetMealTime = '' then SetError(TX_ELTIME);524 576 if not calELStart.IsValid then SetError(TX_ELNOSTART); 525 if not calELStop.IsValid then SetError(TX_ELNOSTOP);526 577 if calELStart.FMDateTime < FMToday then SetError(TX_ELSTARTLT); 527 if calELStop.FMDateTime < FMToday then SetError(TX_ELSTOPLT);528 if calELStop.FMDateTime < calELStart.FMDateTime then SetError(TX_ELSTOPSTART);529 578 if calELStart.FMDateTime > FMDateTimeOffsetBy(FMToday, 30) then SetError(TX_ELSTART30); 530 if calELStop.FMDateTime > FMDateTimeOffsetBy(FMToday, 30) then SetError(TX_ELSTOP30); 579 if OrderForInpatient then 580 begin 581 if GetMealTime = '' then SetError(TX_ELTIME); 582 if not calELStop.IsValid then SetError(TX_ELNOSTOP); 583 if calELStop.FMDateTime < FMToday then SetError(TX_ELSTOPLT); 584 if calELStop.FMDateTime < calELStart.FMDateTime then SetError(TX_ELSTOPSTART); 585 if calELStop.FMDateTime > FMDateTimeOffsetBy(FMToday, 30) then SetError(TX_ELSTOP30); 586 end; 531 587 if grpDOW.Enabled and (GetDaysOfWeek = '') then SetError(TX_ELDOW); 532 588 if MealTimePassed then SetError(TX_ELPAST); … … 539 595 begin 540 596 if not ContainsVisibleChar(txtAOComment.Text) then SetError(TX_AONONE); 541 end; 542 { TODO -oRich V. -cOutpatient Meals : Add any required Outpatient Meals validation code here } 597 if not OrderForInpatient then 598 if not calOPAOStart.IsValid then SetError(TX_BAD_START); 599 end; 543 600 if nbkDiet.ActivePage = pgeOutPt then 544 601 begin … … 580 637 FTabChanging := True; 581 638 if Length(memOrder.Text) > 0 then 582 if InfoBox(TX_ACCEPT + memOrder.Text, TC_ACCEPT, MB_YESNO) = ID_YES then 583 begin 584 cmdAcceptClick(Self); 585 AllowChange := AcceptOK; 586 end else 587 begin 588 memOrder.Text := ''; 589 memOrder.Lines.Clear; 590 Responses.Clear; 639 begin 640 if nbkDiet.ActivePage = pgeOutpt then 641 begin 642 if InfoBox(TX_CONTINUE + memOrder.Text + TX_DISCARD, TC_ACCEPT, MB_YESNO) = ID_YES then 643 begin 644 AllowChange := FALSE; 645 end else 646 begin 647 memOrder.Text := ''; 648 memOrder.Lines.Clear; 649 Responses.Clear; 650 end; 651 end 652 else 653 begin 654 if InfoBox(TX_ACCEPT + memOrder.Text, TC_ACCEPT, MB_YESNO) = ID_YES then 655 begin 656 cmdAcceptClick(Self); 657 AllowChange := AcceptOK; 658 end else 659 begin 660 memOrder.Text := ''; 661 memOrder.Lines.Clear; 662 Responses.Clear; 663 end; 664 end 591 665 end; 592 666 FTabChanging := False; … … 594 668 595 669 procedure TfrmODDiet.nbkDietChange(Sender: TObject); 670 var 671 x, CxMsg: string ; 672 i: integer; 673 AStringList: TStringList; 674 const 675 // TX_CX_CUR = 'A new diet order will CANCEL and REPLACE this current diet:' + CRLF + CRLF; 676 TX_CX_CUR = 'A new diet order will CANCEL and REPLACE this current diet now unless' + CRLF + 677 'you specify a start date for when the new diet should replace the current' + CRLF + 678 'diet:' + CRLF + CRLF; 679 TX_CX_FUT = 'A new diet order with no expiration date will CANCEL and REPLACE these diets:' + CRLF + CRLF; 596 680 begin 597 681 inherited; 598 682 // much of the logic here can be eliminated if ClearDialogControls starts clearing containers 683 if AbortOrder then 684 begin 685 cmdQuitClick(Self); 686 exit; 687 end; 599 688 StatusText('Loading Dialog Definition'); 600 689 if Sender <> Self then Responses.Clear; … … 603 692 begin 604 693 AllowQuickOrder := True; 605 OrderMessage(CurrentDietText); 694 x := CurrentDietText; 695 if Piece(x, #13, 1) <> 'Current Diet: ' then 696 begin 697 AStringList := TStringList.Create; 698 try 699 AStringList.Text := x; 700 CxMsg := TX_CX_CUR + #9 + Piece(AStringList[0], ':', 1) + ':' + CRLF + CRLF 701 + #9 + Copy(AStringList[0], 16, 99) + CRLF; 702 if AStringList.Count > 1 then 703 begin 704 CxMsg := CxMsg + CRLF + CRLF + 705 TX_CX_FUT + #9 + Piece(AStringList[1], ':', 1) + ':' + CRLF + CRLF 706 + #9 + Copy(AStringList[1], 22, 99) + CRLF; 707 if AStringList.Count > 2 then 708 for i := 2 to AStringList.Count - 1 do 709 CxMsg := CxMsg + #9 + TrimLeft(AStringList[i]) + CRLF; 710 end; 711 finally 712 AStringList.Free; 713 end; 714 end; 715 if CxMsg <> '' then 716 begin 717 if InfoBox(CxMsg + CRLF + 718 'Are you sure?', 'Confirm', MB_ICONWARNING or MB_YESNO) = ID_NO then 719 begin 720 AbortOrder := True; 721 cmdQuitClick(Self); 722 exit; 723 end; 724 end; 725 OrderMessage(x); 606 726 Responses.Dialog := 'FHW1'; // Diet Order 607 727 DisplayGroup := DisplayGroupForDialog('FHW1'); … … 615 735 if nbkDiet.ActivePage = pgeTubefeeding then 616 736 begin 617 { TODO -oRich V. -cOutpatient Meals : Prompt for which recurring meal(s) to apply this order against }618 737 if not OrderForInpatient then 619 738 begin 620 // get list of existing OP recurring meals 621 // if none, then exit with message 622 // if some, display and allow selection of multiple dates/times 623 // set different dialog/display group? 624 end; 739 if not PatientHasRecurringMeals(uRecurringMealList) then 740 begin 741 Changing := False; 742 nbkDiet.ActivePage := pgeOutPt; 743 nbkDietChange(nbkDiet); 744 Exit; 745 end 746 else 747 cboOPTFRecurringMeals.Items.Assign(uRecurringMealList); 748 end; 749 cboOPTFRecurringMeals.Visible := not OrderForInpatient; 750 calOPTFStart.Visible := False; 751 lblOPTFStart.Visible := not OrderForInpatient; 625 752 AllowQuickOrder := True; 626 753 if Length(uDietParams.CurTF) > 0 … … 644 771 if nbkDiet.ActivePage = pgeEarlyLate then 645 772 begin 646 { TODO -oRich V. -cOutpatient Meals : Prompt for which recurring meal to apply this order against }647 773 if not OrderForInpatient then 648 begin 649 // get list of existing OP recurring meals 650 // if none, then exit with message 651 // if some, display and allow selection of one and only one 652 // set different dialog/display group? 653 end 774 begin 775 if not PatientHasRecurringMeals(uRecurringMealList) then 776 begin 777 Changing := False; 778 nbkDiet.ActivePage := pgeOutPt; 779 nbkDietChange(nbkDiet); 780 Exit; 781 end 782 else 783 cboOPELRecurringMeals.Items.Assign(uRecurringMealList); 784 end 654 785 else if (StrToIntDef(uDietParams.EarlyIEN, 0) = 0) or (StrToIntDef(uDietParams.LateIEN, 0) = 0) then 655 begin 656 InfoBox(TX_NO_PARAMS, TC_NO_PARAMS, MB_ICONERROR or MB_OK); 657 if pgeEarlyLate <> nil then 658 nbkDiet.SelectNextPage(False); 659 Exit; 660 end; 786 begin 787 InfoBox(TX_NO_PARAMS, TC_NO_PARAMS, MB_ICONERROR or MB_OK); 788 if pgeEarlyLate <> nil then 789 nbkDiet.SelectNextPage(False); 790 Changing := False; 791 Exit; 792 end; 793 cboOPELRecurringMeals.Visible := not OrderForInpatient; 794 cboOPELRecurringMeals.TabStop := not OrderForInpatient; 795 calELStart.Visible := OrderForInpatient; 796 calELStart.TabStop := OrderForInpatient; 797 calELStop.Visible := OrderForInpatient; 798 lblELStop.Visible := OrderForInpatient; 799 grpDOW.Visible := OrderForInpatient; 800 grpDOW.Enabled := OrderForInpatient; 661 801 AllowQuickOrder := False; 662 802 OrderMessage(''); … … 678 818 if nbkDiet.ActivePage = pgeAdditional then 679 819 begin 680 { TODO -oRich V. -cOutpatient Meals : Prompt for which recurring meal(s) to apply this order against } 681 if not OrderForInpatient then 682 begin 683 // get list of existing OP recurring meals 684 // if none, then exit with message 685 // if some, display and allow selection of multiple dates/times 686 // set different dialog/display group? 687 end; 820 if not OrderForInpatient then 821 begin 822 if not PatientHasRecurringMeals(uRecurringMealList) then 823 begin 824 Changing := False; 825 nbkDiet.ActivePage := pgeOutPt; 826 nbkDietChange(nbkDiet); 827 Exit; 828 end 829 else 830 cboOPAORecurringMeals.Items.Assign(uRecurringMealList); 831 end; 832 cboOPAORecurringMeals.Visible := not OrderForInpatient; 833 calOPAOStart.Visible := False; //not OrderForInpatient; 834 lblOPAOStart.Visible := not OrderForInpatient; 688 835 AllowQuickOrder := False; 689 836 OrderMessage(''); … … 694 841 if nbkDiet.ActivePage = pgeOutPt then 695 842 begin 696 OrderMessage(CurrentDietText); 843 x := CurrentDietText; 844 if Length(Piece(x, #$D, 1)) > Length('Current Diet: ') then 845 OrderMessage(x) 846 else 847 OrderMessage(''); 848 if (uDialogName <> 'FHW SPECIAL MEAL') and (uDialogName <> 'FHW OP MEAL') then 849 uDialogName := 'FHW OP MEAL'; 697 850 Responses.Dialog := uDialogName; 698 851 DisplayGroup := DisplayGroupForDialog(uDialogName); 699 if uDialogName = 'FHW OP MEAL' then // Recurring meal 700 begin 701 AllowQuickOrder := True; 702 ResetControlsOP; 703 LoadDietQuickList(cboOPDietAvail.Items, 'MEAL'); // use D.G. short name here 704 cboOPDietAvail.InsertSeparator; 705 cboOPDietAvail.InitLongList(''); 706 { TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? } 707 chkOPCancelTubefeeding.State := cbGrayed; 708 chkOPCancelTubefeeding.Visible := False; 709 grpOPMeal.Caption := 'Recurring Meal'; 710 SetEnableOPDOW(False); 711 end 712 else if uDialogName = 'FHW SPECIAL MEAL' then // Special meal 852 if uDialogName = 'FHW SPECIAL MEAL' then // Special meal 713 853 begin 714 854 AllowQuickOrder := False; 715 855 ResetControlsOP; 716 cboOPDietAvail.I nitLongList('');856 cboOPDietAvail.Items.AddStrings(SubsetOfOPDiets); 717 857 { TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? } 718 858 chkOPCancelTubefeeding.State := cbGrayed; … … 723 863 pgeAdditional.TabVisible := False; 724 864 pgeEarlyLate.TabVisible := False; 725 cboOPDietAvail.SelectByIEN(uDietParams. RegIEN);865 cboOPDietAvail.SelectByIEN(uDietParams.OPDefaultDiet); 726 866 cboOPDietAvailMouseClick(Self); 867 Changing := False; 868 end 869 else if uDialogName = 'FHW OP MEAL' then // Recurring meal 870 begin 871 AllowQuickOrder := True; 872 ResetControlsOP; 873 LoadDietQuickList(cboOPDietAvail.Items, 'MEAL'); // use D.G. short name here 874 cboOPDietAvail.InsertSeparator; 875 cboOPDietAvail.Items.AddStrings(SubsetOfOPDiets); 876 cboOPDietAvail.SelectByIEN(uDietParams.OPDefaultDiet); 877 { TODO -oRich V. -cOutpatient Meals : Need to DC Tubefeeding order for OP meals? } 878 chkOPCancelTubefeeding.State := cbGrayed; 879 chkOPCancelTubefeeding.Visible := False; 880 grpOPMeal.Caption := 'Recurring Meal'; 881 SetEnableOPDOW(False, -1); 882 cboOPDietAvailMouseClick(Self); 883 Changing := False; 727 884 end; 728 885 end; … … 802 959 InfoBox(Piece(ADiet,'^',2), TC_DIET_ERR, MB_OK); 803 960 cboDietAvail.ItemIndex := -1; 961 Changing := False; 804 962 Exit; 805 963 end; … … 935 1093 TFClearGrid; 936 1094 chkCancelTrays.Checked := False; 1095 calOPTFStart.Text := ''; 937 1096 txtTFComment.Text := ''; 938 1097 end; … … 973 1132 AResponse := FindResponseByName('CANCEL', 1); 974 1133 if AResponse <> nil then chkCancelTrays.Checked := AResponse.IValue = '1'; 1134 if not OrderForInpatient then 1135 begin 1136 SetControl(cboOPTFRecurringMeals, 'DATETIME', 1); 1137 SetControl(calOPTFStart, 'DATETIME', 1); 1138 end; 975 1139 SetControl(txtTFComment, 'COMMENT', 1); 976 1140 end; … … 1114 1278 begin 1115 1279 grdSelected.Cells[2, ARow] := Piece(x, U, 2); 1116 grdSelected.Cells[3, ARow] := Piece(x, U, 1) + ' cc';1280 grdSelected.Cells[3, ARow] := Piece(x, U, 1) + 'ml'; 1117 1281 end 1118 1282 else grdSelected.Cells[3, ARow] := ''; … … 1268 1432 then Responses.Update('CANCEL', 1, '1', 'Yes') 1269 1433 else Responses.Update('CANCEL', 1, '0', 'No'); 1434 if not OrderForInpatient then 1435 begin 1436 calOPTFStart.FMDateTime := StrToFloatDef(cboOPTFRecurringMeals.ItemID, 0); 1437 Responses.Update('DATETIME', 1, FloatToStr(calOPTFStart.FMDateTime), calOPTFStart.Text); 1438 end; 1270 1439 memOrder.Text := Responses.OrderText; 1271 1440 end; … … 1323 1492 if radLT3.Caption = AResponse.IValue then radLT3.Checked := True; 1324 1493 end; 1325 SetControl(calELStart, 'START', 1); 1326 SetControl(calELStop, 'STOP', 1); 1494 if not OrderForInpatient then 1495 SetControl(cboOPELRecurringMeals, 'START', 1) 1496 else 1497 begin 1498 SetControl(calELStart, 'START', 1); 1499 SetControl(calELStop, 'STOP', 1); 1500 end; 1327 1501 calELStopChange(Self); 1328 1502 AResponse := FindResponseByName('SCHEDULE', 1); … … 1403 1577 lblNoTimes.Visible := not HasTimes; 1404 1578 end; 1405 1406 begin 1407 inherited; 1579 var 1580 AMeal: string; 1581 begin 1582 inherited; 1583 Changing := True; 1408 1584 case grpMeal.ItemIndex of 1409 0: SetMealTimes(uDietParams.BTimes); 1410 1: SetMealTimes(uDietParams.NTimes); 1411 2: SetMealTimes(uDietParams.ETimes); 1412 else SetMealTimes(''); 1413 end; 1585 0: begin 1586 SetMealTimes(uDietParams.BTimes); 1587 AMeal := 'B'; 1588 end; 1589 1: begin 1590 SetMealTimes(uDietParams.NTimes); 1591 AMeal := 'N'; 1592 end; 1593 2: begin 1594 SetMealTimes(uDietParams.ETimes); 1595 AMeal := 'E'; 1596 end; 1597 else 1598 begin 1599 SetMealTimes(''); 1600 AMeal := ''; 1601 end; 1602 end; 1603 if not OrderForInpatient then 1604 begin 1605 if AMeal = '' then 1606 begin 1607 uRecurringMealList.Clear; 1608 cboOPELRecurringMeals.Clear; 1609 end 1610 else if not PatientHasRecurringMeals(uRecurringMealList, AMeal) then 1611 begin 1612 uRecurringMealList.Clear; 1613 cboOPELRecurringMeals.Clear; 1614 grpMeal.ItemIndex := 3; 1615 end 1616 else 1617 cboOPELRecurringMeals.Items.Assign(uRecurringMealList); 1618 end; 1619 Changing := False; 1620 ELChange(grpMeal); 1414 1621 end; 1415 1622 … … 1445 1652 begin 1446 1653 inherited; 1447 if (Length(calELStop.Text) > 0) and (calELStop.Text = calELStart.Text) 1654 if not OrderForInpatient then SetEnableDOW(False) 1655 else if (Length(calELStop.Text) > 0) and (calELStop.Text = calELStart.Text) 1448 1656 then SetEnableDOW(False) 1449 1657 else SetEnableDOW(True); … … 1478 1686 then Responses.Update('ORDERABLE', 1, uDietParams.EarlyIEN, 'EARLY TRAY') 1479 1687 else Responses.Update('ORDERABLE', 1, uDietParams.LateIEN, 'LATE TRAY'); 1688 end; 1689 if not OrderForInpatient then 1690 begin 1691 calELStart.FMDateTime := StrToFloatDef(cboOPELRecurringMeals.ItemID, 0); 1692 calELStop.FMDateTime := calELStart.FMDateTime; 1480 1693 end; 1481 1694 with calELStart do if Length(Text) > 0 then Responses.Update('START', 1, Text, Text); … … 1525 1738 begin 1526 1739 txtAOComment.Text := ''; 1740 calOPAOStart.Text := ''; 1527 1741 end; 1528 1742 … … 1532 1746 ResetControlsAO; 1533 1747 Responses.SetControl(txtAOComment, 'COMMENT', 1); 1748 //Responses.SetControl(calOPAOStart, 'DATETIME', 1); 1749 Responses.SetControl(cboOPAORecurringMeals, 'DATETIME', 1); 1534 1750 Changing := False; 1535 1751 AOChange(Self); … … 1542 1758 with txtAOComment do if Text <> '' 1543 1759 then Responses.Update('COMMENT', 1, Text, Text); 1760 if not OrderForInpatient then 1761 begin 1762 calOPAOStart.FMDateTime := StrToFloatDef(cboOPAORecurringMeals.ItemID, 0); 1763 Responses.Update('DATETIME', 1, FloatToStr(calOPAOStart.FMDateTime), calOPAOStart.Text); 1764 end; 1544 1765 memOrder.Text := Responses.OrderText; 1545 1766 end; 1546 1767 1768 1547 1769 { Outpatient Meals Order tab ----------------------------------------------------------------- } 1548 1549 procedure TfrmODDiet.cboOPDietAvailNeedData(Sender: TObject; const StartFrom: string;1550 Direction, InsertAt: Integer);1551 begin1552 inherited;1553 cboOPDietAvail.ForDataUse(SubsetOfOPDiets(StartFrom, Direction));1554 end;1555 1770 1556 1771 procedure TfrmODDiet.cboOPDietAvailMouseClick(Sender: TObject); … … 1566 1781 begin 1567 1782 inherited; 1783 if cboOPDietAvail.Items.Count = 0 then 1784 begin 1785 InfoBox(TX_NO_MEALS_DEFINED, TC_NO_MEALS_DEFINED, MB_OK or MB_ICONINFORMATION); 1786 AbortOrder := True; 1787 exit; 1788 end ; 1568 1789 if CharAt(cboOPDietAvail.ItemID, 1) = 'Q' then // setup quick order 1569 1790 begin … … 1592 1813 OPChange(Sender); 1593 1814 end; {if cboOPDietAvail} 1815 OPChange(Sender); 1594 1816 cboOPDietAvail.ItemIndex := -1; 1595 OPChange(Sender);1596 1817 end; 1597 1818 … … 1643 1864 procedure TfrmODDiet.SetValuesFromResponsesOP; 1644 1865 var 1645 //AnInstance: Integer;1646 1866 AResponse: TResponse; 1647 1867 ADiet: string; … … 1651 1871 with Responses do 1652 1872 begin 1653 (* AnInstance := NextInstance('ORDERABLE', 0);1654 while AnInstance > 0 do1655 begin1656 AResponse := FindResponseByName('ORDERABLE', AnInstance);1657 if AResponse <> nil then1658 begin1659 ADiet := DietAttributes(StrToIntDef(AResponse.IValue,0));1660 if Piece(ADiet,'^',1)='0' then1661 begin1662 InfoBox(Piece(ADiet,'^',2), TC_OP_DIET_ERR, MB_OK);1663 cboOPDietAvail.ItemIndex := -1;1664 Exit;1665 end;1666 lstOPDietSelect.Items.Add(ADiet);1667 end;1668 AnInstance := NextInstance('ORDERABLE', AnInstance);1669 end; {while AnInstance - ORDERABLE}*)1670 1671 1873 AResponse := FindResponseByName('ORDERABLE', 1); 1672 1874 if AResponse <> nil then … … 1677 1879 InfoBox(Piece(ADiet,'^',2), TC_OP_DIET_ERR, MB_OK); 1678 1880 cboOPDietAvail.ItemIndex := -1; 1881 Changing := False; 1679 1882 Exit; 1680 1883 end; … … 1721 1924 begin 1722 1925 inherited; 1926 if Changing then exit; 1723 1927 if FChangeStop then 1724 1928 calOPStop.Text := calOPStart.Text … … 1727 1931 end; 1728 1932 1933 function TfrmODDiet.FMDOW(AnFMDate: TFMDateTime): integer; 1934 var 1935 WinDate: TDateTime; 1936 x: integer; 1937 begin 1938 WinDate := FMDateTimeToDateTime(AnFMDate); 1939 x := DayOfTheWeek(WinDate); 1940 Result := x; 1941 end; 1942 1943 function TfrmODDiet.FMDays(AStart, AEnd: TFMDateTime): string; 1944 var 1945 AWinStart, AWinEnd: TDateTime; 1946 i: double; 1947 Days: string; 1948 begin 1949 AWinStart := FMDateTimeToDateTime(AStart); 1950 AWinEnd := FMDateTimeToDateTime(AEnd); 1951 i := AWinStart; 1952 repeat 1953 Days := Days + FMDayLetters[DayOfTheWeek(i)]; 1954 i := i + 1; 1955 until i > AWinEnd; 1956 Result := Days; 1957 end; 1958 1729 1959 procedure TfrmODDiet.calOPStartExit(Sender: TObject); 1730 begin 1731 inherited; 1732 if (Length(calOPStop.Text) > 0) and (calOPStop.Text = calOPStart.Text) 1733 then SetEnableOPDOW(False) 1734 else SetEnableOPDOW(True); 1960 var 1961 Days: string; 1962 begin 1963 inherited; 1964 if not (calOPStart.FMDateTime > 0) then 1965 begin 1966 SetEnableOPDOW(False, -1); 1967 Exit ; 1968 end; 1969 if (Length(calOPStop.Text) > 0) and (calOPStop.Text = calOPStart.Text) then 1970 SetEnableOPDOW(False, FMDOW(calOPStart.FMDateTime)) 1971 else 1972 begin 1973 Days := FMDays(calOPStart.FMDateTime, calOPStop.FMDateTime); 1974 SetEnableOPDOW(True, -1, Days); 1975 end; 1735 1976 end; 1736 1977 1737 1978 procedure TfrmODDiet.calOPStopChange(Sender: TObject); 1738 begin 1739 inherited; 1740 if (Length(calOPStop.Text) > 0) and (calOPStop.FMDateTime = calOPStart.FMDateTime) 1741 then SetEnableOPDOW(False) 1742 else SetEnableOPDOW(True); 1979 var 1980 Days: string; 1981 begin 1982 inherited; 1983 if Changing then exit; 1984 if not (calOPStop.FMDateTime > 0) then 1985 begin 1986 SetEnableOPDOW(False, -1); 1987 Exit ; 1988 end; 1989 if (Length(calOPStop.Text) > 0) and (calOPStop.FMDateTime = calOPStart.FMDateTime) then 1990 SetEnableOPDOW(False, FMDOW(calOPStart.FMDateTime)) 1991 else 1992 begin 1993 Days := FMDays(calOPStart.FMDateTime, calOPStop.FMDateTime); 1994 SetEnableOPDOW(True, -1, Days); 1995 end; 1743 1996 OPChange(Sender); 1744 1997 end; … … 1752 2005 if Changing then Exit; 1753 2006 if Sender <> Self then Responses.Clear; // Sender=Self when called from SetupDialog 1754 // Per NFS, only one selection allowed from any of 5 available OP diets2007 // Per NFS, only one selection allowed from any of 10-15 available OP diets 1755 2008 with lstOPDietSelect do if Items.Count > 0 then 1756 2009 Responses.Update('ORDERABLE', 1, Piece(Items[0], U, 1), Piece(Items[0], U, 2)); … … 1765 2018 begin 1766 2019 x := GetOPDaysOfWeek; 1767 if Length(x) > 0 then Responses.Update('SCHEDULE', 1, x, x); 2020 if Length(x) = 0 then x := 'ONCE'; 2021 Responses.Update('SCHEDULE', 1, x, x); 1768 2022 end; 1769 2023 with txtOPDietComment do {if Length(Text) > 0 then} Responses.Update('COMMENT', 1, Text, Text); … … 1784 2038 end; 1785 2039 1786 procedure TfrmODDiet.SetEnableOPDOW(AllowUse: Boolean); 1787 begin 2040 procedure TfrmODDiet.SetEnableOPDOW(AllowUse: Boolean; OneTimeDay: integer; DaysToCheck: string = ''); 2041 var 2042 i: integer; 2043 begin 2044 if (not AllowUse) and (OneTimeDay > -1) then 2045 begin 2046 for i := 0 to grpOPDOW.ControlCount - 1 do 2047 begin 2048 if grpOPDOW.Controls[i] is TCheckBox then 2049 TCheckBox(grpOPDOW.Controls[i]).Checked := False; 2050 end; 2051 //TCheckBox(grpOPDOW.Controls[OneTimeDay - 1]).Checked := True; CQ #8305 2052 end; 1788 2053 grpOPDOW.Enabled := AllowUse; 1789 chkOPMonday.Enabled := AllowUse ;1790 chkOPTuesday.Enabled := AllowUse ;1791 chkOPWednesday.Enabled := AllowUse ;1792 chkOPThursday.Enabled := AllowUse ;1793 chkOPFriday.Enabled := AllowUse ;1794 chkOPSaturday.Enabled := AllowUse ;1795 chkOPSunday.Enabled := AllowUse ;2054 chkOPMonday.Enabled := AllowUse and (Pos('M', DaysToCheck) > 0); 2055 chkOPTuesday.Enabled := AllowUse and (Pos('T', DaysToCheck) > 0); 2056 chkOPWednesday.Enabled := AllowUse and (Pos('W', DaysToCheck) > 0); 2057 chkOPThursday.Enabled := AllowUse and (Pos('R', DaysToCheck) > 0); 2058 chkOPFriday.Enabled := AllowUse and (Pos('F', DaysToCheck) > 0); 2059 chkOPSaturday.Enabled := AllowUse and (Pos('S', DaysToCheck) > 0); 2060 chkOPSunday.Enabled := AllowUse and (Pos('X', DaysToCheck) > 0); 1796 2061 end; 1797 2062 … … 1896 2161 // check if late tray should be ordered 1897 2162 AResponse := Responses.FindResponseByName('ORDERABLE', 1); 1898 if ( AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then2163 if (Self.EvtID = 0) and (AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then 1899 2164 begin 1900 2165 AResponse := Responses.FindResponseByName('START', 1); … … 1915 2180 // check if late tray should be ordered 1916 2181 AResponse := Responses.FindResponseByName('ORDERABLE', 1); 1917 if ( AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then2182 if (Self.EvtID = 0) and (AResponse <> nil) and (Copy(AResponse.EValue, 1, 3) <> 'NPO') then 1918 2183 begin 1919 2184 AResponse := Responses.FindResponseByName('START', 1); … … 1930 2195 if NewOrder.ID <> '' then 1931 2196 begin 1932 if (Encounter.Provider = User.DUZ) and User.CanSignOrders 1933 then CanSign := CH_SIGN_YES 1934 else CanSign := CH_SIGN_NA; 2197 if OrderForInpatient then 2198 begin 2199 if (Encounter.Provider = User.DUZ) and User.CanSignOrders 2200 then CanSign := CH_SIGN_YES 2201 else CanSign := CH_SIGN_NA; 2202 end 2203 else 2204 begin 2205 CanSign := CH_SIGN_NA; 2206 end; 1935 2207 Changes.Add(CH_ORD, NewOrder.ID, NewOrder.Text, '', CanSign); 1936 2208 SendMessage(Application.MainForm.Handle, UM_NEWORDER, ORDER_NEW, Integer(NewOrder)) … … 1955 2227 end; 1956 2228 2229 procedure TfrmODDiet.cboOPDietAvailKeyDown(Sender: TObject; var Key: Word; 2230 Shift: TShiftState); 2231 begin 2232 inherited; 2233 if Key = VK_RETURN then cboOPDietAvailMouseClick(Self); 2234 end; 2235 2236 function TfrmODDiet.PatientHasRecurringMeals(var MealList: TStringList; MealType: string = ''): boolean; 2237 const 2238 TX_NO_RECURRING_MEALS = 'For outpatients, this type of order requires association with an existing recurring' + CRLF + 2239 'meal order. There are currently no active recurring meal orders for this patient.' + CRLF + CRLF + 2240 'Those orders must be signed and released before they can be linked to this item.'; 2241 TC_NO_RECURRING_MEALS = 'Unable to order ' ; 2242 begin 2243 MealList.Clear; 2244 GetCurrentRecurringOPMeals(MealList, MealType); 2245 if MealList.Count = 0 then 2246 begin 2247 InfoBox(TX_NO_RECURRING_MEALS, TC_NO_RECURRING_MEALS + nbkDiet.ActivePage.Caption, MB_OK); 2248 Result := False; 2249 end 2250 else 2251 Result := True; 2252 end; 2253 1957 2254 end. 1958 2255
Note:
See TracChangeset
for help on using the changeset viewer.