Procedure

TfrmODMedNVA.ChangeDelayed

Module

fODMedNVA

Last Modified

7/15/2014 3:26:42 PM

Comments

Selection

Visibility

Private

Owner

TfrmODMedNVA

Declaration

procedure ChangeDelayed;

Calls Hierarchy


TfrmODMedNVA.ChangeDelayed
 ├TfrmODMedNVA.FindQuickOrder
 ├IndexOfOrderable
 ├TfrmODMedNVA.isUniqueQuickOrder
 └TfrmODMedNVA.ScrollToVisible

Called-By Hierarchy


     TfrmODMedNVA.ChangeDelayed
         TfrmODMedNVA.WMTimer┤ 
      TfrmODMedNVA.txtMedExit┤ 
   TfrmODMedNVA.ShowMedSelect┘ 
    TfrmODMedNVA.InitDialog┤   
  TfrmODMedNVA.FormCreate┘ │   
TfrmODMedNVA.btnSelectClick┘   
TfrmODMedNVA.UMDelayClick┘     

Calls

Name Declaration Comments
TfrmODMedNVA.FindQuickOrder function FindQuickOrder(const x: string): Integer; -
IndexOfOrderable function IndexOfOrderable(ListIEN: Integer; From: string): Integer; -
TfrmODMedNVA.isUniqueQuickOrder function isUniqueQuickOrder(iText: string): Boolean; -
TfrmODMedNVA.ScrollToVisible procedure ScrollToVisible(AListView: TListView); -

Called-By

Name Declaration Comments
TfrmODMedNVA.ShowMedSelect procedure ShowMedSelect; -
TfrmODMedNVA.txtMedExit procedure txtMedExit(Sender: TObject); -
TfrmODMedNVA.WMTimer procedure WMTimer(var Message: TWMTimer); message WM_TIMER; -


Source

656   procedure TfrmODMedNVA.ChangeDelayed;
657   var
658     QuickIndex, AllIndex: Integer;
659     NewText, OldText, UserText: string;
660     UniqueText: Boolean;
661   begin
662     FRemoveText := False;
663     UniqueText := False;
664     FChangePending := False;
665     if (Length(txtMed.Text) > 0) and (txtMed.SelStart = 0) then Exit;  // don't lookup null
666     // lookup item in appropriate list box
667     NewText := '';
668     UserText := Copy(txtMed.Text, 1, txtMed.SelStart);
669     QuickIndex := FindQuickOrder(UserText);
670     AllIndex := IndexOfOrderable(FCacheIEN, UserText);  // but always synch the full list
671     if UserText <> Copy(txtMed.Text, 1, txtMed.SelStart) then Exit;  // if typing during lookup
672     if AllIndex > -1 then
673     begin
674       lstAll.Selected := lstAll.Items[AllIndex];
675       FActiveMedList := lstAll;
676     end;
677     if QuickIndex > -1 then
678     begin
679       try
680         lstQuick.Selected := lstQuick.Items[QuickIndex];
681         lstQuick.ItemFocused := lstQuick.Selected;
682         NewText := lstQuick.Selected.Caption;
683         FActiveMedList := lstQuick;
684         //Search Quick List for Uniqueness
685         UniqueText := isUniqueQuickOrder(UserText);
686       except
687         //doing nothing  short term solution related to 117
688       end;
689     end
690     else if AllIndex > -1 then
691     begin
692       lstAll.Selected := lstAll.Items[AllIndex];
693       lstAll.ItemFocused := lstAll.Selected;
694       NewText := lstAll.Selected.Caption;
695       lstQuick.Selected := nil;
696       FActiveMedList := lstAll;
697       //List is alphabetical, So compare next Item in list to establish uniqueness.
698       if CompareText(UserText, Copy(lstAll.Items[AllIndex+1].Caption, 1, Length(UserText))) <> 0 then
699         UniqueText := True;
700     end
701     else
702     begin
703       lstQuick.Selected := nil;
704       lstAll.Selected := nil;
705       FActiveMedList := lstAll;
706       NewText := txtMed.Text;
707     end;
708     if (AllIndex > -1) and (QuickIndex > -1) then  //Not Unique Between Lists
709       UniqueText := False;
710     FFromSelf := True;
711     if UniqueText then
712     begin
713       OldText := Copy(txtMed.Text, 1, txtMed.SelStart);
714       txtMed.Text := NewText;
715       //txtMed.SelStart := Length(OldText);  // v24.14 RV
716       txtMed.SelStart := Length(UserText);   // v24.14 RV
717       txtMed.SelLength := Length(NewText);
718     end
719     else begin
720       txtMed.Text := UserText;
721       txtMed.SelStart := Length(txtMed.Text);
722     end;
723     FFromSelf := False;
724     if lstAll.Selected <> nil then
725       ScrollToVisible(lstAll);
726     if lstQuick.Selected <> nil then
727       ScrollToVisible(lstQuick);
728     if Not UniqueText then
729     begin
730       lstQuick.ItemIndex := -1;
731       lstAll.ItemIndex := -1;
732     end;
733     FRemoveText := True;
734   end;