Procedure

TfrmODBBank.SetupDialog

Directives

Override

Module

fODBBank

Last Modified

7/15/2014 3:26:40 PM

Visibility

Public

Overrides

TfrmODBase.SetupDialog

Owner

TfrmODBBank

Declaration

procedure SetupDialog(OrderAction: Integer; const ID: string); override;

Calls Hierarchy


TfrmODBBank.SetupDialog
 ├TfrmODBBank.ReadServerVariables
 │ └TfrmODBase.GetKeyVariable
 ├TResponses.NextInstance
 ├TResponses.FindResponseByName
 ├GetSubtype
 ├TResponses.SetControl
 │ ├TResponses.FindResponseByName
 │ └AssignBPText
 │   ├DisplayGroupToLinkType
 │   │ └DisplayGroupByName
 │   ├TResponses.EValueFor
 │   ├GetServiceIEN
 │   ├TResponses.IValueFor
 │   ├GetProcedureIEN
 │   ├ExpandOrderObjects
 │   │ ├TdmodShared.BoilerplateOK
 │   │ │ ├ErrCount
 │   │ │ ├AddErr
 │   │ │ └TdmodShared.LoadTIUObjects
 │   │ │   └GetObjectList
 │   │ └GetTemplateText
 │   │   └TEncounter.GetVisitStr
 │   │     └TEncounter.GetVisitCategory
 │   ├SetTemplateDialogCanceled
 │   ├CheckBoilerplate4Fields
 │   ├ExecuteTemplateOrBoilerPlate
 │   └WasTemplateDialogCanceled
 ├TfrmODBBank.cboAvailTestSelect
 │ ├TfrmODBBank.DisableComponentControls
 │ ├TfrmODBBank.EnableDiagTestControls
 │ ├TLabTest.Create
 │ │ ├LoadLabTestData
 │ │ ├GetOneSpecimen
 │ │ ├TLabTest.FillCollSampList
 │ │ ├TResponses.FindResponseByName
 │ │ ├TLabTest.IndexOfCollSamp
 │ │ ├GetOneCollSamp
 │ │ ├TLabTest.LoadAllSamples
 │ │ │ ├LoadSamples
 │ │ │ └TLabTest.FillCollSampList
 │ │ └TLabTest.SetCollSampDflts
 │ │   ├TResponses.FindResponseByName
 │ │   ├TLabTest.ChangeSpecimen
 │ │   └TLabTest.IndexOfCollSamp
 │ ├GetSubtype
 │ ├TfrmODBBank.DetermineCollectionDefaults
 │ │ ├TResponses.FindResponseByName
 │ │ ├TLabTest.LabCanCollect
 │ │ │ └TLabTest.IndexOfCollSamp
 │ │ ├TfrmODBBank.SetupCollTimes
 │ │ │ ├GetLastCollectionTime
 │ │ │ ├TfrmODBBank.ValidCollTime
 │ │ │ │ └StrToFMDateTime
 │ │ │ ├StrToFMDateTime
 │ │ │ ├RemoveCollTimeDefault
 │ │ │ ├TCtrlInits.SetControl
 │ │ │ │ ├ClearControl
 │ │ │ │ └TCtrlInits.FindInitByName
 │ │ │ ├MakeRelativeDateTime
 │ │ │ │ └FMToday
 │ │ │ │   └FMNow
 │ │ │ └GetDefaultImmCollTime
 │ │ ├TCtrlInits.SetControl...
 │ │ ├StrToFMDateTime
 │ │ └TfrmODBBank.LoadCollType
 │ │   ├TCtrlInits.SetControl...
 │ │   ├TLabTest.LabCanCollect...
 │ │   ├TfrmODBase.OrderForInpatient
 │ │   │ ├OrderEventTypeOnCreate
 │ │   │ └IsPassEvt1
 │ │   └TfrmODBBank.SetupCollTimes...
 │ ├TfrmODBBank.lvSelectionListClick
 │ │ ├StrToFMDateTime
 │ │ ├TLabTest.Create...
 │ │ ├TfrmODBBank.DisableDiagTestControls
 │ │ ├TfrmODBBank.EnableComponentControls
 │ │ │ └TResponses.Update
 │ │ │   ├TResponses.FindResponseByName
 │ │ │   └TResponses.IENForPrompt
 │ │ ├TfrmODBBank.DisableComponentControls
 │ │ └TfrmODBBank.EnableDiagTestControls
 │ ├TfrmODBBank.ExtractTypeScreen
 │ ├TNSDaysBack
 │ ├TLabTest.ObtainCollSamp
 │ ├TLabTest.IndexOfCollSamp
 │ ├TfrmODBase.OrderMessage
 │ │ └TfrmODBase.ShowOrderMessage
 │ ├TResponses.Update...
 │ ├TfrmODBBank.ValidCollTime...
 │ └TResponses.GetOrderText
 │   ├TResponses.NextInstance
 │   ├TResponses.FindResponseByName
 │   ├TResponses.FormatResponse
 │   │ └TResponses.FindResponseByIEN
 │   └TResponses.AppendChildren
 │     ├TResponses.FindPromptByIEN
 │     ├TResponses.FindResponseByIEN
 │     └TResponses.FormatResponse...
 ├TLabTest.Create...
 ├TfrmODBBank.cboUrgencyChange
 │ ├TResponses.Update...
 │ └TResponses.GetOrderText...
 ├TfrmODBBank.DisableComponentControls
 ├TfrmODBBank.EnableDiagTestControls
 ├TfrmODBBank.ExtractTypeScreen
 ├TResponses.Update...
 ├TfrmODBBank.ValidCollTime...
 ├TResponses.GetOrderText...
 ├TLabTest.ObtainCollSamp
 ├TLabTest.IndexOfCollSamp
 ├TfrmODBase.OrderMessage...
 ├TfrmODBBank.DisableDiagTestControls
 ├TfrmODBBank.EnableComponentControls...
 ├TfrmODBBank.ExtractTests
 ├GetPatientBloodResults
 ├GetPatientBloodResultsRaw
 ├TfrmODBBank.SpecimenNeeded
 │ └TfrmODBBank.ExtractSpecimen
 ├TfrmODBBank.ExtractSpecimens
 ├TfrmODBBank.cboSurgeryChange
 │ ├TfrmODBBank.ExtractTypeScreen
 │ ├TLabTest.Create...
 │ ├TfrmODBBank.ExtractMSBOS
 │ ├TResponses.Update...
 │ ├TfrmODBBank.DisableComponentControls
 │ └TResponses.GetOrderText...
 ├TNSDaysBack
 ├TfrmODBBank.lvSelectionListClick...
 └TfrmODBBank.btnRemoveClick
   ├TfrmODBBank.ExtractTypeScreen
   ├TResponses.Clear
   ├TfrmODBBank.InitDialog
   │ ├TLabTest.Destroy
   │ └TfrmODBBank.DisableCommentPanels
   ├TResponses.Update...
   ├TfrmODBBank.ValidCollTime...
   └TResponses.GetOrderText...

