Index: cprs/trunk/CPRS-Chart/Orders/fODBBank.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Orders/fODBBank.pas	(revision 829)
+++ cprs/trunk/CPRS-Chart/Orders/fODBBank.pas	(revision 1679)
@@ -57,6 +57,8 @@
     txtImmedColl: TCaptionEdit;
     pnlCollTimeButton: TKeyClickPanel;
+    lblTNS: TLabel;
+    lblNoBloodReq: TLabel;
     cmdImmedColl: TSpeedButton;
-    lblTNS: TLabel;
+    Splitter1: TSplitter;
     procedure FormCreate(Sender: TObject);
     procedure cboAvailTestSelect(Sender: TObject);
@@ -97,8 +99,23 @@
     procedure cboModifiersChange(Sender: TObject);
     procedure lvSelectionListClick(Sender: TObject);
-    procedure cboAvailCompChange(Sender: TObject);
     procedure cboCollTimeChange(Sender: TObject);
     procedure memDiagCommentChange(Sender: TObject);
     procedure cboUrgencyExit(Sender: TObject);
+    procedure pnlBloodComponentsEnter(Sender: TObject);
+    procedure pnlDiagnosticTestsEnter(Sender: TObject);
+    procedure pnlDiagnosticTestsExit(Sender: TObject);
+    procedure pnlBloodComponentsExit(Sender: TObject);
+    procedure pnlBloodComponentsClick(Sender: TObject);
+    procedure pnlDiagnosticTestsClick(Sender: TObject);
+    procedure cboCollTypeClick(Sender: TObject);
+    procedure cboAvailTestEnter(Sender: TObject);
+    procedure cboCollTypeEnter(Sender: TObject);
+    procedure txtImmedCollEnter(Sender: TObject);
+    procedure calCollTimeEnter(Sender: TObject);
+    procedure cboCollTimeEnter(Sender: TObject);
+    procedure cboModifiersEnter(Sender: TObject);
+    procedure calWantTimeEnter(Sender: TObject);
+    procedure cboAvailCompEnter(Sender: TObject);
+    procedure FormShow(Sender: TObject);
   protected
     FCmtTypes: TStringList ;
@@ -244,4 +261,5 @@
   ALabTest: TLabTest;
   UserHasLRLABKey: boolean;
+  uChangingMSBOS: boolean;
   LRFZX     : string;  //the default collection type  (LC,WC,SP,I)
   LRFSAMP   : string;  //the default sample           (ptr)
@@ -293,4 +311,5 @@
   uSelUrgency := '';
   uSelSurgery := 0;
+  uChangingMSBOS := false;
   TabResults.Caption := 'Lab Results';
   edtResults.Lines.Clear;
@@ -314,4 +333,18 @@
     UserHasLRLABKey := User.HasKey('LRLAB');
     AllowQuickOrder := True;
+    if GetDiagnosticPanelLocation then
+      begin
+        pnlDiagnosticTests.Left := 0;
+        pnlBloodComponents.Left := (pnlDiagnosticTests.Width + 10);
+        pnlDiagnosticTests.TabOrder := 0;
+        pnlBloodComponents.TabOrder := 1;
+      end
+    else
+      begin
+        pnlBloodComponents.Left := 0;
+        pnlDiagnosticTests.Left := (pnlBloodComponents.Width + 10);
+        pnlBloodComponents.TabOrder := 0;
+        pnlDiagnosticTests.TabOrder := 1;
+      end;
     StatusText('Loading Dialog Definition');
     FCmtTypes := TStringList.Create;
@@ -342,9 +375,11 @@
       else
         cboCollType.SelectByID('SP');
-      SetupCollTimes(cboCollType.ItemID);
-      StatusText('Initializing List of Tests');
-      FVbecLookup := 'S.VBT';
-      cboAvailTest.InitLongList('');      //Populates cboAvailTest control based on S.VBT xref
-    end;
+      //SetupCollTimes(cboCollType.ItemID);
+    end;
+    cboAvailTest.Clear;
+    aList.Clear;
+    GetDiagnosticTests(aList);            //Get Tests in right order
+    for i := 0 to aList.Count - 1 do
+      cboAvailTest.Items.Add(aList[i]);
     cboAvailComp.Clear;
     aList.Clear;
@@ -365,5 +400,5 @@
     AList.Clear;
     ExtractUrgencies(uUrgencyList, uVBECList);
-    ExtractTNSOrders(uTNSOrders, uVBECList);
+    if not(self.EvtID > 0) then ExtractTNSOrders(uTNSOrders, uVBECList);
     LoadUrgencies(cboUrgency);
     ExtractModifiers(uModifierList, uVBECList);
@@ -371,5 +406,4 @@
     LoadModifiers(cboModifiers);
     LoadReasons(cboReasons);
-    calWantTime.Text := 'NOW'; //FormatFMDateTime('mmm dd,yyyy@hh:nn',DateTimeToFMDateTime(Now));
     pgeProduct.TabIndex := TI_INFO;
     lvSelectionList.Column[0].Width := 240;
@@ -378,4 +412,5 @@
     DisableComponentControls;
     DisableDiagTestControls;
+    pnlDiagnosticTests.Caption := 'Diagnostic Tests';
     pgeProduct.ActivePageIndex := TI_INFO;
     StatusText('');
@@ -425,13 +460,17 @@
   AnInstance, CurAdd: Integer;
   AResponse: TResponse;
-  i, j, k, aTNS, aTNSDays, getTest, TestAdded: integer;
-  aStr, aTestYes, aName, aTypeScreen, aSpecimen, aModifier, sub, sub1, x, aTNSString: string;
+  i, j, k, aTNS, getTest, TestAdded, aMSBOSContinue: integer;
+  aStr, aTestYes, aName, aTypeScreen, aSpecimen, aSpecimenUID, aSpecimenReq, aModifier, sub, sub1, x, aTNSString, aUrgText: string;
   ListItem: TListItem;
-  aList: TStringList;
+  aList, cList: TStringList;
   aTests: TStringList;
+  xLabTest: TLabTest;
+  aGotTNS : Boolean;
 begin
   inherited;
   aList := TStringList.Create;
+  cList := TStringList.Create;
   aTests:= TStringList.Create;
+  aGotTNS := false;
   try
   FOrderAction := OrderAction;
@@ -439,8 +478,11 @@
   sub1 := '';
   aTypeScreen := '';
-  aSpecimen := '^';
+  aSpecimen := '';
+  aSpecimenUID := '';
+  aSpecimenReq := '';
   aModifier := '';
   if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses, ALabTest do
     begin
+      pgeProduct.ActivePageIndex := TI_COMPONENT;
       AnInstance := NextInstance('ORDERABLE', 0);
       while AnInstance > 0 do
@@ -453,5 +495,7 @@
                 begin
                   SetControl(cboAvailTest,        'ORDERABLE', AnInstance);
-                  ALabTest := TLabTest.Create(cboAvailTest.ItemID, Responses);
+                  changing := true;
+                  cboAvailTestSelect(Self);
+                  changing := false;
                 end
               else
@@ -468,9 +512,13 @@
                   SetControl(chkConsent,         'YN', AnInstance);
                   //DetermineCollectionDefaults(Responses);
-                  SetControl(cboCollType,        'COLLECT', AnInstance);
-                  SetControl(cboCollTime,        'START', AnInstance);
-                  SetupCollTimes(cboCollType.ItemID);
+                  SetControl(cboSurgery,         'MISC', AnInstance);
                   SetControl(cboUrgency,         'URGENCY', AnInstance);
-                  SetControl(cboSurgery,         'MISC', AnInstance);
+                  if cboUrgency.ItemIEN = 0 then
+                    begin
+                      if StrToIntDef(LRFURG, 0) > 0 then
+                        cboUrgency.SelectByID(LRFURG)
+                      else if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
+                        cboUrgency.ItemIndex := 0;
+                    end;
                   Urgency := cboUrgency.ItemIEN;
                   if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
@@ -487,4 +535,5 @@
                       AResponse := Responses.FindResponseByName('COMMENT',i);
                     end ;
+                  cboUrgencyChange(self);
                 end;
               if sub = 't' then with ALabTest do      //DIAGNOSTIC TEST
@@ -494,4 +543,5 @@
                   EnableDiagTestControls;
                   LRORDERMODE := TORDER_MODE_DIAG;
+                  //DetermineCollectionDefaults(Responses);
                   aList.Clear;
                   aTestYes := '1';
@@ -499,74 +549,23 @@
                   if aList.Count > 0 then aTypeScreen := aList[0];
                   aList.Clear;
-                  with lvSelectionList do
-                    begin
-                      ListItem := Items.Add;
-                      ListItem.Caption := piece(cboAvailTest.Items[cboAvailTest.ItemIndex],'^',2);
-                      ListItem.SubItems.Add('');
-                      ListItem.SubItems.Add('');
-                      ListItem.SubItems.Add('');
-                      ListItem.SubItems.Add(piece(cboAvailTest.Items[cboAvailTest.ItemIndex],'^',1));
-                      if piece(cboAvailTest.Items[cboAvailTest.ItemIndex],'^',1) = aTypeScreen then
-                        begin
-                          lblTNS.Caption := '';
-                          lblTNS.Visible := false;
-                          memMessage.Text := '';
-                          pnlMessage.Visible := false;
-                          uGetTnS := 0;
-                          pnlDiagnosticTests.Caption := 'Diagnostic Tests';
-                        end;
-                    end;
-                  aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces additional pieces added for Tests
-                  uSelectedItems.Add(aStr);
                   if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
-                  {with cboCollType do if Length(ItemID) > 0 then
-                    begin
-                      Responses.Update('COLLECT', 1, ItemID, ItemID) ;
-                      FLastCollType := ItemID;
-                    end;  }
-                  if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
+                  if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
+                    else
+                      begin
+                        cboUrgency.ItemIndex := 2;
+                        for i := 0 to cboUrgency.Items.Count - 1 do
+                          begin
+                            aUrgText := cboUrgency.Items[i];
+                            if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
+                              begin
+                                cboUrgency.ItemIndex := i;
+                                break;
+                              end;
+                          end;
+                        Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
+                        cboUrgencyChange(self);
+                      end;
                   if Length(memDiagComment.Text) > 0 then Responses.Update('COMMENT',1,memDiagComment.Text,memDiagComment.Text);
                   if Length(cboReasons.Text) > 0 then Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
-                  LoadCollType(cboCollType);
-                  if (cboCollType.ItemID = 'LC') or (cboCollType.ItemID = 'I') then
-                    if not(ALabTest.LabCanCollect) and OrderForInpatient then
-                      cboCollType.SelectByID('WC')
-                    else if not(ALabTest.LabCanCollect) then
-                      cboCollType.SelectByID('SP');
-                  SetupCollTimes(cboCollType.ItemID);
-                  if cboCollType.ItemID = 'LC' then
-                    begin
-                      with cboCollTime do
-                        if Length(ItemID) > 0 then
-                          begin
-                            Responses.Update('START', 1, Copy(ItemID, 2, 999), Copy(ItemID, 2, 999));
-                            FLastLabCollTime := ItemID + U + Text;
-                          end
-                        else if Length(Text) > 0 then
-                          begin
-                            Responses.Update('START', 1, ValidCollTime(Text), Text) ;
-                            FLastLabCollTime := ValidCollTime(Text);
-                          end;
-                    end
-                  else
-                    begin
-                      with calCollTime do
-                        if FMDateTime > 0 then
-                          begin
-                            Responses.Update('START', 1, ValidCollTime(Text), Text);
-                            FLastColltime := ValidCollTime(Text);
-                          end
-                        else
-                          begin
-                            Responses.Update('START', 1, '', '') ;
-                            FLastCollTime := '';
-                          end;
-                    end;
-                  with cboCollType do if Length(ItemID) > 0 then
-                    begin
-                      Responses.Update('COLLECT', 1, ItemID, ItemID) ;
-                      FLastCollType := ItemID;
-                    end;
-                  //if Length(cboCollType.Text) > 0 then Responses.Update('COLLECT',1,cboCollType.ItemID,cboCollType.ItemID);
                   memOrder.Text := Responses.OrderText;
                   Changing := False;
@@ -625,11 +624,14 @@
                     if TestAdded = 1 then
                       begin
-                        edtResults.Clear;
                         aTests.Clear;
                         GetPatientBloodResults(aTests, Patient.DFN, uTestsForResults);
-                        QuickCopy(ATests,edtResults);
-                        if edtResults.Lines.Count > 0 then TabResults.Caption := 'Lab Results Available'; //TabResults.ImageIndex := 1;
-                        uRaw.Clear;
-                        GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+                        if aTests.Count > 0 then
+                          begin
+                            edtResults.Clear;
+                            QuickCopy(ATests,edtResults);
+                            TabResults.Caption := 'Lab Results Available';
+                            uRaw.Clear;
+                            GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+                          end;
                       end;
                     CurAdd := 1;
@@ -640,4 +642,33 @@
                         Inc(CurAdd);
                       end;
