Changeset 829 for cprs/trunk/CPRS-Chart/Orders/fODMedNVA.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/Orders/fODMedNVA.pas
r456 r829 6 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 7 7 fODBase, StdCtrls, ComCtrls, ExtCtrls, ORCtrls, Grids, Buttons, uConst, ORDtTm, 8 Menus, XUDIGSIGSC_TLB, rMisc, uOrders, StrUtils, oRFn; 8 Menus, XUDIGSIGSC_TLB, rMisc, uOrders, StrUtils, oRFn, contnrs, 9 VA508AccessibilityManager; 9 10 10 11 const … … 94 95 private 95 96 {selection} 96 FAllItems: TStringList; 97 FAllFirst: Integer; 98 FAllLast: Integer; 99 FAllList: Integer; 97 FNVAMedCache: TObjectList; 98 FCacheIEN: integer; 100 99 FQuickList: Integer; 101 100 FQuickItems: TStringList; … … 135 134 FQOInitial: boolean; 136 135 FRemoveText : Boolean; 136 FMedName: string; 137 137 {selection} 138 138 procedure ChangeDelayed; … … 140 140 function FindQuickOrder(const x: string): Integer; 141 141 function isUniqueQuickOrder(iText: string): Boolean; 142 function GetCacheChunkIndex(idx: integer): integer; 142 143 procedure ScrollToVisible(AListView: TListView); 143 144 procedure StartKeyTimer; … … 180 181 procedure SetupDialog(OrderAction: Integer; const ID: string); override; 181 182 procedure CheckDecimal(var AStr: string); 183 property MedName: string read FMedName write FMedName; 182 184 end; 183 185 … … 194 196 195 197 uses rCore, uCore, rODMeds, rODBase, rOrders, fRptBox, fODMedOIFA, 196 uAccessibleStringGrid, fFrame, ORNet;198 fFrame, ORNet, VAUtils; 197 199 198 200 const … … 259 261 TIMER_FROM_DAYS = 1; 260 262 TIMER_FROM_QTY = 2; 263 264 MED_CACHE_CHUNK_SIZE = 100; 261 265 {text constants} 262 266 TX_ADMIN = 'Requested Start: '; … … 346 350 FRowHeight := MainFontHeight + 1; 347 351 x := 'NV RX'; // CLA 6/3/03 348 ListForOrderable(F AllList, ListCount, x);352 ListForOrderable(FCacheIEN, ListCount, x); 349 353 lstAll.Items.Count := ListCount; 350 FAllItems := TStringList.Create; 351 FAllFirst := -1; 352 FAllLast := -1; 354 FNVAMedCache := TObjectList.Create; 353 355 FQuickItems := TStringList.Create; 354 356 ListForQuickOrders(FQuickList, ListCount, x); … … 370 372 then Height := (((Height - 6) div VisibleRowCount) * ListCount) + 6; 371 373 pnlFields.Height := cmdAccept.Top - 4 - pnlFields.Top; 374 cmdAccept.Left := cmdQuit.Left; 375 cmdaccept.Anchors := cmdQuit.anchors; 372 376 FNoZero := False; 373 377 FShrinked := False; … … 382 386 {selection} 383 387 FQuickItems.Free; 384 F AllItems.Free;388 FNVAMedCache.Free; 385 389 {edit} 386 390 FGuideline.Free; … … 553 557 end; 554 558 end; 559 if Pos(U, self.memComment.Text) > 0 then SetError('Comments cannot contain a "^".'); 555 560 end; 556 561 … … 659 664 UserText := Copy(txtMed.Text, 1, txtMed.SelStart); 660 665 QuickIndex := FindQuickOrder(UserText); 661 AllIndex := IndexOfOrderable(F AllList, UserText); // but always synch the full list666 AllIndex := IndexOfOrderable(FCacheIEN, UserText); // but always synch the full list 662 667 if UserText <> Copy(txtMed.Text, 1, txtMed.SelStart) then Exit; // if typing during lookup 663 668 if AllIndex > -1 then … … 772 777 { lstAll Methods (lstAll is TListView) } 773 778 779 // Cache is a list of 100 string lists, starting at idx 0 774 780 procedure TfrmODMedNVA.LoadNonVAMedCache(First, Last: Integer); 775 const 776 MAX_CACHE_ITEMS = 1000; 777 begin 778 // if range is within cache range we don't need to update anything 779 if (First >= FAllFirst) and (Last <= FAllLast) then Exit; 780 // if range is outside of cache or a superset of cache, start over 781 if (Last < Pred(FAllFirst)) or (First > Succ(FAllLast)) or 782 ((First < FAllFirst) and (Last > FAllLast)) or 783 (FAllItems.Count > MAX_CACHE_ITEMS) then 784 begin 785 FAllItems.Clear; 786 FAllFirst := -1; 787 FAllLast := -1; 788 end; 789 // if getting items immediately before cache range 790 if (First < FAllFirst) and (Last >= FAllFirst) then Last := Pred(FAllFirst); 791 // if getting items immediately after cache range 792 if (Last > FAllLast) and (First <= FAllLast) then First := Succ(FAllLast); 793 // retrieve the items and append (First>FAllLast) or prepend them to FAllItems 794 SubsetOfOrderable(FAllItems, First>FAllLast, FAllList, First, Last); 795 // reset FAllFirst & FAllLast indexes to reflect current FAllItems 796 if FAllFirst < 0 then FAllFirst := First; 797 if FAllLast < 0 then FAllLast := Last; 798 if First < FAllFirst then FAllFirst := First; 799 if Last > FAllLast then FAllLast := Last; 781 var 782 firstChunk, lastchunk, i: integer; 783 list: TStringList; 784 firstMed, LastMed: integer; 785 786 begin 787 firstChunk := GetCacheChunkIndex(First); 788 lastChunk := GetCacheChunkIndex(Last); 789 for i := firstChunk to lastChunk do 790 begin 791 if (FNVAMedCache.Count <= i) or (not assigned(FNVAMedCache[i])) then 792 begin 793 while FNVAMedCache.Count <= i do 794 FNVAMedCache.add(nil); 795 list := TStringList.Create; 796 FNVAMedCache[i] := list; 797 firstMed := i * MED_CACHE_CHUNK_SIZE; 798 LastMed := firstMed + MED_CACHE_CHUNK_SIZE - 1; 799 if LastMed >= lstAll.Items.Count then 800 LastMed := lstAll.Items.Count - 1; 801 SubsetOfOrderable(list, false, FCacheIEN, firstMed, lastMed); 802 end; 803 end; 800 804 end; 801 805 … … 803 807 var 804 808 x: string; 805 begin 806 if (FAllFirst = -1) or (Item.Index < FAllFirst) or (Item.Index > FAllLast) 807 then LoadNonVAMedCache(Item.Index, Item.Index); 808 x := FAllItems[Item.Index - FAllFirst]; 809 chunk: integer; 810 list: TStringList; 811 begin 812 LoadNonVAMedCache(Item.Index, Item.Index); 813 chunk := GetCacheChunkIndex(Item.Index); 814 list := TStringList(FNVAMedCache[chunk]); 815 x := list[Item.Index mod MED_CACHE_CHUNK_SIZE]; 809 816 Item.Caption := Piece(x, U, 2); 810 817 Item.Data := Pointer(StrToIntDef(Piece(x, U, 1), 0)); … … 822 829 var 823 830 MedIEN: Integer; 824 MedName: string;831 //MedName: string; 825 832 QOQuantityStr: string; 826 ErrMsg : string;833 ErrMsg, temp: string; 827 834 begin 828 835 inherited; 829 836 QOQuantityStr := ''; 830 btnSelect.SetFocus; // let the exit events finish 837 btnSelect.SetFocus; 838 self.MedName := ''; // let the exit events finish 831 839 if pnlMeds.Visible then // display the medication fields 832 840 begin … … 845 853 //btnSelect.Visible := False; 846 854 btnSelect.Enabled := False; 847 ShowM essage(ErrMsg);855 ShowMsg(ErrMsg); 848 856 Exit; 849 857 end; … … 862 870 begin 863 871 MedIEN := Integer(lstAll.Selected.Data); 864 MedName := lstAll.Selected.Caption;872 self.MedName := lstAll.Selected.Caption; 865 873 txtMed.Tag := MedIEN; 866 874 ErrMsg := ''; … … 869 877 begin 870 878 btnSelect.Enabled := False; 871 ShowM essage(ErrMsg);879 ShowMsg(ErrMsg); 872 880 Exit; 873 881 end; … … 882 890 begin 883 891 txtMed.Tag := MedIEN; 884 txtMed.Text := MedName; 892 temp := self.MedName; 893 self.MedName := txtMed.Text; 894 txtMed.Text := Temp; 885 895 end; 886 896 SetOnMedSelect; … … 918 928 var 919 929 i,j: Integer; 920 x: string;930 temp,x: string; 921 931 QOPiUnChk: boolean; 922 932 PKIEnviron: boolean; … … 933 943 // set up lists & initial values based on orderable item 934 944 SetControl(txtMed, 'Medication'); 945 if (self.MedName <> '') then 946 begin 947 if (txtMed.Text <> self.MedName) then 948 begin 949 temp := self.MedName; 950 self.MedName := txtMed.Text; 951 txtMed.Text := temp; 952 end 953 else MedName := ''; 954 end; 935 955 SetControl(cboDosage, 'Dosage'); 936 956 SetControl(cboRoute, 'Route'); … … 1044 1064 else 1045 1065 SetDosage(IValueFor('INSTR', 1)); 1046 SetControl(cboDosage, 'DOSAGE', 1); // CQ: HDS00007776 1047 SetSchedule(IValueFor('SCHEDULE', 1)); 1066 SetControl(cboDosage, 'DOSAGE', 1); // CQ: HDS00007776 1067 SetControl(cboRoute, 'ROUTE', 1); //AGP ADDED ROUTE FOR CQ 11252 1068 SetSchedule(IValueFor('SCHEDULE', 1)); 1048 1069 if (cboSchedule.Text = '') and FIsQuickOrder then 1049 1070 begin … … 1613 1634 FUpdated := FALSE; 1614 1635 Responses.Clear; 1615 Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), txtMed.Text); 1636 if self.MedName = '' then Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), txtMed.Text) 1637 else Responses.Update('ORDERABLE', 1, IntToStr(txtMed.Tag), self.MedName); 1616 1638 DoseList := TStringList.Create; 1617 1639 case tabDose.TabIndex of … … 1729 1751 Schedule <TAB> (nothing) 1730 1752 Duration <TAB> Duration^Units } 1753 1754 // the following functions were created to get rid of a compile warning saying the 1755 // return value may be undefined - too much branching logic in the case statements 1756 // for the compiler to handle 1757 1758 function GetSchedule: string; 1759 begin 1760 Result := UpperCase(cboSchedule.Text); 1761 if chkPRN.Checked then Result := Result + ' PRN'; 1762 if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' 1763 then Result := Copy(Result, 1, Length(Result) - 4); 1764 end; 1765 1766 function GetScheduleEX: string; 1767 begin 1768 Result := ''; 1769 with cboSchedule do 1770 if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 2); 1771 if (Length(Result) > 0) and chkPRN.Checked then Result := Result + ' AS NEEDED'; 1772 if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' 1773 then Result := Copy(Result, 1, Length(Result) - 10); 1774 end; 1775 1731 1776 begin 1732 1777 Result := ''; … … 1763 1808 if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 4); 1764 1809 FLD_SCHEDULE : begin 1765 Result := UpperCase(cboSchedule.Text); 1766 if chkPRN.Checked then Result := Result + ' PRN'; 1767 if UpperCase(Copy(Result, Length(Result) - 6, Length(Result))) = 'PRN PRN' 1768 then Result := Copy(Result, 1, Length(Result) - 4); 1810 Result := GetSchedule; 1769 1811 end; 1770 1812 FLD_SCHED_EX : begin 1771 with cboSchedule do 1772 if ItemIndex > -1 then Result := Piece(Items[ItemIndex], U, 2); 1773 if (Length(Result) > 0) and chkPRN.Checked then Result := Result + ' AS NEEDED'; 1774 if UpperCase(Copy(Result, Length(Result) - 18, Length(Result))) = 'AS NEEDED AS NEEDED' 1775 then Result := Copy(Result, 1, Length(Result) - 10); 1813 Result := GetScheduleEX; 1776 1814 end; 1777 1815 FLD_SCHED_TYP : with cboSchedule do … … 2184 2222 end; 2185 2223 2224 function TfrmODMedNVA.GetCacheChunkIndex(idx: integer): integer; 2225 begin 2226 Result := idx div MED_CACHE_CHUNK_SIZE; 2227 end; 2228 2186 2229 procedure TfrmODMedNVA.lstQuickData(Sender: TObject; Item: TListItem); 2187 2230 var … … 2209 2252 tmplst.Strings[i] := Piece(s,U,2); 2210 2253 end; 2211 Dest.Assign(tmplst);2254 FastAssign(tmplst, Dest); 2212 2255 end; 2213 2256 end;
Note:
See TracChangeset
for help on using the changeset viewer.