Calls

Name Declaration Comments
TfrmODBBank.btnRemoveClick procedure btnRemoveClick(Sender: TObject); -
TfrmODBBank.cboAvailTestSelect procedure cboAvailTestSelect(Sender: TObject); -
TfrmODBBank.cboSurgeryChange procedure cboSurgeryChange(Sender: TObject); -
TfrmODBBank.cboUrgencyChange procedure cboUrgencyChange(Sender: TObject); -
TLabTest.Create constructor Create(const LabTestIEN: string; Responses: TResponses); -
TfrmODBBank.DisableComponentControls procedure DisableComponentControls; -
TfrmODBBank.DisableDiagTestControls procedure DisableDiagTestControls; -
TfrmODBBank.EnableComponentControls procedure EnableComponentControls; -
TfrmODBBank.EnableDiagTestControls procedure EnableDiagTestControls; -
TfrmODBBank.ExtractSpecimens procedure ExtractSpecimens(OutList:TStrings; AList:TStrings); -
TfrmODBBank.ExtractTests procedure ExtractTests(OutList:TStrings; AList:TStrings); -
TfrmODBBank.ExtractTypeScreen procedure ExtractTypeScreen(OutList:TStrings; AList:TStrings); -
TResponses.FindResponseByName function FindResponseByName(const APromptID: string; AnInstance: Integer): TResponse; -
TResponses.GetOrderText function GetOrderText: string; -
GetPatientBloodResults procedure GetPatientBloodResults(Dest: TStrings; PatientID: string; ATests: TStringList); -
GetPatientBloodResultsRaw procedure GetPatientBloodResultsRaw(Dest: TStrings; PatientID: string; ATests: TStringList); -
GetSubtype function GetSubtype(TestName: string): string; -
TLabTest.IndexOfCollSamp function IndexOfCollSamp(CollSampIEN: Integer): Integer; -
TfrmODBBank.lvSelectionListClick procedure lvSelectionListClick(Sender: TObject); -
TResponses.NextInstance function NextInstance(const APromptID: string; LastInstance: Integer): Integer; -
TLabTest.ObtainCollSamp function ObtainCollSamp: Boolean; -
TfrmODBase.OrderMessage procedure OrderMessage(const AMessage: string); -
TfrmODBBank.ReadServerVariables procedure ReadServerVariables; -
TResponses.SetControl procedure SetControl(AControl: TControl; const APromptID: string; AnInstance: Integer); -
TfrmODBBank.SpecimenNeeded function SpecimenNeeded(OutList:TStrings; AList:TStrings; CompID:integer): Boolean; -
TNSDaysBack function TNSDaysBack: integer; -
TResponses.Update procedure Update(const APromptID: string; AnInstance: Integer; const AnIValue, AnEValue: string); -
TfrmODBBank.ValidCollTime function ValidCollTime(UserEntry: string): string; -