+                  for i := lvSelectionList.Items.Count - 1 downto 0 do
+                    begin
+                      if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
+                        begin
+                          aGotTNS := true;
+                          break;
+                        end;
+                    end;
+                  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
+                    begin
+                      uGetTnS := 1;
+                    end;
+                  if aList.Count > 0 then
+                    begin
+                      aSpecimen := piece(aList[0], '^',1);
+                      aSpecimenUID := piece(aList[0], '^',2);
+                    end;
+                  aList.Clear;
+                  ExtractSpecimens(aList, uVBECList);    //Get specimen values to pass back to Server
+                  for i := 0 to aList.Count - 1 do
+                    begin
+                      if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID) then
+                        begin
+                          aSpecimenReq := piece(aList[i],'^',2);
+                          if (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then
+                            aSpecimenUID := '';
+                          break;
+                        end;
+                    end;
                   with lvSelectionList do
                     begin
@@ -657,8 +688,18 @@
                       ListItem.SubItems.Add(piece(cboAvailComp.Items[cboAvailComp.ItemIndex],'^',1));
                     end;
-                  aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces additional pieces added for Tests
+                  aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
                   uSelectedItems.Add(aStr);
                   memOrder.Text := Responses.OrderText;
                   Changing := False;
+                  if (Length(cboSurgery.Text) > 0) then
+                    begin
+                      for i := 0 to cboSurgery.Items.Count - 1 do
+                        if uppercase(cboSurgery.Text) = uppercase(piece(cboSurgery.Items[i],'^',2)) then
+                          begin
+                            cboSurgery.ItemIndex := i;
+                            Break;
+                          end;
+                      cboSurgeryChange(self);
+                    end;
                 end;
             end;
@@ -669,4 +710,104 @@
       DisableDiagTestControls;
     end;
+    cList.Clear;
+    if (Length(cboSurgery.ItemID) > 0) then
+      begin
+        for j := 0 to uSelectedItems.Count - 1 do
+          begin
+            xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
+            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
+              begin
+                cList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3));
+              end;
+            xLabTest.Free;
+          end;
+      end;
+    if (uChangingMSBOS = false) and (cList.Count > 0) then
+      begin
+        lblNoBloodReq.Visible := true;
+        with Application do
+          begin
+            NormalizeTopMosts;
+            aMSBOSContinue :=
+              MessageBox(PChar('No blood is required for the surgical procedure: ' + cboSurgery.text +
+               '.' + CRLF +
+               'If you still need to order any components, please enter a justification in the Comment box.'
+                + CRLF + CRLF + 'Do you want me to remove ALL the component orders you''ve just entered? '),
+               PChar('No Blood Required'),MB_YESNO);
+            RestoreTopMosts;
+          end;
+        if aMSBOSContinue = 6 then
+          begin
+            tQuantity.Text := '';
+            for j := uSelectedItems.Count - 1 downto 0 do
+              begin
+                if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+                  begin
+                    lvSelectionList.Items[j].Delete;
+                    uSelectedItems.Delete(j);
+                    Responses.Update('ORDERABLE', (j+1) ,'', '');
+                    Responses.Update('MODIFIER', (j+1), '', '');
+                    Responses.Update('QTY', (j+1), '', '');
+                  end;
+              end;
+            cboAvailComp.Text := '';
+            cboAvailComp.ItemIndex := -1;
+            cboModifiers.Text := '';
+            cboModifiers.ItemIndex := -1;
+            lblNoBloodReq.Visible := false;
+            //if fODBBank. Active then cboAvailTest.SetFocus;
+            lblTNS.Caption := '';
+            lblTNS.Visible := false;
+            DisableComponentControls;
+          end;
+      end;
+      for i := 0 to lvSelectionList.Items.Count - 1 do
+        begin
+          if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
+            begin
+              uGetTnS := 0;
+              aGotTNS := true;
+              uDfltUrgency := cboUrgency.ItemID;
+              lblTNS.Caption := '';
+              lblTNS.Visible := false;
+              memMessage.Text := '';
+              pnlMessage.Visible := false;
+              pnlDiagnosticTests.Caption := 'Diagnostic Tests';
+              if uTNSOrders.Count > 0 then
+                begin
+                  for j := 0 to uTNSOrders.Count - 1 do
+                    aTNSString := aTNSString + CRLF + uTNSOrders[j];
+                  with Application do
+                    begin
+                      NormalizeTopMosts;
+                      aTNS :=
+                        MessageBox(PChar(aTNSString + CRLF + CRLF +
+                           'Do you wish to cancel this request for Type & Screen?'),
+                           PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
+                           MB_YESNO);
+                      RestoreTopMosts;
+                      if aTNS = 6 then
+                        begin
+                          lvSelectionList.ItemIndex := i;
+                          lvSelectionListClick(self);
+                          btnRemoveClick(self);
+                          break;
+                        end;
+                    end;
+                end;
+              break;
+            end;
+        end;
+      if uSelectedItems.Count < 1 then uGetTNS := 0;
+
+      for i := uSelectedItems.Count - 1 downto 0 do
+        begin
+          if (aGotTNS = false) and not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
+            begin
+              uGetTnS := 1;
+              break;
+            end;
+        end;
+
     CurAdd := 1;
     for i := 0 to uSelectedItems.Count - 1 do
@@ -689,5 +830,14 @@
               else
                 begin
-                  cboUrgency.ItemIndex := 1;
+                  cboUrgency.ItemIndex := 2;
+                  for j := 0 to cboUrgency.Items.Count - 1 do
+                    begin
+                      aUrgText := cboUrgency.Items[j];
+                      if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
+                        begin
+                          cboUrgency.ItemIndex := j;
+                          break;
+                        end;
+                    end;
                   Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
                   cboUrgencyChange(self);
@@ -696,183 +846,18 @@
         Inc(CurAdd);
       end;
-    for i := 0 to lvSelectionList.Items.Count - 1 do
-      begin
-        if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
-          begin
-            if uTNSOrders.Count > 0 then
-              begin
-                for j := 0 to uTNSOrders.Count - 1 do
-                  aTNSString := aTNSString + CRLF + uTNSOrders[j];
-                with Application do
-                  begin
-                    NormalizeTopMosts;
-                    aTNSDays := TNSDaysBack;
-                    aTNS :=
-                      MessageBox(PChar(aTNSString + CRLF + CRLF +
-                                 'Do you wish to continue with this request for Type & Screen?'),
-                                 PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
-                                 MB_YESNO);
-                    RestoreTopMosts;
-                    if aTNS = 7 then
-                      begin
-                        lvSelectionList.ItemIndex := i;
-                        lvSelectionListClick(self);
-                        btnRemoveClick(self);
-                        break;
-                      end;
-                  end;
-              end;
-            break;
-          end;
-      end;
-  {if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses, ALabTest do
-    begin
-      if OrderAction in [ORDER_QUICK, ORDER_EDIT] then uQuickInProcess := 1;
-      AnInstance := NextInstance('ORDERABLE', 0);
-      while AnInstance > 0 do
-        begin
-          AResponse := FindResponseByName('ORDERABLE', AnInstance);
-          if AResponse <> nil then
-            begin
-              sub := GetSubtype(AResponse.EValue);
-              if sub = 't' then
-                begin
-                  SetControl(cboAvailTest,        'ORDERABLE', AnInstance);
-                  ALabTest := TLabTest.Create(cboAvailTest.ItemID, Responses);
-                end
-              else
-                begin
-                  SetControl(cboAvailComp,        'ORDERABLE', AnInstance);
-                  ALabTest := TLabTest.Create(cboAvailComp.ItemID, Responses);
-                end;
-              //SetControl(cboTests,           'ORDERABLE', AnInstance);
-              //ALabTest := TLabTest.Create(cboTests.ItemID, Responses);
-              if ALabTest = nil then Exit;  // Causes access violation
-              //sub := GetSubtype(ALabTest.TestName);
-              if AnInstance = 1 then
-                begin
-                  DetermineCollectionDefaults(Responses);
-                  SetControl(cboReasons,         'REASON', AnInstance);
-                  SetControl(chkConsent,         'YN', AnInstance);
-                  SetControl(cboSurgery,         'MISC', AnInstance);
-                  //SetControl(cboCollType,        'COLLECT', AnInstance);
-                  //SetControl(cboCollTime,        'START', AnInstance);
-                  SetControl(calWantTime,        'DATETIME', AnInstance);
-                  //LoadUrgency(cboCollType.ItemID, cboUrgency);
-                  SetControl(cboUrgency,         'URGENCY', AnInstance);
-                  Urgency := cboUrgency.ItemIEN;
-                  if (Urgency = 0) and (cboUrgency.Items.Count = AnInstance) then
-                    begin
-                      cboUrgency.ItemIndex := 0;
-                      Urgency := cboUrgency.ItemIEN;
-                    end;
-                  i := 1 ;
-                  AResponse := Responses.FindResponseByName('COMMENT',i);
-                  while AResponse <> nil do
-                      begin
-                        if Length(AResponse.Evalue) > 0 then
-                          Comment.Add(AResponse.EValue);
-                        Inc(i);
-                        AResponse := Responses.FindResponseByName('COMMENT',i);
-                      end ;
-                end;
-              if sub = 't' then with ALabTest do      //DIAGNOSTIC TEST
-                begin
-                  Changing := True;
-                  DisableComponentControls;
-                  EnableDiagTestControls;
-                  LRORDERMODE := TORDER_MODE_DIAG;
-                  with Responses do
-                    begin
-                      StatusText('Initializing Order');
-                      AResponse := FindResponseByName('ORDERABLE', AnInstance);
-                      if AResponse <> nil then
-                        sub1 := GetSubtype(AResponse.EValue);
-                      if sub1 = 't' then
-                        begin
-                          SetControl(cboAvailTest,       'ORDERABLE', AnInstance);
-                          //SetControl(cboTests,           'ORDERABLE', AnInstance);
-                          //DetermineCollectionDefaults(Responses);   //cboCollType = COLLECT , calCollTime = START
-                          cboAvailTestSelect(self);
-                        end;
-                    end;
-                  Changing := False;
-                  if ObtainCollSamp then
-                    begin
-                      //For BloodBank orders, this condition should never occur
-                    end
-                  else
-                    begin
-                      with ALabTest do
-                        with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
-                          begin
-                            x := '' ;
-                            for i := 0 to WardComment.Count-1 do
-                            x := x + WardComment.strings[i]+#13#10 ;
-                            pnlMessage.TabOrder := cboAvailTest.TabOrder + 1;
-                            OrderMessage(x) ;
-                          end ;
-                    end;
-                end;
-              if sub = 'c' then with ALabTest do  //COMPONENT
-                begin
-                  Changing := True;
-                  DisableDiagTestControls;
-                  EnableComponentControls;
-                  LRORDERMODE := TORDER_MODE_COMP;
-                  with Responses do
-                    begin
-                      StatusText('Initializing Order');
-                      AResponse := FindResponseByName('ORDERABLE', AnInstance);
-                      if AResponse <> nil then
-                        sub1 := GetSubtype(AResponse.EValue);
-                      if sub1 = 'c' then
-                        begin
-                          SetControl(cboAvailComp,       'ORDERABLE', AnInstance);
-                          //SetControl(cboTests,           'ORDERABLE', AnInstance);
-                          SetControl(cboModifiers,       'MODIFIER', AnInstance);
-                          SetControl(tQuantity,          'QTY', AnInstance);
-                          //DetermineCollectionDefaults(Responses);
-                          cboAvailCompSelect(self);
-                        end;
-                    end;
-                  Changing := False;
-                end;
-              with ALabTest do
-                begin
-                  if ObtainComment then
-                    LoadRequiredComment(FCmtTypes.IndexOf(CurReqComment))
-                  else
-                    DisableCommentPanels;
-                  x := '' ;
-                  for i := 0 to CurWardComment.Count-1 do
-                    x := x + CurWardComment.strings[i]+#13#10 ;
-                  i :=  IndexOfCollSamp(CollSamp);
-                  if i > -1 then with TCollSamp(CollSampList.Items[IndexOfCollSamp(CollSamp)]) do
-                    for i := 0 to WardComment.Count-1 do
-                      x := x + WardComment.strings[i]+#13#10 ;
-                  pnlMessage.TabOrder := cboAvailTest.TabOrder + 1;
-                  if Length(x) > 0 then
-                    begin
-                      OrderMessage(x) ;
-                    end;
-                end;
-              StatusText('');
-              Changing := True;
-              //if not(FOrderAction = ORDER_EDIT) then DetermineCollectionDefaults(Responses);
-              Changing := False;
-            end;
-          AnInstance := NextInstance('ORDERABLE', AnInstance);
-        end; //while AnInstance - ORDERABLE
-      DisableComponentControls;
-      DisableDiagTestControls;
-      uQuickInProcess := 0;
-    end;  }
+    if uGetTnS = 1 then
+      begin
+        lblTNS.Caption := 'TYPE + SCREEN must be added to order';
+        lblTNS.Visible := true;
+        memMessage.Text := 'TYPE + SCREEN must be added to order';
+        pnlMessage.Visible := true;
+        pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
+      end
+      else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
   finally
     aList.Free;
+    cList.Free;
     aTests.Free;
   end;
-  edtResults.Height := 247;
-  edtInfo.Height := 247;
   if lvSelectionList.Items.Count > 0 then
     begin
@@ -881,4 +866,6 @@
       memOrder.Visible := True;
       GroupBox1.Visible := False;
+      lvSelectionList.Items[0].Selected := true;
+      lvSelectionListClick(self);
     end;
 end;
@@ -890,14 +877,17 @@
   i: integer;
   x,sub,sub1,aTNSString: string;
-  aList: TStringList;
-  aGotIt: boolean;
+  aList, cList: TStringList;
+  aGotIt, aGotTNS: boolean;
   aTests: TStringList;
   ListItem: TListItem;
-  aName, aMsg, aStr, aModifier, aReason, aSurgery, aCollTime, aTestYes, aSpecimen, aTypeScreen: String;
-  CurAdd, j, k, getTest, TestAdded, aMSBOS, aMSBOSContinue, aTNS, aTNSDays: Integer;
+  xLabTest: TLabTest;
+  aName, aMsg, aStr, aModifier, aReason, aSurgery, aCollTime, aTestYes, aSpecimen, aSpecimenUID, aSpecimenReq, aTypeScreen, aUrgText: String;
+  CurAdd, j, k, getTest, TestAdded, aMSBOS, aMSBOSContinue, aTNS: Integer;
 begin
   inherited;
   aList := TStringList.Create;
+  cList := TStringList.Create;
   aTests := TStringList.Create;
+  pgeProduct.ActivePageIndex := TI_COMPONENT;
   try
     aModifier := '';
@@ -908,10 +898,17 @@
     aTypeScreen := '';
     aSpecimen := '';
+    aSpecimenUID := '';
+    aSpecimenReq := '';
     sub1 := '';
+    aGotTNS := false;
     ExtractTypeScreen(aList, uVBECList);
     if aList.Count > 0 then aTypeScreen := aList[0];
     aList.Clear;
-    Extractspecimen(aList, uVBECList);
-    if aList.Count > 0 then aSpecimen := aList[0];
+    ExtractSpecimen(aList, uVBECList);
+    if aList.Count > 0 then
+      begin
+        aSpecimen := piece(aList[0], '^',1);
+        aSpecimenUID := piece(aList[0], '^',2);
+      end;
     with Responses, ALabTest do
       begin
@@ -963,25 +960,25 @@
                     SetControl(chkConsent,         'YN', AnInstance);
                     //DetermineCollectionDefaults(Responses);
-                    SetControl(cboCollType,        'COLLECT', AnInstance);
-                    SetupCollTimes(cboCollType.ItemID);
-                    //SetControl(cboCollTime,        'START', AnInstance);
-                    //LoadUrgency(cboCollType.ItemID, cboUrgency);
                     SetControl(cboUrgency,         'URGENCY', AnInstance);
-                    Urgency := cboUrgency.ItemIEN;
-                    if (Urgency = 0) and (cboUrgency.Items.Count = AnInstance) then
+                    if cboUrgency.ItemIEN = 0 then
                       begin
-                        cboUrgency.ItemIndex := 0;
-                        Urgency := cboUrgency.ItemIEN;
-                        cboUrgencyChange(self);
+                        if StrToIntDef(LRFURG, 0) > 0 then
+                          cboUrgency.SelectByID(LRFURG)
+                        else if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
+                          cboUrgency.ItemIndex := 0;
                       end;
                     SetControl(cboSurgery,         'MISC', AnInstance);
+                    if Length(cboSurgery.Text) > 0 then
+                      begin
+                        for i := 0 to cboSurgery.Items.Count - 1 do
+                          if uppercase(cboSurgery.Text) = uppercase(piece(cboSurgery.Items[i],'^',2)) then
+                            begin
+                              cboSurgery.ItemIndex := i;
+                              Break;
+                            end;
+                        cboSurgeryChange(self);
+                      end;
                     if not(ALabTest = nil) then
                       begin
-                        Urgency := cboUrgency.ItemIEN;
-                        if (Urgency = 0) and (cboUrgency.Items.Count = 1) then
-                          begin
-                            cboUrgency.ItemIndex := 0;
-                            Urgency := cboUrgency.ItemIEN;
-                          end;
                         i := 1 ;
                         AResponse := Responses.FindResponseByName('COMMENT',i);
@@ -992,16 +989,4 @@
                             AResponse := Responses.FindResponseByName('COMMENT',i);
                           end ;
-                      end;
-                    if not(cboCollType.ItemID = 'LC') then
-                      begin
-                        if Length(cboCollTime.Text) > 0 then
-                          begin
-                            calCollTime.FMDateTime := StrToFMDateTime(cboCollTime.Text);
-                            FLastCollTime := cboCollTime.Text;
-                          end
-                        else
-                          begin
-                            FLastCollTime := '';
-                          end;
                       end;
                   end;
@@ -1014,6 +999,4 @@
                     SetControl(cboModifiers,       'MODIFIER', AnInstance);
                     SetControl(tQuantity,          'QTY', AnInstance);
-                    //DetermineCollectionDefaults(Responses);
-                    //Check for and display any associated Lab Results
                     aList.Clear;
                     TestAdded := 0;
@@ -1043,11 +1026,14 @@
                       if TestAdded = 1 then
                         begin
-                          edtResults.Clear;
                           aTests.Clear;
                           GetPatientBloodResults(aTests, Patient.DFN, uTestsForResults);
-                          QuickCopy(ATests,edtResults);
-                          if edtResults.Lines.Count > 0 then TabResults.Caption := 'Lab Results Available'; //TabResults.ImageIndex := 1;
-                          uRaw.Clear;
-                          GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+                          if aTests.Count > 0 then
+                            begin
+                              edtResults.Clear;
+                              QuickCopy(ATests,edtResults);
+                              TabResults.Caption := 'Lab Results Available';
+                              uRaw.Clear;
+                              GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+                            end;
                         end;
                       CurAdd := 1;
@@ -1058,5 +1044,7 @@
                           Inc(CurAdd);
                         end;
-                    aSpecimen := '^';
+                    aSpecimen := '';
+                    aSpecimenUID := '';
+                    aSpecimenReq := '';
                     aTestYes := '0';
                     aReason := '';
@@ -1064,9 +1052,12 @@
                     aCollTime := '';
                     ExtractSpecimen(aList, uVBECList);
-                    if aList.Count > 0 then aSpecimen := aList[0];
+                    if aList.Count > 0 then
+                      begin
+                        aSpecimen := piece(aList[0], '^', 1);
+                        aSpecimenUID := piece(aList[0], '^', 2);
+                      end;
                     if length(cboModifiers.ItemID) > 0 then aModifier := cboModifiers.Items[cboModifiers.ItemIndex];
                     if length(cboReasons.ItemID) > 0 then aReason := cboReasons.Items[cboReasons.ItemIndex];
                     if length(cboSurgery.ItemID) > 0 then aSurgery := cboSurgery.Items[cboSurgery.ItemIndex];
-                    if length(cboCollTime.ItemID) > 0 then aCollTime := cboCollTime.Items[cboCollTime.ItemIndex];
                     if Length(cboSurgery.ItemID) > 0 then
                       begin
@@ -1076,5 +1067,5 @@
                           begin
                             if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
-                             and (piece(aList[i],'^',3) = cboSurgery.Text) then
+                             and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
                               begin
                                 aMSBOS := StrToInt(piece(aList[i],'^',4));
@@ -1086,15 +1077,46 @@
                                       aMSBOSContinue :=
                                         MessageBox(PChar('The number of units ordered (' + tQuantity.Text +
-                                                   ') for ' + aLabTest.TestName + ' exceeds the maximum number of units ('
-                                                   + IntToStr(aMSBOS) +
-                                                   ') for the ' + cboSurgery.text +
-                                                   ' surgical procedure selected.' + CRLF + CRLF + 'Do you wish to continue?'),
-                                                   PChar('Maximum Number of Units Exceeded'),
-                                                   MB_YESNO);
+                                           ') for ' + aLabTest.TestName + ' Exceeds the maximum number recommended ('
+                                           + IntToStr(aMSBOS) +
+                                           ') for the ' + cboSurgery.text +
+                                           ' surgical procedure.' + CRLF +
+                                           'If you need to order more than the maximum number of units, please enter a justification in the Comment box.'
+                                            + CRLF + CRLF + 'Edit the Blood component Quantity?'),
+                                           PChar('Maximum Number of Units Exceeded'),
+                                           MB_YESNO);
                                       RestoreTopMosts;
                                     end;
-                                    if aMSBOSContinue = 7 then
+                                    if aMSBOSContinue = 6 then
                                       begin
                                         ShowMsg(cboAvailComp.Text + ' has NOT been added to this request.');
+                                        lvSelectionList.Clear;
+                                        uSelectedItems.Clear;
+                                        uTestsForResults.Clear;
+                                        uRaw.Clear;
+                                        uGetTnS := 0;
+                                        lblTNS.Caption := '';
+                                        lblTNS.Visible := false;
+                                        memMessage.Text := '';
+                                        pnlMessage.Visible := false;
+                                        FLastItemID := '';
+                                        InitDialog;
+                                        cboModifiers.ItemIndex := -1;
+                                        cboAvailTest.ItemIndex := -1;
+                                        cboAvailComp.ItemIndex := -1;
+                                        cboSurgery.ItemIndex := -1;
+                                        cboUrgency.ItemIndex := -1;
+                                        cboReasons.ItemIndex := -1;
+                                        cboCollType.ItemIndex := -1;
+                                        cboCollTime.ItemIndex := -1;
+                                        cboQuick.ItemIndex := -1;
+                                        calWantTime.Text := '';
+                                        memDiagComment.Text := '';
+                                        GroupBox1.Visible := true;
+                                        tQuantity.Text := '';
+                                        FLastCollType := '';
+                                        FLastCollTime := '';
+                                        FLastLabCollTime := '';
+                                        txtImmedColl.Text := '';
+                                        calCollTime.text := '';
                                         exit;
                                       end;
@@ -1103,5 +1125,13 @@
                           end;
                       end;
-                    if (uTNSOrders.Count < 1) then //SpecimenNeeded(aList, uVBECList, aLabTest.ItemID) then  //check to see if type and screen is needed
+                    for i := lvSelectionList.Items.Count - 1 downto 0 do
+                      begin
+                        if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
+                          begin
+                            aGotTNS := true;
+                            break;
+                          end;
+                      end;
+                    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
                       begin
                         uGetTnS := 1;
@@ -1113,5 +1143,7 @@
                         if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID) then
                           begin