Source

458   procedure TfrmODBBank.SetupDialog(OrderAction: Integer; const ID: string);
459   var
460     AnInstance, CurAdd: Integer;
461     AResponse: TResponse;
462     i, j, k, aTNS, getTest, TestAdded, aMSBOSContinue: integer;
463     aStr, aTestYes, aName, aTypeScreen, aSpecimen, aSpecimenUID, aSpecimenReq, aModifier, sub, sub1, x, aTNSString, aUrgText: string;
464     ListItem: TListItem;
465     aList, cList: TStringList;
466     aTests: TStringList;
467     xLabTest: TLabTest;
468     aGotTNS : Boolean;
469   begin
470     inherited;
471     aList := TStringList.Create;
472     cList := TStringList.Create;
473     aTests:= TStringList.Create;
474     aGotTNS := false;
475     try
476     FOrderAction := OrderAction;
477     ReadServerVariables;
478     sub1 := '';
479     aTypeScreen := '';
480     aSpecimen := '';
481     aSpecimenUID := '';
482     aSpecimenReq := '';
483     aModifier := '';
484     if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses, ALabTest do
485       begin
486         pgeProduct.ActivePageIndex := TI_COMPONENT;
487         AnInstance := NextInstance('ORDERABLE', 0);
488         while AnInstance > 0 do
489           begin
490             AResponse := FindResponseByName('ORDERABLE', AnInstance);
491             if AResponse <> nil then
492               begin
493                 sub := GetSubtype(AResponse.EValue);
494                 if sub = 't' then
495                   begin
496                     SetControl(cboAvailTest,        'ORDERABLE', AnInstance);
497                     changing := true;
498                     cboAvailTestSelect(Self);
499                     changing := false;
500                   end
501                 else
502                   begin
503                     SetControl(cboAvailComp,        'ORDERABLE', AnInstance);
504                     ALabTest := TLabTest.Create(cboAvailComp.ItemID, Responses);
505                   end;
506                 if ALabTest = nil then Exit;  // Causes access violation
507                 if AnInstance = 1 then
508                   begin
509                     SetControl(cboReasons,         'REASON' , AnInstance);
510                     SetControl(calWantTime,        'DATETIME', AnInstance);
511                     SetControl(memDiagComment,     'COMMENT', AnInstance);
512                     SetControl(chkConsent,         'YN', AnInstance);
513                     //DetermineCollectionDefaults(Responses);
514                     SetControl(cboSurgery,         'MISC', AnInstance);
515                     SetControl(cboUrgency,         'URGENCY', AnInstance);
516                     if cboUrgency.ItemIEN = 0 then
517                       begin
518                         if StrToIntDef(LRFURG, 0) > 0 then
519                           cboUrgency.SelectByID(LRFURG)
520                         else if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
521                           cboUrgency.ItemIndex := 0;
522                       end;
523                     Urgency := cboUrgency.ItemIEN;
524                     if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
525                       begin
526                         cboUrgency.ItemIndex := 0;
527                         Urgency := cboUrgency.ItemIEN;
528                       end;
529                     i := 1 ;
530                     AResponse := Responses.FindResponseByName('COMMENT',i);
531                     while AResponse <> nil do
532                       begin
533                         Comment.Add(AResponse.EValue);
534                         Inc(i);
535                         AResponse := Responses.FindResponseByName('COMMENT',i);
536                       end ;
537                     cboUrgencyChange(self);
538                   end;
539                 if sub = 't' then with ALabTest do      //DIAGNOSTIC TEST
540                   begin
541                     Changing := True;
542                     DisableComponentControls;
543                     EnableDiagTestControls;
544                     LRORDERMODE := TORDER_MODE_DIAG;
545                     //DetermineCollectionDefaults(Responses);
546                     aList.Clear;
547                     aTestYes := '1';
548                     ExtractTypeScreen(aList, uVBECList);
549                     if aList.Count > 0 then aTypeScreen := aList[0];
550                     aList.Clear;
551                     if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
552                     if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
553                       else
554                         begin
555                           cboUrgency.ItemIndex := 2;
556                           for i := 0 to cboUrgency.Items.Count - 1 do
557                             begin
558                               aUrgText := cboUrgency.Items[i];
559                               if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
560                                 begin
561                                   cboUrgency.ItemIndex := i;
562                                   break;
563                                 end;
564                             end;
565                           Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
566                           cboUrgencyChange(self);
567                         end;
568                     if Length(memDiagComment.Text) > 0 then Responses.Update('COMMENT',1,memDiagComment.Text,memDiagComment.Text);
569                     if Length(cboReasons.Text) > 0 then Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
570                     memOrder.Text := Responses.OrderText;
571                     Changing := False;
572                     if ObtainCollSamp then
573                       begin
574                         //For BloodBank orders, this condition should never occur
575                       end
576                     else
577                       begin
578                         with ALabTest do
579                           with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
580                             begin
581                               x := '' ;
582                               for i := 0 to WardComment.Count-1 do
583                               x := x + WardComment.strings[i]+#13#10 ;
584                               pnlMessage.TabOrder := cboAvailTest.TabOrder + 1;
585                               OrderMessage(x) ;
586                             end ;
587                       end;
588                   end;
589                 if sub = 'c' then with ALabTest do  //COMPONENT
590                   begin
591                     Changing := True;
592                     DisableDiagTestControls;
593                     EnableComponentControls;
594                     aTestYes := '0';
595                     LRORDERMODE := TORDER_MODE_COMP;
596                     SetControl(cboModifiers,       'MODIFIER', AnInstance);
597                     SetControl(tQuantity,          'QTY', AnInstance);
598                     uComponentSelected := true;
599                     aList.Clear;
600                     TestAdded := 0;
601                     getTest := 0;
602                     ExtractTests(aList, uVBECList);   //Get Results associated with ordered components
603                       for j := 0 to aList.Count - 1 do
604                         begin
605                           if StrToInt(piece(aList[j],'^',1)) = aLabTest.ItemID then
606                             begin
607                               if uTestsForResults.Count < 1 then getTest := 1;
608                               for k := 0 to uTestsForResults.Count - 1 do
609                                 begin
610                                   if piece(uTestsForResults[k],'^',1) = piece(aList[j],'^',3) then
611                                     begin
612                                       getTest := 0;
613                                       break;
614                                     end
615                                   else getTest := 1;
616                                 end;
617                               if getTest = 1 then
618                                 begin
619                                   uTestsForResults.Add(piece(aList[j],'^',3));
620                                   TestAdded := 1;
621                                 end;
622                             end;
623                         end;
624                       if TestAdded = 1 then
625                         begin
626                           aTests.Clear;
627                           GetPatientBloodResults(aTests, Patient.DFN, uTestsForResults);
628                           if aTests.Count > 0 then
629                             begin
630                               edtResults.Clear;
631                               QuickCopy(ATests,edtResults);
632                               TabResults.Caption := 'Lab Results Available';
633                               uRaw.Clear;
634                               GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
635                             end;
636                         end;
637                       CurAdd := 1;
638                       if uRaw.Count > 0 then
639                       for j := 0 to uRaw.Count - 1 do
640                         begin
641                           if Length(uRaw[j]) > 0 then Responses.Update('RESULTS', CurAdd, uRaw[j], piece(uRaw[j],'^',1));
642                           Inc(CurAdd);
643                         end;
644                     for i := lvSelectionList.Items.Count - 1 downto 0 do
645                       begin
646                         if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
647                           begin
648                             aGotTNS := true;
649                             break;
650                           end;
651                       end;
652                     if (uTNSOrders.Count < 1) and (aGotTNS = false) and (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then  //check to see if type and screen is needed CQ 17349
653                       begin
654                         uGetTnS := 1;
655                       end;
656                     if aList.Count > 0 then
657                       begin
658                         aSpecimen := piece(aList[0], '^',1);
659                         aSpecimenUID := piece(aList[0], '^',2);
660                       end;
661                     aList.Clear;
662                     ExtractSpecimens(aList, uVBECList);    //Get specimen values to pass back to Server
663                     for i := 0 to aList.Count - 1 do
664                       begin
665                         if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID) then
666                           begin
667                             aSpecimenReq := piece(aList[i],'^',2);
668                             if (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then
669                               aSpecimenUID := '';
670                             break;
671                           end;
672                       end;
673                     with lvSelectionList do
674                       begin
675                         ListItem := Items.Add;
676                         ListItem.Caption := piece(cboAvailComp.Items[cboAvailComp.ItemIndex],'^',2);
677                         ListItem.SubItems.Add(tQuantity.Text);
678                         if length(cboModifiers.ItemID) > 0 then
679                           begin
680                             ListItem.SubItems.Add(cboModifiers.Items[cboModifiers.ItemIndex]);
681                             ListItem.SubItems.Add(IntToStr(cboModifiers.ItemIndex));
682                           end
683                           else
684                             begin
685                               ListItem.SubItems.Add('');
686                               ListItem.SubItems.Add('');
687                             end;
688                         ListItem.SubItems.Add(piece(cboAvailComp.Items[cboAvailComp.ItemIndex],'^',1));
689                       end;
690                     aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
691                     uSelectedItems.Add(aStr);
692                     memOrder.Text := Responses.OrderText;
693                     Changing := False;
694                     if (Length(cboSurgery.Text) > 0) then
695                       begin
696                         for i := 0 to cboSurgery.Items.Count - 1 do
697                           if uppercase(cboSurgery.Text) = uppercase(piece(cboSurgery.Items[i],'^',2)) then
698                             begin
699                               cboSurgery.ItemIndex := i;
700                               Break;
701                             end;
702                         cboSurgeryChange(self);
703                       end;
704                   end;
705               end;
706             StatusText('');
707             AnInstance := NextInstance('ORDERABLE', AnInstance);
708           end;  //while AnInstance - ORDERABLE
709         DisableComponentControls;
710         DisableDiagTestControls;
711       end;
712       cList.Clear;
713       if (Length(cboSurgery.ItemID) > 0) then
714         begin
715           for j := 0 to uSelectedItems.Count - 1 do
716             begin
717               xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
718               if (piece(uSelectedItems[j],'^',1) = '0') and (not(piece(uSelectedItems[j],'^',3)='')) and (StrToInt(piece(uSelectedItems[j],'^',3)) > 0) and (piece(cboSurgery.Items[cboSurgery.ItemIndex],'^',3) = '1') then
719                 begin
720                   cList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3));
721                 end;
722               xLabTest.Free;
723             end;
724         end;
725       if (uChangingMSBOS = false) and (cList.Count > 0) then
726         begin
727           lblNoBloodReq.Visible := true;
728           with Application do
729             begin
730               NormalizeTopMosts;
731               aMSBOSContinue :=
732                 MessageBox(PChar('No blood is required for the surgical procedure: ' + cboSurgery.text +
733                  '.' + CRLF +
734                  'If you still need to order any components, please enter a justification in the Comment box.'
735                   + CRLF + CRLF + 'Do you want me to remove ALL the component orders you''ve just entered? '),
736                  PChar('No Blood Required'),MB_YESNO);
737               RestoreTopMosts;
738             end;
739           if aMSBOSContinue = 6 then
740             begin
741               tQuantity.Text := '';
742               for j := uSelectedItems.Count - 1 downto 0 do
743                 begin
744                   if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
745                     begin
746                       lvSelectionList.Items[j].Delete;
747                       uSelectedItems.Delete(j);
748                       Responses.Update('ORDERABLE', (j+1) ,'', '');
749                       Responses.Update('MODIFIER', (j+1), '', '');
750                       Responses.Update('QTY', (j+1), '', '');
751                     end;
752                 end;
753               cboAvailComp.Text := '';
754               cboAvailComp.ItemIndex := -1;
755               cboModifiers.Text := '';
756               cboModifiers.ItemIndex := -1;
757               lblNoBloodReq.Visible := false;
758               //if fODBBank. Active then cboAvailTest.SetFocus;
759               lblTNS.Caption := '';
760               lblTNS.Visible := false;
761               DisableComponentControls;
762             end;
763         end;
764         for i := 0 to lvSelectionList.Items.Count - 1 do
765           begin
766             if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
767               begin
768                 uGetTnS := 0;
769                 aGotTNS := true;
770                 uDfltUrgency := cboUrgency.ItemID;
771                 lblTNS.Caption := '';
772                 lblTNS.Visible := false;
773                 memMessage.Text := '';
774                 pnlMessage.Visible := false;
775                 pnlDiagnosticTests.Caption := 'Diagnostic Tests';
776                 if uTNSOrders.Count > 0 then
777                   begin
778                     for j := 0 to uTNSOrders.Count - 1 do
779                       aTNSString := aTNSString + CRLF + uTNSOrders[j];
780                     with Application do
781                       begin
782                         NormalizeTopMosts;
783                         aTNS :=
784                           MessageBox(PChar(aTNSString + CRLF + CRLF +
785                              'Do you wish to cancel this request for Type & Screen?'),
786                              PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
787                              MB_YESNO);
788                         RestoreTopMosts;
789                         if aTNS = 6 then
790                           begin
791                             lvSelectionList.ItemIndex := i;
792                             lvSelectionListClick(self);
793                             btnRemoveClick(self);
794                             break;
795                           end;
796                       end;
797                   end;
798                 break;
799               end;
800           end;
801         if uSelectedItems.Count < 1 then uGetTNS := 0;
802   
803         for i := uSelectedItems.Count - 1 downto 0 do
804           begin
805             if (aGotTNS = false) and not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
806               begin
807                 uGetTnS := 1;
808                 break;
809               end;
810           end;
811   
812       CurAdd := 1;
813       for i := 0 to uSelectedItems.Count - 1 do
814         begin
815           aName := lvSelectionList.Items[i].Caption;
816           x := uSelectedItems[i];
817           if piece(x,'^',1) = '1' then    //Diagnostic Test related fields
818             begin
819               if Length(piece(x,'^',2)) > 0 then Responses.Update('ORDERABLE', CurAdd, piece(x,'^',2), aName);
820             end
821           else
822             begin
823               if Length(piece(x,'^',2)) > 0 then Responses.Update('ORDERABLE', CurAdd, piece(x,'^',2), aName);
824               if Length(piece(x,'^',3)) > 0 then Responses.Update('QTY', CurAdd, piece(x,'^',3), piece(x,'^',3));
825               if Length(piece(x,'^',4)) > 0 then Responses.Update('MODIFIER', CurAdd, piece(x,'^',4), piece(x,'^',4));
826               if Length(piece(x,'^',5)) > 0 then Responses.Update('SPECSTS', CurAdd, pieces(x,'^',5,7), piece(x,'^',5));
827               if Length(cboSurgery.Text) > 0 then Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
828               if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
829               if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
830                 else
831                   begin
832                     cboUrgency.ItemIndex := 2;
833                     for j := 0 to cboUrgency.Items.Count - 1 do
834                       begin
835                         aUrgText := cboUrgency.Items[j];
836                         if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
837                           begin
838                             cboUrgency.ItemIndex := j;
839                             break;
840                           end;
841                       end;
842                     Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
843                     cboUrgencyChange(self);
844                   end;
845             end;
846           Inc(CurAdd);
847         end;
848       if uGetTnS = 1 then
849         begin
850           lblTNS.Caption := 'TYPE + SCREEN must be added to order';
851           lblTNS.Visible := true;
852           memMessage.Text := 'TYPE + SCREEN must be added to order';
853           pnlMessage.Visible := true;
854           pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
855         end
856         else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
857     finally
858       aList.Free;
859       cList.Free;
860       aTests.Free;
861     end;
862     if lvSelectionList.Items.Count > 0 then
863       begin
864         pnlSelectedTests.Visible := True;
865         cmdAccept.Visible := True;
866         memOrder.Visible := True;
867         GroupBox1.Visible := False;
868         lvSelectionList.Items[0].Selected := true;
869         lvSelectionListClick(self);
870       end;
871   end;