-                            aSpecimen := piece(aList[i],'^',2) + '^' + aSpecimen;
+                            aSpecimenReq := piece(aList[i],'^',2);
+                            if (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then
+                              aSpecimenUID := '';
                             break;
                           end;
@@ -1136,5 +1168,5 @@
                       end;
                     CurAdd := 1;
-                    aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces additional pieces added for Tests
+                    aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
                     uSelectedItems.Add(aStr);
                     for i := 0 to uSelectedItems.Count - 1 do
@@ -1160,61 +1192,4 @@
                   aMsg := '';
                   LRORDERMODE := TORDER_MODE_INFO;
-                  {if uGetTnS = 1 then
-                    begin
-                      lblTNS.Caption := 'TYPE + SCREEN must be added to order';
-                      lblTNS.Visible := true;
-                      memMessage.Text := 'TYPE + SCREEN must be added to order';
-                      memMessage.Visible := false;
-                      pnlMessage.Visible := true;
-                      pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
-                    end;  }
-                  {if uGetTnS = 1 then
-                    begin
-                      if responses.QuickOrder < 1 then
-                        begin
-                          for i := 1 to cboAvailTest.Items.Count - 1 do
-                            begin
-                              if piece(cboAvailTest.Items[i],'^',1) = aTypeScreen then
-                                begin
-                                  if piece(aSpecimen,'^',1) = '1' then
-                                    begin
-                                      cboCollTime.Text := calWantTime.Text;
-                                      aCollSave := cboCollTime.Text + '^' + cboCollTime.ItemID + '^' + cboCollType.Text + '^' + cboCollType.ItemID;
-                                      cboCollTime.Text := '';
-                                      cboCollType.Text := '';
-                                      uSpecimen := 1;
-                                    end;
-                                  cboModifiers.Text := '';
-                                  cboAvailTest.SelectByID(aTypeScreen);
-                                  cboTests.SelectByID(aTypeScreen);
-                                  cboTestsClick(self);
-                                  //cboAvailTestSelect(Self);
-                                  uSpecimen := 0;
-                                  cboCollTime.Text := piece(aCollSave,'^',1);
-                                  cboCollType.Text := piece(aCollSave,'^',3);
-                                  aCollSave := '';
-                                  break;
-                                end;
-                            end;
-                          aMsg := 'An order for Type and Screen has been added to this request' + '.';
-                        end
-                        else
-                          begin
-                            lblTNS.Caption := 'TYPE + SCREEN must be added to order';
-                            lblTNS.Visible := true;
-                            memMessage.Text := 'TYPE + SCREEN must be added to order';
-                            memMessage.Visible := false;
-                            pnlMessage.Visible := true;
-                          end;
-                    end;
-                  if (uGetTnS = 1) then
-                    begin
-                      if length(aMsg) > 0 then aMsg := aMsg + crlf + crlf;
-                      ShowMsg(aMsg);
-                    end;  }
-
-                  //cboModifiers.Text := '';
-                  edtResults.Height := 247;
-                  edtInfo.Height := 247;
                   if lvSelectionList.Items.Count > 0 then
                     begin
@@ -1234,5 +1209,5 @@
                         aTestYes := '1';
                         SetControl(cboAvailTest,       'ORDERABLE', AnInstance);
-                        //DetermineCollectionDefaults(Responses);   //cboCollType = COLLECT , calCollTime = START
+                        //DetermineCollectionDefaults(Responses); //cboCollType = COLLECT , calCollTime = START
                         i := 1 ;
                         AResponse := Responses.FindResponseByName('COMMENT',i);
@@ -1260,13 +1235,17 @@
                           end;
                         if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
-                        with cboCollType do if Length(ItemID) > 0 then
-                          begin
-                            Responses.Update('COLLECT', 1, ItemID, ItemID) ;
-                            FLastCollType := ItemID;
-                          end;
                         if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
                           else
                             begin
-                              cboUrgency.ItemIndex := 1;
+                              cboUrgency.ItemIndex := 2;
+                              for i := 0 to cboUrgency.Items.Count - 1 do
+                                begin
+                                  aUrgText := cboUrgency.Items[i];
+                                  if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
+                                    begin
+                                      cboUrgency.ItemIndex := i;
+                                      break;
+                                    end;
+                                end;
                               Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
                               cboUrgencyChange(self);
@@ -1274,45 +1253,4 @@
                         if Length(memDiagComment.Text) > 0 then Responses.Update('COMMENT',1,memDiagComment.Text,memDiagComment.Text);
                         if Length(cboReasons.Text) > 0 then Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
-                        LoadCollType(cboCollType);
-                        if (cboCollType.ItemID = 'LC') or (cboCollType.ItemID = 'I') then
-                          if not(ALabTest.LabCanCollect) and OrderForInpatient then
-                            cboCollType.SelectByID('WC')
-                          else if not(ALabTest.LabCanCollect) then
-                            cboCollType.SelectByID('SP');
-                        SetupCollTimes(cboCollType.ItemID);
-                        if cboCollType.ItemID = 'LC' then
-                          begin
-                            with cboCollTime do
-                              if Length(ItemID) > 0 then
-                                begin
-                                  Responses.Update('START', 1, Copy(ItemID, 2, 999), Copy(ItemID, 2, 999));
-                                  FLastLabCollTime := ItemID + U + Text;
-                                end
-                              else if Length(Text) > 0 then
-                                begin
-                                  Responses.Update('START', 1, ValidCollTime(Text), Text) ;
-                                  FLastLabCollTime := ValidCollTime(Text);
-                                end;
-                          end
-                        else
-                          begin
-                            with calCollTime do
-                              if FMDateTime > 0 then
-                                begin
-                                  Responses.Update('START', 1, ValidCollTime(Text), Text);
-                                  FLastColltime := ValidCollTime(Text);
-                                end
-                              else
-                                begin
-                                  Responses.Update('START', 1, '', '') ;
-                                  FLastCollTime := '';
-                                end;
-                          end;
-                        if length(cboCollTime.ItemID) > 0 then aCollTime := cboCollTime.Items[cboCollTime.ItemIndex];
-                        with cboCollType do if Length(ItemID) > 0 then
-                          begin
-                            Responses.Update('COLLECT', 1, ItemID, ItemID) ;
-                            FLastCollType := ItemID;
-                          end;
                         uTestSelected := true;
                         with lvSelectionList do
@@ -1326,5 +1264,5 @@
                           end;
                         CurAdd := 1;
-                        aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + aCollTime + '^' + cboCollType.Text + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces
+                        aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
                         uSelectedItems.Add(aStr);
                         for i := 0 to uSelectedItems.Count - 1 do
@@ -1339,6 +1277,4 @@
                           end;
                         memOrder.Text := Responses.OrderText;
-                      edtResults.Height := 247;
-                      edtInfo.Height := 247;
                       if lvSelectionList.Items.Count > 0 then
                         begin
@@ -1353,4 +1289,56 @@
               end;
               //Quick Order
+          end;
+        cList.Clear;
+        if (Length(cboSurgery.ItemID) > 0) then
+          begin
+            for j := 0 to uSelectedItems.Count - 1 do
+              begin
+                xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
+                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
+                  begin
+                    cList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3));
+                  end;
+                xLabTest.Free;
+              end;
+          end;
+        if (uChangingMSBOS = false) and (cList.Count > 0) then
+          begin
+            lblNoBloodReq.Visible := true;
+            with Application do
+              begin
+                NormalizeTopMosts;
+                aMSBOSContinue :=
+                  MessageBox(PChar('No blood is required for the surgical procedure: ' + cboSurgery.text +
+                   '.' + CRLF +
+                   'If you still need to order any components, please enter a justification in the Comment box.'
+                    + CRLF + CRLF + 'Do you want me to remove ALL the component orders you''ve just entered? '),
+                   PChar('No Blood Required'),MB_YESNO);
+                RestoreTopMosts;
+              end;
+            if aMSBOSContinue = 6 then
+              begin
+                tQuantity.Text := '';
+                for j := uSelectedItems.Count - 1 downto 0 do
+                  begin
+                    if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+                      begin
+                        lvSelectionList.Items[j].Delete;
+                        uSelectedItems.Delete(j);
+                        Responses.Update('ORDERABLE', (j+1) ,'', '');
+                        Responses.Update('MODIFIER', (j+1), '', '');
+                        Responses.Update('QTY', (j+1), '', '');
+                      end;
+                  end;
+                cboAvailComp.Text := '';
+                cboAvailComp.ItemIndex := -1;
+                cboModifiers.Text := '';
+                cboModifiers.ItemIndex := -1;
+                lblNoBloodReq.Visible := false;
+                //if fODBBank. Active then cboAvailTest.SetFocus;
+                lblTNS.Caption := '';
+                lblTNS.Visible := false;
+                DisableComponentControls;
+              end;
           end;
         for i := 0 to lvSelectionList.Items.Count - 1 do
@@ -1372,12 +1360,11 @@
                       begin
                         NormalizeTopMosts;
-                        aTNSDays := TNSDaysBack;
                         aTNS :=
                           MessageBox(PChar(aTNSString + CRLF + CRLF +
-                                     'Do you wish to continue with this request for Type & Screen?'),
-                                     PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
-                                     MB_YESNO);
+                             'Do you wish to cancel this request for Type & Screen?'),
+                             PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
+                             MB_YESNO);
                         RestoreTopMosts;
-                        if aTNS = 7 then
+                        if aTNS = 6 then
                           begin
                             lvSelectionList.ItemIndex := i;
@@ -1398,5 +1385,6 @@
             pnlMessage.Visible := true;
             pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
-          end;
+          end
+          else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
         if ALabTest <> nil then
           begin
@@ -1440,4 +1428,5 @@
   finally                      //**SubTest
     alist.Free;
+    cList.Free;
     aTests.Free;
   end;
@@ -1719,17 +1708,26 @@
 procedure TLabTest.LoadUrgency(CollType: string; AComboBox:TORComboBox);
 var
-  i: integer;
+  i, PreviousSelectionIndex: integer;
+  PreviousSelectionString: String;
 begin
   if UrgencyList.Count < 1 then Exit;
   with AComboBox do
     begin
+     PreviousSelectionIndex := -1;
+     PreviousSelectionString := SelText;
       Clear;
       for i := 0 to UrgencyList.Count - 1 do
+        begin
          if (CollType = 'LC') and (Piece(UrgencyList[i], U, 3) = '') then
            Continue
          else
            Items.Add(UrgencyList[i]);
+         if (PreviousSelectionString <> '') and (PreviousSelectionString = Piece(UrgencyList[i], U, 2)) then
+           PreviousSelectionIndex := i;
+        end;
       if (LRFURG <> '') and (ALabTest.ObtainUrgency) then
         SelectByID(LRFURG)
+      else if PreviousSelectionIndex > -1 then
+        ItemIndex := PreviousSelectionIndex
       else
         SelectByIEN(uDfltUrgency);
@@ -1864,5 +1862,5 @@
   i:integer;
   aborh: boolean;
-  aSpecimen, aSpecimenDate: string;
+  aSpecimen, aSpecimenUID, aSpecimenDate: string;
   aWantDateTime, aExpiredSpecimenDate: TFMDateTime;
 begin
@@ -1870,4 +1868,5 @@
   aborh := false;
   aSpecimen := '';
+  aSpecimenUID := '';
   OutList.Clear;
   ExtractItems(OutList,Alist,'ABORH');
@@ -1886,25 +1885,35 @@
   OutList.Clear;
   ExtractSpecimen(OutList, uVBECList);
-  if OutList.Count > 0 then aSpecimen := OutList[0];
+  if OutList.Count > 0 then
+    begin
+      aSpecimen := Piece(OutList[0], '^',1);
+      aSpecimenUID := Piece(OutList[0], '^',2);
+    end;
   OutList.Clear;
   ExtractItems(OutList,AList,'SPECIMENS');
   aWantDateTime := calWantTime.FMDateTime;
-  aSpecimenDate := piece(aSpecimen,'^',1);
+  aSpecimenDate := aSpecimen;
   aExpiredSpecimenDate := 0;
   if Length(aSpecimenDate) > 0 then aExpiredSpecimenDate := StrToFloat(aSpecimenDate);
-
   for i := 0 to OutList.Count - 1 do
     begin
       if (IntToStr(aLabTest.ItemID) = piece(OutList[i],'^',1)) and (piece(OutList[i],'^',2) = '1') then
-        if aSpecimen = '' then
-          begin
-            result := true;
-            exit;
-          end
-        else if (Length(calWantTime.Text) > 0) and (aExpiredSpecimenDate < aWantDateTime) then
-          begin
-            result := true;
-            exit;
-          end;
+        begin
+          if self.EvtID > 0 then
+            begin
+              result := true;
+              exit;
+            end;
+          if aSpecimen = '' then
+            begin
+              result := true;
+              exit;
+            end
+          else if (Length(calWantTime.Text) > 0) and (aExpiredSpecimenDate < aWantDateTime) then
+            begin
+              result := true;
+              exit;
+            end;
+        end;
     end;
 end;
@@ -1963,9 +1972,7 @@
   TX_TOO_MANY_DAYS  = 'Maximum number of days allowed is ';
   TX_TOO_MANY_TIMES = 'For this frequency, the maximum number of times allowed is:  X';
-  //TX_NO_COMMENT     = 'A comment is required for this test and collection sample.';
   TX_NUMERIC_REQD   = 'A numeric value is required for urine volume';
   TX_DOSEDRAW_REQD  = 'Both DOSE and DRAW times are required for this order';
   TX_TDM_REQD       = 'A value for LEVEL is required for this order';
-  //TX_ANTICOAG_REQD  = 'You must specify an anticoagulant on this order.' ;
   TX_NO_COLLSAMPLE  = 'A collection sample MUST be specified';
   TX_NO_SPECIMEN    = 'A specimen MUST be specified';
@@ -2189,9 +2196,59 @@
   tmpImmTime, tmpTime: TFMDateTime;
   x, tmpORECALLType, tmpORECALLTime: string;
-begin
+  j: integer;
+  havetest: boolean;
+begin
+  havetest := false;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') and ((length(calCollTime.Text) > 0) or (length(cboCollTime.Text) > 0)) then
+        begin
+          havetest := true;
+          Break;
+        end;
+    end;
+  //if (havetest = True) and (not(FOrderAction in [ORDER_QUICK, ORDER_EDIT])) then havetest := false;
   x := GetLastCollectionTime;
   tmpORECALLType := Piece(x, U, 1);
   tmpORECALLTime := Piece(x, U, 2);
   if CollType = 'SP' then
+    begin
+      cboColltime.Visible    := False;
+      txtImmedColl.Visible   := False;
+      pnlCollTimeButton.Visible   := False;
+      pnlCollTimeButton.TabStop := False;
+      calCollTime.Visible    := True;
+      calCollTime.Enabled    := True;
+      if FLastCollTime <> '' then
+        begin
+          calCollTime.Text := ValidCollTime(FLastColltime);
+          if IsFMDateTime(calCollTime.Text) then
+            begin
+              calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
+              calCollTime.FMDateTime := StrToFMDateTime(FLastCollTime);
+            end;
+        end
+      else if tmpORECALLTime <> '' then
+        begin
+          calCollTime.Text := ValidCollTime(tmpORECALLTime);
+          if IsFMDateTime(calCollTime.Text) then
+            begin
+              calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
+              calCollTime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
+            end;
+        end
+      else if LRFDATE <> '' then
+        calCollTime.Text     := LRFDATE
+      else if not(FOrderAction in [ORDER_EDIT]) then
+        calCollTime.Text     := 'TODAY'
+      else if (havetest = false) then
+        calCollTime.Text     := 'TODAY';
+     if (havetest = false) and (RemoveCollTimeDefault = True) then
+        begin
+          calCollTime.Text := '';
+          calCollTime.FMDateTime := 0;
+        end;
+    end
+  else if CollType = 'WC' then
     begin
       cboColltime.Visible    := False;
@@ -2203,55 +2260,29 @@
       if FLastCollTime <> '' then
         begin
-          calCollTime.Text := ValidCollTime(FLastColltime);
+          calCollTime.Text := ValidColltime(FLastColltime);
           if IsFMDateTime(calCollTime.Text) then
             begin
               calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
-              calColltime.FMDateTime := StrToFMDateTime(FLastCollTime);
+              calCollTime.FMDateTime := StrToFMDateTime(FLastCollTime);
             end;
         end
       else if tmpORECALLTime <> '' then
         begin
-          calCollTime.Text := ValidCollTime(tmpORECALLTime);
+          calCollTime.Text := ValidColltime(tmpORECALLTime);
           if IsFMDateTime(calCollTime.Text) then
             begin
               calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
-              calColltime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
+              calCollTime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
             end;
         end
       else if LRFDATE <> '' then
         calCollTime.Text     := LRFDATE
-      else
-        calCollTime.Text     := 'TODAY';
-    end
-  else if CollType = 'WC' then
-    begin
-      cboColltime.Visible    := False;
-      txtImmedColl.Visible   := False;
-      pnlCollTimeButton.Visible   := False;
-      pnlCollTimeButton.TabStop := False;
-      calCollTime.Visible    := True;
-      calColltime.Enabled    := True;
-      if FLastCollTime <> '' then
-        begin
-          calCollTime.Text := ValidColltime(FLastColltime);
-          if IsFMDateTime(calCollTime.Text) then
-            begin
-              calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
-              calColltime.FMDateTime := StrToFMDateTime(FLastCollTime);
-            end;
-        end
-      else if tmpORECALLTime <> '' then
-        begin
-          calCollTime.Text := ValidColltime(tmpORECALLTime);
-          if IsFMDateTime(calCollTime.Text) then
-            begin
-              calCollTime.Text := FormatFMDateTime('mmm dd,yy@hh:nn', StrToFMDateTime(calColltime.Text));
-              calColltime.FMDateTime := StrToFMDateTime(tmpORECALLTime);
-            end;
-        end
-      else if LRFDATE <> '' then
-        calCollTime.Text     := LRFDATE
-      else
+      else if not(FOrderAction in [ORDER_EDIT]) then
         calCollTime.Text     := 'NOW';
+      if (havetest = false) and (RemoveCollTimeDefault = True) then
+        begin
+          calCollTime.Text := '';
+          calCollTime.FMDateTime := 0;
+        end;
     end
   else if CollType = 'LC' then
@@ -2274,4 +2305,8 @@
       else
         cboCollTime.ItemIndex := 0;
+      if (havetest = false) and (RemoveCollTimeDefault = True) then
+        begin
+          cboCollTime.Text := '';
+        end;
     end
   else if CollType = 'I' then
@@ -2279,5 +2314,5 @@
       cboColltime.Visible    := False;
       calCollTime.Visible    := False;
-      calColltime.Enabled    := False;
+      calCollTime.Enabled    := False;
       txtImmedColl.Visible   := True;
       pnlCollTimeButton.Visible   := True;
@@ -2291,5 +2326,4 @@
       else if LRFDATE <> '' then
         tmpTime := StrToFMDateTime(LRFDATE);
-
       if tmpTime > tmpImmTime then
         begin
@@ -2301,4 +2335,10 @@
           calCollTime.FMDateTime := GetDefaultImmCollTime;
           txtImmedColl.Text      := FormatFMDateTime('mmm dd,yy@hh:nn', calCollTime.FMDateTime);
+        end;
+      if (havetest = false) and (RemoveCollTimeDefault = True) then
+        begin
+          calCollTime.Text := '';
+          calCollTime.FMDateTime := 0;
+          txtImmedColl.Text := '';
         end;
     end;
@@ -2387,4 +2427,5 @@
 begin
   inherited;
+  cboReasons.Text := StringReplace(cboReasons.Text,CRLF,'  ',[rfReplaceAll]);
   if (length(cboReasons.Text) > 75) then
     begin
@@ -2414,22 +2455,25 @@
 var
   i: integer;
-  text : string;
   ListItem: TListItem;
-  aCollTime,aTypeScreen,aStr,aModifier,aSpecimen,aTestYes,x,aName,aTNSString: string;
+  aCollTime,aTypeScreen,aStr,aModifier,aSpecimen,aSpecimenUID,aSpecimenReq,aTestYes,x,aName,aTNSString, aUrgText: string;
   aList: TStringList;
-  curAdd,AnInstance,aTNS,aTNSDays: Integer;
+  curAdd,aTNS: Integer;
   sub,sub1: string;
-  AResponse: TResponse;
+  aChanging: Boolean;
 begin
   if cboAvailTest.ItemID = '' then Exit;
   aList := TStringList.Create;
+  aChanging := changing;
   try
     ALabTest := nil;
     aTypeScreen := '';
-    aSpecimen := '^';
+    aSpecimen := '';
+    aSpecimenUID := '';
+    aSpecimenReq := '';
     aTestYes := '1';
     aModifier := '';
     changing := true;
     tQuantity.Text := '';
+    changing := aChanging;
     sub1 := '';
     cboModifiers.ItemIndex := -1;
@@ -2439,24 +2483,14 @@
     ALabTest := TLabTest.Create(cboAvailTest.ItemID, Responses);
     sub := GetSubtype(ALabTest.TestName);
-    with CtrlInits do
-        begin
-          SetControl(cboCollType, 'Collection Types');
-          LoadCollType(cboCollType);
-          if FLastCollType <> '' then
-            cboCollType.SelectByID(FLastCollType)
-          else if uDfltCollType <> '' then
-            cboCollType.SelectByID(uDfltCollType)
-          else if OrderForInpatient then
-            if (ALabTest.LabCanCollect) then
-              cboCollType.SelectByID('LC')
-            else
-              cboCollType.SelectByID('WC')
-          else
-            cboCollType.SelectByID('SP');
-          SetupCollTimes(cboCollType.ItemID);
-        end;
+    {if not(FOrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK]) then
+      DetermineCollectionDefaults(Responses); }
+    DetermineCollectionDefaults(Responses);
     with cboAvailTest do
       begin
-        if (Length(ItemID) = 0) or (ItemID = '0') then Exit;
+        if (Length(ItemID) = 0) or (ItemID = '0') then
+          begin
+            changing := aChanging;
+            Exit;
+          end;
         FLastLabID := ItemID ;
         FLastItemID := ItemID;
@@ -2467,13 +2501,12 @@
               lvSelectionList.Items[i].Selected := true;
               lvSelectionListClick(self);
+              changing := aChanging;
               Exit;
             end;
-        Changing := True;
-        Changing := False;
         ExtractTypeScreen(aList, uVBECList);
         if aList.Count > 0 then aTypeScreen := aList[0];
         aList.Clear;
         aTNSString := '';
-        if (StrToInt(aTypeScreen) = cboAvailTest.ItemID) and (uTNSOrders.Count > 0) then
+        if (Changing = false) and (StrToInt(aTypeScreen) = cboAvailTest.ItemID) and (uTNSOrders.Count > 0) then
           begin
             for i := 0 to uTNSOrders.Count - 1 do
@@ -2482,12 +2515,11 @@
               begin
                 NormalizeTopMosts;
-                aTNSDays := TNSDaysBack;
                 aTNS :=
                   MessageBox(PChar(aTNSString + CRLF + CRLF +
-                             'Do you wish to continue?'),
-                             PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
-                             MB_YESNO);
+                   'Do you wish to cancel this request for Type & Screen?'),
+                   PChar('Type & Screen Entered in Past ' + IntToStr(TNSDaysBack) + ' Days'),
+                   MB_YESNO);
                 RestoreTopMosts;
-                if aTNS = 7 then
+                if aTNS = 6 then
                   begin
                     cboAvailTest.ItemIndex := -1;
@@ -2515,22 +2547,26 @@
               end;
         end;
-        Changing := False;
       end;
     if LRORDERMODE = TORDER_MODE_DIAG then
       begin
         if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
-        with cboCollType do if Length(ItemID) > 0 then
+        if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
+        else if changing = false then
           begin
-            Responses.Update('COLLECT', 1, ItemID, ItemID) ;
-            FLastCollType := ItemID;
-          end;
-        if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text)
-        else
-          begin
-            cboUrgency.ItemIndex := 1;
+            for i := 0 to cboUrgency.Items.Count - 1 do
+              begin
+                aUrgText := cboUrgency.Items[i];
+                if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
+                  begin
+                    cboUrgency.ItemIndex := i;
+                    break;
+                  end;
+              end;
             Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
           end;
         if Length(memDiagComment.Text) > 0 then Responses.Update('COMMENT',1,memDiagComment.Text,memDiagComment.Text);
         if Length(cboReasons.Text) > 0 then Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
+        with cboCollTime do
+
         if cboCollType.ItemID = 'LC' then
           begin
@@ -2547,21 +2583,20 @@
                 end;
           end
-          else
-            begin
-              with calCollTime do
-                if FMDateTime > 0 then
-                  begin
-                    Responses.Update('START', 1, ValidCollTime(Text), Text);
-                    FLastColltime := ValidCollTime(Text);
-                  end
-                else
-                  begin
-                    Responses.Update('START', 1, '', '') ;
-                    FLastCollTime := '';
-                  end;
-            end;
-          if Length(cboCollType.Text) > 0 then Responses.Update('COLLECT',1,cboCollType.ItemID,cboCollType.ItemID);
+        else
+          begin
+            with calCollTime do
+              if FMDateTime > 0 then
+                begin
+                  Responses.Update('START', 1, ValidCollTime(Text), Text);
+                  FLastColltime := ValidCollTime(Text);
+                end
+              else
+                begin
+                  Responses.Update('START', 1, '', '') ;
+                  FLastCollTime := '';
+                end;
+          end;
+        if Length(cboCollType.Text) > 0 then Responses.Update('COLLECT',1,cboCollType.ItemID,cboCollType.ItemID);
       end;
-    if length(cboCollTime.ItemID) > 0 then aCollTime := cboCollTime.Items[cboCollTime.ItemIndex];
     uTestSelected := true;
     with lvSelectionList do
@@ -2583,5 +2618,5 @@
           end;
       end;
-    aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + aCollTime + '^' + cboCollType.Text + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces
+    aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
     uSelectedItems.Add(aStr);
     CurAdd := 1;
@@ -2600,6 +2635,4 @@
     aList.Free;
   end;
-  edtResults.Height := 247;
-  edtInfo.Height := 247;
   if lvSelectionList.Items.Count > 0 then
     begin
@@ -2618,7 +2651,7 @@
   aMSBOS,aMSBOSContinue,curAdd,AnInstance: integer;
   sub,sub1: string;
-  AResponse: TResponse;
   ListItem: TListItem;
-  aTypeScreen,aSpecimen,aTestYes,aStr,aMsg,aModifier,x,x1,aReason,aSurgery,aCollTime,aCollSave,aName: String;
+  aTypeScreen,aSpecimen,aSpecimenUID,aSpecimenReq,aTestYes,aStr,aMsg,aModifier,x,x1,aReason,aSurgery,aCollTime,aCollSave,aName,aUrgText: String;
+  aChanging: Boolean;
 begin
   if cboAvailComp.ItemID = '' then Exit;
@@ -2626,4 +2659,5 @@
   aTests := TStringList.Create;
   sub1 := '';
+  aChanging := changing;
   try
     DisableDiagTestControls;
@@ -2634,5 +2668,5 @@
         tQuantity.Text := '';
         cboModifiers.ItemIndex := -1;
-        changing := false;
+        changing := aChanging;
       end;
     LRORDERMODE := TORDER_MODE_COMP;
@@ -2652,12 +2686,11 @@
         ALabTest := TLabTest.Create(ItemID, Responses);
         sub := GetSubtype(ALabTest.TestName);
-        Changing := False;
+        changing := aChanging;
         StatusText('');
       end;
-    //Check for and display any associated Lab Results
     aList.Clear;
     TestAdded := 0;
     getTest := 0;
-    ExtractTests(aList, uVBECList);   //Get Results associated with ordered components
+    ExtractTests(aList, uVBECList);   //Get Lab Results associated with ordered components
       for j := 0 to aList.Count - 1 do
         begin
@@ -2683,11 +2716,14 @@
       if TestAdded = 1 then
         begin
-          edtResults.Clear;
           aTests.Clear;
           GetPatientBloodResults(aTests, Patient.DFN, uTestsForResults);
-          QuickCopy(ATests,edtResults);
-          if edtResults.Lines.Count > 0 then TabResults.Caption := 'Lab Results Available';
-          uRaw.Clear;
-          GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+          if aTests.Count > 0 then
+            begin
+              edtResults.Clear;
+              QuickCopy(ATests,edtResults);
+              TabResults.Caption := 'Lab Results Available';
+              uRaw.Clear;
+              GetPatientBloodResultsRaw(uRaw, Patient.DFN, uTestsForResults);
+            end;
         end;
       CurAdd := 1;
@@ -2699,5 +2735,7 @@
         end;
     aTypeScreen := '';
-    aSpecimen := '^';
+    aSpecimen := '';
+    aSpecimenUID := '';
+    aSpecimenReq := '';
     aTestYes := '0';
     aReason := '';
@@ -2709,11 +2747,27 @@
     aList.Clear;
     ExtractSpecimen(aList, uVBECList);
-    if aList.Count > 0 then aSpecimen := aList[0];
+    if aList.Count > 0 then
+      begin
+        aSpecimen := piece(aList[0], '^', 1);
+        aSpecimenUID := piece(aList[0], '^', 2);
+      end;
+    if (cboSurgery.ItemID = '') and (length(cboSurgery.Text) > 0) then
+      begin
+        for i := 0 to cboSurgery.Items.Count - 1 do
+          if uppercase(cboSurgery.Text) = uppercase(piece(cboSurgery.Items[i],'^',2)) then
+            begin
+              cboSurgery.ItemIndex := i;
+              Break;
+            end;
+      end;
     if length(cboModifiers.ItemID) > 0 then aModifier := cboModifiers.Items[cboModifiers.ItemIndex];
     if length(cboReasons.ItemID) > 0 then aReason := cboReasons.Items[cboReasons.ItemIndex];
     if length(cboSurgery.ItemID) > 0 then aSurgery := cboSurgery.Items[cboSurgery.ItemIndex];
-    if length(cboCollTime.ItemID) > 0 then aCollTime := cboCollTime.Items[cboCollTime.ItemIndex];
-    if Length(cboSurgery.ItemID) > 0 then
-      begin
+    if (Length(cboSurgery.ItemID) > 0) and (length(tQuantity.Text) > 0) and (strToInt(tQuantity.Text) > 0) then
+      begin
+        uChangingMSBOS := true;
+        cboSurgeryChange(self);
+        uChangingMSBOS := false;
+        if cboAvailComp.ItemIndex = -1 then Exit;
         aList.Clear;
         ExtractMSBOS(aList, uVBECList);    //Get maximum units for selected Surgey
@@ -2721,5 +2775,5 @@
           begin
             if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
-             and (piece(aList[i],'^',3) = cboSurgery.Text) then
+             and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
               begin
                 aMSBOS := StrToInt(piece(aList[i],'^',4));
@@ -2731,13 +2785,15 @@
                       aMSBOSContinue :=
                         MessageBox(PChar('The number of units ordered (' + tQuantity.Text +
-                                   ') for ' + aLabTest.TestName + ' exceeds the maximum number of units ('
-                                   + IntToStr(aMSBOS) +
-                                   ') for the ' + cboSurgery.text +
-                                   ' surgical procedure selected.' + CRLF + CRLF + 'Do you wish to continue?'),
-                                   PChar('Maximum Number of Units Exceeded'),
-                                   MB_YESNO);
+                         ') for ' + aLabTest.TestName + ' Exceeds the maximum number recommended ('
+                         + IntToStr(aMSBOS) +
+                         ') for the ' + cboSurgery.text +
+                         ' surgical procedure.' + CRLF +
+                         'If you need to order more than the maximum number of units, please enter a justification in the Comment box.'
+                          + CRLF + CRLF + 'Edit the Blood component Quantity?'),
+                         PChar('Maximum Number of Units Exceeded'),
+                         MB_YESNO);
                       RestoreTopMosts;
                     end;
-                    if aMSBOSContinue = 7 then
+                    if aMSBOSContinue = 6 then
                       begin
                         ShowMsg(cboAvailComp.Text + ' has NOT been added to this request.');
@@ -2748,5 +2804,5 @@
           end;
       end;
-    if (uTNSOrders.Count < 1) then // SpecimenNeeded(aList, uVBECList, aLabTest.ItemID) then  //check to see if type and screen is needed
+    if (uTNSOrders.Count < 1) and (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then  //check to see if type and screen is needed CQ 17349
       begin
         uGetTnS := 1;
@@ -2772,5 +2828,7 @@
         if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID) then
           begin
-            aSpecimen := piece(aList[i],'^',2) + '^' + aSpecimen;
+            aSpecimenReq := piece(aList[i],'^',2);
+            if (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then
+              aSpecimenUID := '';
             break;
           end;
@@ -2794,5 +2852,5 @@
         ListItem.SubItems.Add(piece(cboAvailComp.Items[cboAvailComp.ItemIndex],'^',1));
       end;
-      aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimen + '^' + IntToStr(aLabTest.ItemID);  //aSpecimen has 2 pieces additional pieces added for Tests
+      aStr := aTestYes + '^' + IntToStr(aLabTest.TestID) + '^' + tQuantity.Text + '^' + aModifier + '^' + aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID + '^' + IntToStr(aLabTest.ItemID);
       uSelectedItems.Add(aStr);
       CurAdd := 1;
@@ -2816,5 +2874,14 @@
                 else
                   begin
-                    cboUrgency.ItemIndex := 1;
+                    cboUrgency.ItemIndex := 2;
+                    for j := 0 to cboUrgency.Items.Count - 1 do
+                      begin
+                        aUrgText := cboUrgency.Items[j];
+                        if aUrgText = '9^ROUTINE' then    // Find urgency default of ROUTINE
+                          begin
+                            cboUrgency.ItemIndex := i;
+                            break;
+                          end;
+                      end;
                     Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
                   end;
@@ -2836,51 +2903,6 @@
       pnlMessage.Visible := true;
       pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
-    end;
-  {if uGetTnS = 1 then
-    begin
-      if responses.QuickOrder < 1 then
-        begin
-          for i := 1 to cboAvailTest.Items.Count - 1 do
-            begin
-              if piece(cboAvailTest.Items[i],'^',1) = aTypeScreen then
-                begin
-                  if piece(aSpecimen,'^',1) = '1' then
-                    begin
-                      cboCollTime.Text := calWantTime.Text;
-                      aCollSave := cboCollTime.Text + '^' + cboCollTime.ItemID + '^' + cboCollType.Text + '^' + cboCollType.ItemID;
-                      cboCollTime.Text := '';
-                      cboCollType.Text := '';
-                      uSpecimen := 1;
-                    end;
-                  cboModifiers.Text := '';
-                  cboAvailTest.SelectByID(aTypeScreen);
-                  cboTests.SelectByID(aTypeScreen);
-                  cboTestsClick(self);
-                  //cboAvailTestSelect(Self);
-                  uSpecimen := 0;
-                  cboCollTime.Text := piece(aCollSave,'^',1);
-                  cboCollType.Text := piece(aCollSave,'^',3);
-                  aCollSave := '';
-                  break;
-                end;
-            end;
-          aMsg := 'An order for Type and Screen has been added to this request' + '.';
-        end
-        else
-          begin
-            lblTNS.Caption := 'TYPE + SCREEN must be added to order';
-            lblTNS.Visible := true;
-            memMessage.Text := 'TYPE + SCREEN must be added to order';
-            memMessage.Visible := false;
-            pnlMessage.Visible := true;
-          end;
-      end;
-  if (uGetTnS = 1) then
-    begin
-      if length(aMsg) > 0 then aMsg := aMsg + crlf + crlf;
-      ShowMsg(aMsg);
-    end;  }
-  edtResults.Height := 247;
-  edtInfo.Height := 247;
+    end
+    else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
   if lvSelectionList.Items.Count > 0 then
     begin
@@ -2899,4 +2921,6 @@
 
 procedure TfrmODBBank.DisableComponentControls;
+var
+  j: integer;
 begin
   lblQuantity.Enabled := false;
@@ -2904,5 +2928,17 @@
   lblModifiers.Enabled := false;
   cboModifiers.Enabled := false;
+  lblQuantity.Caption := 'Quantity';
+  lblWanted.Caption := 'Date/Time Wanted';
+  lblReason.Caption := 'Reason for Request';
   cboAvailComp.ItemIndex := -1;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if piece(uSelectedItems[j],'^',1) = '0' then
+        begin
+          lblReason.Caption := 'Reason for Request*';
+          lblWanted.Caption := 'Date/Time Wanted*';
+          Break;
+        end;
+    end;
 end;
 
@@ -2913,4 +2949,7 @@
   lblModifiers.Enabled := true;
   cboModifiers.Enabled := true;
+  lblQuantity.Caption := 'Quantity*';
+  lblWanted.Caption := 'Date/Time Wanted*';
+  lblReason.Caption := 'Reason for Request*';
   if not(changing) then
     if not(uSelUrgency = 'PRE-OP') then
@@ -2919,28 +2958,65 @@
           cboUrgency.SelectByID(IntToStr(uDfltUrgency));
   if cboUrgency.Text = 'PRE-OP' then
-    begin
-      lblSurgery.Enabled := true;
-      cboSurgery.Enabled := true;
-      lblSurgery.Caption := 'Surgery*';
-    end
-    else
-      begin
-        lblSurgery.Enabled := false;
-        cboSurgery.Enabled := false;
-        lblSurgery.Caption := 'Surgery';
-      end;
+        begin
+          lblSurgery.Enabled := true;
+          cboSurgery.Enabled := true;
+          lblSurgery.Caption := 'Surgery*';
+        end
+      else
+        begin
+          if Length(cboSurgery.Text) > 0 then
+            begin
+              lblSurgery.Enabled := true;
+              cboSurgery.Enabled := true;
+              lblSurgery.Caption := 'Surgery*';
+            end
+            else
+            begin
+              lblSurgery.Enabled := false;
+              cboSurgery.Enabled := false;
+              lblSurgery.Caption := 'Surgery';
+              cboSurgery.ItemIndex := -1;
+              Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
+            end;
+        end;
+
   lblDiagComment.Enabled := true;
 end;
 
 procedure TfrmODBBank.DisableDiagTestControls;
-begin
-  lblCollTime.Enabled := false;
-  calCollTime.Enabled := false;
-  cboCollTime.Enabled := false;
-  lblCollType.Enabled := false;
-  cboCollType.Enabled := false;
-  cmdImmedColl.Enabled := false;
+var
+  i,j: integer;
+  diagflg: boolean;
+begin
+  diagflg := false;
+  for i := 0 to uSelectedItems.Count - 1 do
+    begin
+      if (piece(uSelectedItems[i],'^',1) = '1') then
+        begin
+          diagflg := true;
+          Break;
+        end;
+    end;
+  if diagflg = false then
+    begin
+      lblCollTime.Enabled := false;
+      calCollTime.Enabled := false;
+      cboCollTime.Enabled := false;
+      lblCollType.Enabled := false;
+      cboCollType.Enabled := false;
+      cmdImmedColl.Enabled := false;
+    end;
+  lblCollTime.Caption := 'Collection Date/Time';
+  lblCollType.Caption := 'Collection Type';
   cboAvailTest.ItemIndex := -1;
-  cboAvailTest.InitLongList('');
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if piece(uSelectedItems[j],'^',1) = '1' then
+        begin
+          lblCollTime.Caption := 'Collection Date/Time*';
+          lblCollType.Caption := 'Collection Type*';
+          Break;
+        end;
+    end;
 end;
 
@@ -2953,4 +3029,6 @@
   cboCollType.Enabled := true;
   cmdImmedColl.Enabled := true;
+  lblCollTime.Caption := 'Collection Date/Time*';
+  lblCollType.Caption := 'Collection Type*';
   if not(changing) then
     if not(uSelUrgency = 'PRE-OP') then
@@ -2971,7 +3049,4 @@
 begin
   if ALabTest = nil then exit;
-  if ALabTest.LabSubscript = 'BB' then exit;
-  calCollTime.Clear;
-  cboCollTime.Clear;
   calCollTime.Enabled := True;
   lblCollTime.Enabled := True;
@@ -3024,5 +3099,12 @@
               begin
                 calCollTime.Enabled := False;
-                if RespStart <> nil then txtImmedColl.Text := RespStart.EValue;
+                cboCollType.SelectByID('I');
+                SetupCollTimes('I');
+                //cboCollTypeClick(self);
+                //txtImmedColl.Enabled := True;
+                if RespStart <> nil then
+                  begin
+                    txtImmedColl.Text := RespStart.EValue;
+                  end;
               end;
         end
@@ -3032,19 +3114,50 @@
 end;
 
+procedure TfrmODBBank.cboAvailTestEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailTest.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
+end;
+
 procedure TfrmODBBank.cboAvailTestExit(Sender: TObject);
 begin
   inherited;
-  if (Length(cboAvailTest.ItemID) = 0) or (cboAvailTest.ItemID = '0') then Exit;
+  if (Length(cboAvailTest.Text)>0) and (Length(cboAvailTest.ItemID) = 0) or (cboAvailTest.ItemID = '0') then
+    begin
+      ShowMsg('Invalid Test Selection. Please select a valid Test.');
+      cboAvailTestSelect(cboAvailTest);
+      cboAvailTest.SetFocus;
+      Exit;
+    end;
   if cboAvailTest.ItemID = FLastLabID then Exit;
-  cboAvailTestSelect(cboAvailTest);
-  cboAvailTest.SetFocus;
-  PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
-end;
-
-procedure TfrmODBBank.cboAvailCompChange(Sender: TObject);
-begin
-  inherited;
-  changing := true;
-  changing := false;
+  if not (Length(cboAvailTest.ItemID) = 0) then cboAvailTestSelect(cboAvailTest);
+end;
+
+procedure TfrmODBBank.cboAvailCompEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailComp.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
 end;
 
@@ -3052,9 +3165,13 @@
 begin
   inherited;
-  if (Length(cboAvailComp.ItemID) = 0) or (cboAvailComp.ItemID = '0') then Exit;
+  if (Length(cboAvailComp.Text)>0) and (Length(cboAvailComp.ItemID) = 0) or (cboAvailComp.ItemID = '0') then
+    begin
+      ShowMsg('Invalid Component selection. Please select a valid Component.');
+      cboAvailCompSelect(cboAvailComp);
+      cboAvailComp.SetFocus;
+      Exit;
+    end;
   if cboAvailComp.ItemID = FLastLabID then Exit;
-  cboAvailCompSelect(cboAvailComp);
-  cboAvailComp.SetFocus;
-  PostMessage(Handle, WM_NEXTDLGCTL, 0, 0);
+  if not (Length(cboAvailComp.ItemID) = 0) then cboAvailCompSelect(cboAvailComp);
 end;
 
@@ -3130,4 +3247,40 @@
 end;
 
+procedure TfrmODBBank.pnlBloodComponentsClick(Sender: TObject);
+begin
+  inherited;
+  cboAvailComp.SetFocus;
+end;
+
+procedure TfrmODBBank.pnlBloodComponentsEnter(Sender: TObject);
+begin
+  inherited;
+  pnlBloodComponents.Color := clActiveborder;
+end;
+
+procedure TfrmODBBank.pnlBloodComponentsExit(Sender: TObject);
+begin
+  inherited;
+  pnlBloodcomponents.Color := clBtnFace;
+end;
+
+procedure TfrmODBBank.pnlDiagnosticTestsClick(Sender: TObject);
+begin
+  inherited;
+  cboAvailTest.SetFocus;
+end;
+
+procedure TfrmODBBank.pnlDiagnosticTestsEnter(Sender: TObject);
+begin
+  inherited;
+  pnlDiagnosticTests.Color := clActiveBorder;
+end;
+
+procedure TfrmODBBank.pnlDiagnosticTestsExit(Sender: TObject);
+begin
+  inherited;
+  pnlDiagnosticTests.Color := clBtnFace;
+end;
+
 procedure TfrmODBBank.cboCollTimeChange(Sender: TObject);
 var
@@ -3163,4 +3316,21 @@
 end;
 
+procedure TfrmODBBank.cboCollTimeEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailTest.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
+end;
+
 procedure TfrmODBBank.cboCollTypeChange(Sender: TObject);
 begin
@@ -3180,6 +3350,28 @@
   SetupCollTimes(cboCollType.ItemID);
   if Length(cboCollType.Text) > 0 then Responses.Update('COLLECT',1,cboCollType.ItemID,cboCollType.ItemID);
-  FLastCollType := cboCollType.ItemID;
   calCollTimeChange(self);
+end;
+
+procedure TfrmODBBank.cboCollTypeClick(Sender: TObject);
+begin
+  inherited;
+  FOrderAction := 0;
+end;
+
+procedure TfrmODBBank.cboCollTypeEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailTest.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
 end;
 
@@ -3226,4 +3418,21 @@
 end;
 
+procedure TfrmODBBank.cboModifiersEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailComp.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
+end;
+
 procedure TfrmODBBank.LoadModifiers(AComboBox:TORComboBox);
 var
@@ -3257,9 +3466,11 @@
     begin
       Clear;
-      for i := 0 to uUrgencyList.Count - 1 do
+      {for i := 0 to uUrgencyList.Count - 1 do
          if (piece(uUrgencyList[i],'^',2) = 'STAT') and (StatAllowed(Patient.DFN) = false) then
            Continue
          else
-           Items.Add(uUrgencyList[i]);
+           Items.Add(uUrgencyList[i]); }
+      for i := 0 to uUrgencyList.Count - 1 do
+        Items.Add(uUrgencyList[i]);
     end;
 end;
@@ -3281,8 +3492,8 @@
   if cboCollType.ItemID = 'LC' then
     begin
-      if FLastLabCollTime <> '' then
+      if (FLastLabCollTime <> '') and (length(cboCollTime.Text) < 1) then
         cboCollTime.SelectByID(piece(FLastLabCollTime,'^',1));
     end
-  else
+  else if length(calcollTime.Text) < 1 then
     begin
       if FLastCollTime = 'TODAY' then
@@ -3293,5 +3504,5 @@
         calCollTime.Text := FormatFMDateTime('mmm dd,yyyy@hh:nn',StrToFMDateTime(FLastCollTime));
     end;
-  if FLastCollType <> '' then
+  if (FLastCollType <> '') and (length(cboCollType.Text) < 1) then
     cboCollType.SelectByID(FLastCollType);
   if uSelectedItems.Count > 0 then
@@ -3325,4 +3536,5 @@
 begin
   inherited;
+  memDiagComment.Text := StringReplace(memDiagComment.Text,CRLF,'  ',[rfReplaceAll]);
   if (length(memDiagComment.Text) > 250) then
     begin
@@ -3353,4 +3565,10 @@
 end;
 
+procedure TfrmODBBank.FormShow(Sender: TObject);
+begin
+  inherited;
+  pgeProduct.SetFocus;
+end;
+
 procedure TfrmODBBank.btnRemoveClick(Sender: TObject);
 var
@@ -3358,5 +3576,5 @@
   x, aName, aModifier, aReason, aTypeScreen: string;
   aList: TStringList;
-  aSel, aSelTst : boolean;
+  aSel, aSelTst, aSelComp, aGotTNS : boolean;
 begin
   inherited;
@@ -3369,4 +3587,6 @@
     aSel := false;
     aSelTst := false;
+    aSelComp := false;
+    aGotTNS := false;
     ExtractTypeScreen(aList, uVBECList);
     if aList.Count > 0 then aTypeScreen := aList[0];
@@ -3381,4 +3601,6 @@
     cboAvailComp.ItemIndex := -1;
     tQuantity.Text := '';
+    tQuantity.Enabled := false;
+    lblQuantity.Enabled := false;
     cboAvailTest.ItemIndex := -1;
     uGetTnS := 0;
@@ -3398,14 +3620,4 @@
                   if lvSelectionList.Items[i].SubItems[3] = piece(uSelectedItems[j],'^',2) then
                     begin
-                      {if (uGetTnS = 1) and (lvSelectionList.Items[i].SubItems[3] = aTypeScreen) then
-                        begin
-                          uGetTnS := 1;
-                          lblTNS.Caption := 'TYPE+SCREEN must be added to order';
-                          lblTNS.Visible := true;
-                          memMessage.Text := 'TYPE + SCREEN must be added to order';
-                          //memMessage.Visible := true;
-                          pnlMessage.Visible := true;
-                          pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
-                        end; }
                       uSelectedItems.Delete(j);
                       lvSelectionList.Items[i].Delete;
@@ -3415,19 +3627,29 @@
           end;
       end;
-    for i := uSelectedItems.Count - 1 downto 0 do
-      begin
-        if (not(piece(uSelectedItems[i],'^',1) = '1')) and (uTNSOrders.Count < 1) then // and (SpecimenNeeded(aList, uVBECList, StrToInt(piece(uSelectedItems[i],'^',9)))) then
+    for i := lvSelectionList.Items.Count - 1 downto 0 do
+      begin
+        if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
           begin
-            uGetTnS := 1;
-            lblTNS.Caption := 'TYPE+SCREEN must be added to order';
-            lblTNS.Visible := true;
-            memMessage.Text := 'TYPE + SCREEN must be added to order';
-            //memMessage.Visible := true;
-            pnlMessage.Visible := true;
-            pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
+            aGotTNS := true;
             break;
           end;
       end;
-      
+    if aGotTNS = false then
+      begin
+        for i := uSelectedItems.Count - 1 downto 0 do
+          begin
+            if not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
+              begin
+                uGetTnS := 1;
+                lblTNS.Caption := 'TYPE + SCREEN must be added to order';
+                lblTNS.Visible := true;
+                memMessage.Text := 'TYPE + SCREEN must be added to order';
+                pnlMessage.Visible := true;
+                pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
+                break;
+              end
+              else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
+          end;
+      end;
     if (aSel = false) and (lvSelectionList.Items.Count > 0) then
       begin
@@ -3436,14 +3658,34 @@
       end;
     Responses.Clear;
+    pnlDiagnosticTests.Caption := 'Diagnostic Tests';
+    lblCollTime.Caption := 'Collection Date/Time';
+    lblCollType.Caption := 'Collection Type';
+    lblQuantity.Caption := 'Quantity';
+    lblWanted.Caption := 'Date/Time Wanted';
+    lblReason.Caption := 'Reason for Request';
     if lvSelectionList.Items.Count < 1 then
       begin
-        cboReasons.ItemIndex := -1;
-        memDiagComment.Text := '';
-        cboSurgery.ItemIndex := -1;
-        cboUrgency.ItemIndex := -1;
+        uGetTnS := 0;
+        lblTNS.Caption := '';
+        lblTNS.Visible := false;
+        memMessage.Text := '';
+        pnlMessage.Visible := false;
+        FLastItemID := '';
+        InitDialog;
+        cboModifiers.ItemIndex := -1;
+        cboAvailTest.ItemIndex := -1;
+        cboAvailComp.ItemIndex := -1;
         cboCollType.ItemIndex := -1;
         cboCollTime.ItemIndex := -1;
         cboQuick.ItemIndex := -1;
-        calCollTime.Text := '';
+        calWantTime.Text := '';
+        GroupBox1.Visible := true;
+        tQuantity.Text := '';
+        FLastCollType := '';
+        FLastCollTime := '';
+        FLastLabCollTime := '';
+        txtImmedColl.Text := '';
+        calCollTime.text := '';
+        lblNoBloodReq.Visible := false;
       end;
     for i := 0 to uSelectedItems.Count - 1 do
@@ -3454,4 +3696,6 @@
           begin
             if Length(piece(x,'^',2)) > 0 then Responses.Update('ORDERABLE', CurAdd, piece(x,'^',2), aName);
+            lblCollTime.Caption := 'Collection Date/Time*';
+            lblCollType.Caption := 'Collection Type*';
             aSelTst := true;
           end
@@ -3465,4 +3709,8 @@
             cboAvailComp.ItemIndex := -1;
             tQuantity.Text := '';
+            lblQuantity.Caption := 'Quantity*';
+            lblWanted.Caption := 'Date/Time Wanted*';
+            lblReason.Caption := 'Reason for Request*';
+            //aSelComp := true;
           end;
         Inc(CurAdd);
@@ -3474,4 +3722,8 @@
         calCollTime.Text := '';
       end;
+    {if aSelcomp = false then
+      lblNoBloodReq.Visible := false
+    else
+      lblNoBloodReq.Visible := true;  }
     if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
     if cboCollType.ItemID = 'LC' then
@@ -3569,4 +3821,5 @@
   memMessage.Text := '';
   pnlMessage.Visible := false;
+  FLastItemID := '';
   InitDialog;
   cboModifiers.ItemIndex := -1;
@@ -3583,8 +3836,18 @@
   GroupBox1.Visible := true;
   tQuantity.Text := '';
+  tQuantity.Enabled := false;
+  lblQuantity.Enabled := false;
   FLastCollType := '';
   FLastCollTime := '';
   FLastLabCollTime := '';
   txtImmedColl.Text := '';
+  calCollTime.text := '';
+  lblNoBloodReq.Visible := false;
+  pnlDiagnosticTests.Caption := 'Diagnostic Tests';
+  lblCollTime.Caption := 'Collection Date/Time';
+  lblCollType.Caption := 'Collection Type';
+  lblQuantity.Caption := 'Quantity';
+  lblWanted.Caption := 'Date/Time Wanted';
+  lblReason.Caption := 'Reason for Request';
 end;
 
@@ -3622,16 +3885,27 @@
 
 procedure TfrmODBBank.calWantTimeChange(Sender: TObject);
-begin
-  inherited;
+var
+  i: integer;
+  aList: TStringList;
+  aSpecimen, aSpecimenUID, aSpecimenReq: string;
+  aChanging: Boolean;
+begin
+  inherited;
+  aList := TStringList.Create;
+  aChanging := changing;
+  try
+  aSpecimen := '';
+  aSpecimenUID := '';
+  aSpecimenReq := '';
   if uSelectedItems.Count > 0 then
     begin
-      with calWantTime do if not Changing then
+      with calWantTime do if not changing then
         begin
           if FMDateTime = 0 then
             begin
               ShowMsg('Invalid Date/Time entered');
-              Changing := true;
+              changing := true;
               calWantTime.Text := '';
-              Changing := false;
+              changing := aChanging;
               Exit;
             end
@@ -3642,7 +3916,7 @@
                 begin
                   ShowMsg('Date/Time Wanted must be a future Date/Time');
-                  Changing := true;
+                  changing := true;
                   calWantTime.Text := '';
-                  Changing := false;
+                  changing := aChanging;
                   Exit;
                 end;
@@ -3651,4 +3925,44 @@
       if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
       memOrder.Text := Responses.OrderText;
+      aList.Clear;
+      ExtractSpecimen(aList, uVBECList);
+      if aList.Count > 0 then
+      begin
+        aSpecimen := piece(aList[0], '^', 1);
+        aSpecimenUID := piece(aList[0], '^', 2);
+      end;
+      aList.Clear;
+      ExtractSpecimens(aList, uVBECList);    //Get specimen values to pass back to Server
+      for i := 0 to aList.Count - 1 do
+        begin
+          if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID) then
+            begin
+              aSpecimenReq := piece(aList[i],'^',2);
+              if (SpecimenNeeded(aList, uVBECList, aLabTest.ItemID)) then
+                aSpecimenUID := '';
+              break;
+            end;
+        end;
+      Responses.Update('SPECSTS', 1, aSpecimenReq + '^' + aSpecimen + '^' + aSpecimenUID, aSpecimenReq);
+    end;
+  finally
+    aList.Free;
+  end;
+end;
+
+procedure TfrmODBBank.calWantTimeEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailComp.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
     end;
 end;
@@ -3679,9 +3993,18 @@
       else
         begin
-          lblSurgery.Enabled := false;
-          cboSurgery.Enabled := false;
-          lblSurgery.Caption := 'Surgery';
-          cboSurgery.ItemIndex := -1;
-          Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
+          if Length(cboSurgery.Text) > 0 then
+            begin
+              lblSurgery.Enabled := true;
+              cboSurgery.Enabled := true;
+              lblSurgery.Caption := 'Surgery*';
+            end
+            else
+            begin
+              lblSurgery.Enabled := false;
+              cboSurgery.Enabled := false;
+              lblSurgery.Caption := 'Surgery';
+              cboSurgery.ItemIndex := -1;
+              Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
+            end;
         end;
     end
@@ -3700,14 +4023,38 @@
 procedure TfrmODBBank.cboSurgeryChange(Sender: TObject);
 var
-  aList: TStringList;
+  aList, bList, cList: TStringList;
   i,j,aMSBOS,aMSBOSContinue: integer;
-  x: string;
-  handled: boolean;
-begin
-  inherited;
+  x,aTypeScreen: string;
+  handled,aGotTNS: boolean;
+  xLabTest: TLabTest;
+begin
+  inherited;
+  cboSurgery.Text := StringReplace(cboSurgery.Text,CRLF,'  ',[rfReplaceAll]);
   aList := TStringList.Create;
+  bList := TStringList.Create;
+  cList := TStringList.Create;
   handled := false;
+  //uGetTNS := 0;
+  //aGotTNS := false;
+  ExtractTypeScreen(aList, uVBECList);
+  if aList.Count > 0 then aTypeScreen := aList[0];
+  aList.Clear;
+  bList.Clear;
+  cList.Clear;
   try
-    if (Length(cboSurgery.ItemID) > 0) and (Length(tQuantity.Text) > 0) then
+    cboSurgery.DroppedDown := false;
+    if (Length(cboSurgery.ItemID) > 0) then
+      begin
+        for j := 0 to uSelectedItems.Count - 1 do
+          begin
+            xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
+            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
+              begin
+                cList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3));
+              end;
+            xLabTest.Free;
+          end;
+      end;
+    if (Length(cboSurgery.ItemID) > 0) and (Length(tQuantity.Text) > 0) and (Length(cboAvailComp.Text) > 0) then
       begin
         aList.Clear;
@@ -3716,30 +4063,10 @@
           begin
             if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
-             and (piece(aList[i],'^',3) = cboSurgery.Text) then
+             and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
               begin
                 aMSBOS := StrToInt(piece(aList[i],'^',4));
                 if (aMSBOS > 0) and (StrToInt(tQuantity.Text) > aMSBOS) then
                   begin
-                    with Application do
-                    begin
-                      NormalizeTopMosts;
-                      aMSBOSContinue :=
-                        MessageBox(PChar('The number of unit Quantity selected (' + tQuantity.Text +
-                                   ') for ' + aLabTest.TestName + ' exceeds the maximum number of units ('
-                                   + IntToStr(aMSBOS) +
-                                   ') for the ' + cboSurgery.text +
-                                   ' surgical procedure selected.' + CRLF + CRLF + 'Continue to order ' + tQuantity.Text + ' units?'),
-                                   PChar('Maximum Number of Units Exceeded'),
-                                   MB_YESNO);
-                      RestoreTopMosts;
-                    end;
-                    if aMSBOSContinue = 7 then
-                      begin
-                        ShowMsg('Please enter a new quantity for ' + cboAvailComp.Text);
-                        tQuantity.Text := '0';
-                        tQuantity.SelLength := 2;
-                        tQuantity.SelectAll;
-                        break;
-                      end;
+                    bList.Add(aLabTest.TestName + '^' + tQuantity.Text + '^' + IntToStr(aMSBOS));
                   end;
                 handled := true;
@@ -3754,44 +4081,109 @@
         for j := 0 to uSelectedItems.Count - 1 do
           begin
-            ALabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
+            xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
             for i := 0 to aList.Count - 1 do
               begin
                 if (piece(uSelectedItems[j],'^',1) = '0')
-                 and (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
-                 and (piece(aList[i],'^',3) = cboSurgery.Text) then
+                 and (StrToInt(piece(aList[i],'^',1)) = xLabTest.ItemID)
+                 and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
                   begin
                     aMSBOS := StrToInt(piece(aList[i],'^',4));
                     if (aMSBOS > 0) and (length(piece(uSelectedItems[j],'^',3)) > 0) and (StrToInt(piece(uSelectedItems[j],'^',3)) > aMSBOS) then
                       begin
-                        with Application do
-                        begin
-                          NormalizeTopMosts;
-                          aMSBOSContinue :=
-                            MessageBox(PChar('The number of unit Quantity selected (' + piece(uSelectedItems[j],'^',3) +
-                               ') for ' + lvSelectionList.Items[j].Caption + ' exceeds the maximum number of units ('
-                               + IntToStr(aMSBOS) +
-                               ') for the ' + cboSurgery.text +
-                               ' surgical procedure selected.' + CRLF + CRLF + 'Continue to order ' + piece(uSelectedItems[j],'^',3) + ' units?'),
-                               PChar('Maximum Number of Units Exceeded'),
-                               MB_YESNO);
-                          RestoreTopMosts;
-                        end;
-                        if aMSBOSContinue = 7 then
-                          begin
-                            ShowMsg('Please enter a new quantity for ' + lvSelectionList.Items[j].Caption);
-                            tQuantity.Text := '0';
-                            tQuantity.SelLength := 2;
-                            tQuantity.SelectAll;
-                            x := uSelectedItems[j];
-                            SetPiece(x,U,3,'');
-                            uSelectedItems[j] := x;
-                            lvSelectionList.Items[j].SubItems[0] := '';
-                            RePaint;
-                            break;
-                          end;
+                        bList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3) + '^' + IntToStr(aMSBOS));
                       end;
                     break;
                   end;
               end;
+            xLabTest.Free;
+          end;
+      end;
+    if (uChangingMSBOS = false) and (cList.Count > 0) then
+      begin
+        lblNoBloodReq.Visible := true;
+        with Application do
+          begin
+            NormalizeTopMosts;
+            aMSBOSContinue :=
+              MessageBox(PChar('No blood is required for the surgical procedure: ' + cboSurgery.text +
+               '.' + CRLF +
+               'If you still need to order any components, please enter a justification in the Comment box.'
+                + CRLF + CRLF + 'Do you want me to remove ALL the component orders you''ve just entered? '),
+               PChar('No Blood Required'),MB_YESNO);
+            RestoreTopMosts;
+          end;
+        if aMSBOSContinue = 6 then
+          begin
+            tQuantity.Text := '';
+            bList.Clear;
+            for j := uSelectedItems.Count - 1 downto 0 do
+              begin
+                if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+                  begin
+                    lvSelectionList.Items[j].Delete;
+                    uSelectedItems.Delete(j);
+                    Responses.Update('ORDERABLE', (j+1) ,'', '');
+                    Responses.Update('MODIFIER', (j+1), '', '');
+                    Responses.Update('QTY', (j+1), '', '');
+                  end;
+              end;
+            cboAvailComp.Text := '';
+            cboAvailComp.ItemIndex := -1;
+            cboModifiers.Text := '';
+            cboModifiers.ItemIndex := -1;
+            lblNoBloodReq.Visible := false;
+            //if fODBBank. Active then cboAvailTest.SetFocus;
+            lblTNS.Caption := '';
+            lblTNS.Visible := false;
+            uGetTNS := 0;
+            aGotTNS := false;
+            DisableComponentControls;
+            for i := lvSelectionList.Items.Count - 1 downto 0 do
+              begin
+                if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
+                  begin
+                    aGotTNS := true;
+                    break;
+                  end;
+              end;
+            for i := uSelectedItems.Count - 1 downto 0 do
+              begin
+                if (aGotTNS = false) and not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
+                  begin
+                    uGetTnS := 1;
+                    lblTNS.Caption := 'TYPE + SCREEN must be added to order';
+                    lblTNS.Visible := true;
+                    memMessage.Text := 'TYPE + SCREEN must be added to order';
+                    pnlMessage.Visible := true;
+                    pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
+                    break;
+                  end
+                  else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
+              end;
+          end;
+      end
+      else
+        begin
+          lblNoBloodReq.Visible := false;
+        end;
+
+    if (uChangingMSBOS = false) and (bList.Count > 0) then
+      begin
+        x := '';
+        for i := 0 to bList.Count - 1 do
+          begin
+            x := x + CRLF + piece(bList[i],'^',1) + ' (' + piece(bList[i],'^',2) + ') Max allowed: ' + piece(bList[i],'^',3);
+          end;
+        with Application do
+          begin
+            NormalizeTopMosts;
+            aMSBOSContinue :=
+              MessageBox(PChar('The number of units ordered' + x + CRLF +
+               'Exceeds the maximum number recommended for '
+               + cboSurgery.text + CRLF + CRLF +
+               'If you need to order more than the recommended maximum units, please enter a justification in the Comment box.')
+               ,PChar('Maximum Number of Units Exceeded'),
+               MB_OK);
+            RestoreTopMosts;
           end;
       end;
@@ -3806,7 +4198,9 @@
         Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
       end;
-    memOrder.Text := Responses.OrderText; 
+    memOrder.Text := Responses.OrderText;
     finally
       aList.Free;
+      bList.Free;
+      cList.Free;
     end;
 end;
@@ -3844,6 +4238,9 @@
     end;
   try
-    if (Length(cboSurgery.ItemID) > 0) and (Length(tQuantity.Text) > 0) then
-      begin
+    if not(aLabTest = nil) and (Length(cboSurgery.ItemID) > 0) and (Length(tQuantity.Text) > 0) then
+      begin
+        uChangingMSBOS := true;
+        cboSurgeryChange(self);
+        uChangingMSBOS := false;
         aList.Clear;
         ExtractMSBOS(aList, uVBECList);    //Get maximum units for selected Surgery
@@ -3851,5 +4248,5 @@
           begin
             if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
-             and (piece(aList[i],'^',3) = cboSurgery.Text) then
+             and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) and (Length(tQuantity.Text) > 0) then
               begin
                 aMSBOS := StrToInt(piece(aList[i],'^',4));
@@ -3861,13 +4258,16 @@
                       aMSBOSContinue :=
                         MessageBox(PChar('The number of units ordered (' + tQuantity.Text +
-                                   ') for ' + aLabTest.TestName + ' exceeds the maximum number of units ('
-                                   + IntToStr(aMSBOS) +
-                                   ') for the ' + cboSurgery.text +
-                                   ' surgical procedure selected.' + CRLF + CRLF + 'Do you wish to continue?'),
-                                   PChar('Maximum Number of Units Exceeded'),
-                                   MB_YESNO);
+                         ') for ' + aLabTest.TestName + ' Exceeds the maximum number recommended ('
+                         + IntToStr(aMSBOS) +
+                         ') for the ' + cboSurgery.text +
+                         ' surgical procedure.' + CRLF +
+                         'If you need to order more than the maximum number of units, please enter a justification in the Comment box.'
+                          + CRLF + CRLF + 'Edit the Blood component Quantity?'),
+                         PChar('Maximum Number of Units Exceeded'),
+                         MB_YESNO);
+
                       RestoreTopMosts;
                     end;
-                    if aMSBOSContinue = 7 then
+                    if aMSBOSContinue = 6 then
                       begin
                         ShowMsg('Please enter a new quantity for ' + cboAvailComp.Text);
@@ -3927,8 +4327,37 @@
 
 procedure TfrmODBBank.tQuantityEnter(Sender: TObject);
+var
+  j: integer;
 begin
   inherited;
   tQuantity.SelLength := 2;
   tQuantity.SelectAll;
+  if Length(cboAvailComp.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
+end;
+
+procedure TfrmODBBank.txtImmedCollEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailTest.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
 end;
 
@@ -3970,3 +4399,20 @@
 end;
 
+procedure TfrmODBBank.calCollTimeEnter(Sender: TObject);
+var
+  j: integer;
+begin
+  inherited;
+  if Length(cboAvailTest.Text) > 0 then Exit;
+  for j := uSelectedItems.Count - 1 downto 0 do
+    begin
+      if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '1') then
+        begin
+          lvSelectionList.Items[j].Selected := true;
+          lvSelectionListClick(self);
+          Break;
+        end;
+    end;
+end;
+
 end.
