Procedure

TfrmODBBank.btnRemoveClick

Module

fODBBank

Last Modified

7/15/2014 3:26:40 PM

Visibility

Public/Published

Owner

TfrmODBBank

Declaration

procedure btnRemoveClick(Sender: TObject);

Calls Hierarchy


TfrmODBBank.btnRemoveClick
 ├TfrmODBBank.ExtractTypeScreen
 ├TResponses.Clear
 ├TfrmODBBank.InitDialog
 │ ├TLabTest.Destroy
 │ └TfrmODBBank.DisableCommentPanels
 ├TResponses.Update
 │ ├TResponses.FindResponseByName
 │ └TResponses.IENForPrompt
 ├TfrmODBBank.ValidCollTime
 │ └StrToFMDateTime
 └TResponses.GetOrderText
   ├TResponses.NextInstance
   ├TResponses.FindResponseByName
   ├TResponses.FormatResponse
   │ └TResponses.FindResponseByIEN
   └TResponses.AppendChildren
     ├TResponses.FindPromptByIEN
     ├TResponses.FindResponseByIEN
     └TResponses.FormatResponse...

Called-By Hierarchy


   TfrmODBBank.btnRemoveClick
    TfrmODBBank.SetupDialog┤ 
TfrmODBBank.SetOnQuickOrder┘ 
TfrmODBBank.cboQuickClick┘   

Calls

Name Declaration Comments
TResponses.Clear procedure Clear; overload; -
TfrmODBBank.ExtractTypeScreen procedure ExtractTypeScreen(OutList:TStrings; AList:TStrings); -
TResponses.GetOrderText function GetOrderText: string; -
TfrmODBBank.InitDialog procedure InitDialog; override; -
TResponses.Update procedure Update(const APromptID: string; AnInstance: Integer; const AnIValue, AnEValue: string); -
TfrmODBBank.ValidCollTime function ValidCollTime(UserEntry: string): string; -

Called-By

Name Declaration Comments
TfrmODBBank.SetOnQuickOrder procedure SetOnQuickOrder; -
TfrmODBBank.SetupDialog procedure SetupDialog(OrderAction: Integer; const ID: string); override; -


Source

3573  procedure TfrmODBBank.btnRemoveClick(Sender: TObject);
3574  var
3575    i,j,curAdd: integer;
3576    x, aName, aModifier, aReason, aTypeScreen: string;
3577    aList: TStringList;
3578    aSel, aSelTst, aSelComp, aGotTNS : boolean;
3579  begin
3580    inherited;
3581    aList := TStringList.Create;
3582    try
3583      curAdd := 1;
3584      aModifier := '';
3585      aReason := '';
3586      aTypeScreen := '';
3587      aSel := false;
3588      aSelTst := false;
3589      aSelComp := false;
3590      aGotTNS := false;
3591      ExtractTypeScreen(aList, uVBECList);
3592      if aList.Count > 0 then aTypeScreen := aList[0];
3593      aList.Clear;
3594      if length(cboModifiers.ItemID) > 0 then aModifier := cboModifiers.Items[cboModifiers.ItemIndex];
3595      if length(cboReasons.ItemID) > 0 then aReason := cboReasons.Items[cboReasons.ItemIndex];
3596      if lvSelectionList.Items.Count < 1 then
3597        begin
3598          ShowMsg('There is nothing in the list to remove.');
3599          exit;
3600        end;
3601      cboAvailComp.ItemIndex := -1;
3602      tQuantity.Text := '';
3603      tQuantity.Enabled := false;
3604      lblQuantity.Enabled := false;
3605      cboAvailTest.ItemIndex := -1;
3606      uGetTnS := 0;
3607      lblTNS.Caption := '';
3608      lblTNS.Visible := false;
3609      memMessage.Text := '';
3610      pnlMessage.Visible := false;
3611      pnlDiagnosticTests.Caption := 'Diagnostic Tests';
3612      with lvSelectionList do
3613        begin
3614          for i := lvSelectionList.Items.Count - 1 downto 0 do
3615            begin
3616              if lvSelectionList.Items[i].Selected = true then
3617                begin
3618                  aSel := true;
3619                  for j := uSelectedItems.Count - 1 downto 0 do
3620                    if lvSelectionList.Items[i].SubItems[3] = piece(uSelectedItems[j],'^',2) then
3621                      begin
3622                        uSelectedItems.Delete(j);
3623                        lvSelectionList.Items[i].Delete;
3624                        break;
3625                      end;
3626                end;
3627            end;
3628        end;
3629      for i := lvSelectionList.Items.Count - 1 downto 0 do
3630        begin
3631          if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
3632            begin
3633              aGotTNS := true;
3634              break;
3635            end;
3636        end;
3637      if aGotTNS = false then
3638        begin
3639          for i := uSelectedItems.Count - 1 downto 0 do
3640            begin
3641              if not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
3642                begin
3643                  uGetTnS := 1;
3644                  lblTNS.Caption := 'TYPE + SCREEN must be added to order';
3645                  lblTNS.Visible := true;
3646                  memMessage.Text := 'TYPE + SCREEN must be added to order';
3647                  pnlMessage.Visible := true;
3648                  pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
3649                  break;
3650                end
3651                else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
3652            end;
3653        end;
3654      if (aSel = false) and (lvSelectionList.Items.Count > 0) then
3655        begin
3656          ShowMsg('Please select an item from the list to be removed.');
3657          exit;
3658        end;
3659      Responses.Clear;
3660      pnlDiagnosticTests.Caption := 'Diagnostic Tests';
3661      lblCollTime.Caption := 'Collection Date/Time';
3662      lblCollType.Caption := 'Collection Type';
3663      lblQuantity.Caption := 'Quantity';
3664      lblWanted.Caption := 'Date/Time Wanted';
3665      lblReason.Caption := 'Reason for Request';
3666      if lvSelectionList.Items.Count < 1 then
3667        begin
3668          uGetTnS := 0;
3669          lblTNS.Caption := '';
3670          lblTNS.Visible := false;
3671          memMessage.Text := '';
3672          pnlMessage.Visible := false;
3673          FLastItemID := '';
3674          InitDialog;
3675          cboModifiers.ItemIndex := -1;
3676          cboAvailTest.ItemIndex := -1;
3677          cboAvailComp.ItemIndex := -1;
3678          cboCollType.ItemIndex := -1;
3679          cboCollTime.ItemIndex := -1;
3680          cboQuick.ItemIndex := -1;
3681          calWantTime.Text := '';
3682          GroupBox1.Visible := true;
3683          tQuantity.Text := '';
3684          FLastCollType := '';
3685          FLastCollTime := '';
3686          FLastLabCollTime := '';
3687          txtImmedColl.Text := '';
3688          calCollTime.text := '';
3689          lblNoBloodReq.Visible := false;
3690        end;
3691      for i := 0 to uSelectedItems.Count - 1 do
3692        begin
3693          aName := lvSelectionList.Items[i].Caption;
3694          x := uSelectedItems[i];
3695          if piece(x,'^',1) = '1' then    //Diagnostic Test related fields
3696            begin
3697              if Length(piece(x,'^',2)) > 0 then Responses.Update('ORDERABLE', CurAdd, piece(x,'^',2), aName);
3698              lblCollTime.Caption := 'Collection Date/Time*';
3699              lblCollType.Caption := 'Collection Type*';
3700              aSelTst := true;
3701            end
3702          else
3703            begin
3704              if Length(piece(x,'^',2)) > 0 then Responses.Update('ORDERABLE', CurAdd, piece(x,'^',2), aName);
3705              if Length(piece(x,'^',3)) > 0 then Responses.Update('QTY', CurAdd, piece(x,'^',3), piece(x,'^',3));
3706              if Length(piece(x,'^',4)) > 0 then Responses.Update('MODIFIER', CurAdd, piece(x,'^',4), aModifier);
3707              if Length(piece(x,'^',5)) > 0 then Responses.Update('SPECSTS', CurAdd, pieces(x,'^',5,7), piece(x,'^',5));
3708              cboModifiers.ItemIndex := -1;
3709              cboAvailComp.ItemIndex := -1;
3710              tQuantity.Text := '';
3711              lblQuantity.Caption := 'Quantity*';
3712              lblWanted.Caption := 'Date/Time Wanted*';
3713              lblReason.Caption := 'Reason for Request*';
3714              //aSelComp := true;
3715            end;
3716          Inc(CurAdd);
3717        end;
3718      if aSelTst = false then
3719        begin
3720          cboCollType.ItemIndex := -1;
3721          cboCollTime.ItemIndex := -1;
3722          calCollTime.Text := '';
3723        end;
3724      {if aSelcomp = false then
3725        lblNoBloodReq.Visible := false
3726      else
3727        lblNoBloodReq.Visible := true;  }
3728      if Length(calWantTime.Text) > 0 then Responses.Update('DATETIME',1,ValidCollTime(calWantTime.Text),calWantTime.Text);
3729      if cboCollType.ItemID = 'LC' then
3730        begin
3731          with cboCollTime do
3732            if Length(ItemID) > 0 then
3733              begin
3734                Responses.Update('START', 1, Copy(ItemID, 2, 999), Copy(ItemID, 2, 999));
3735                FLastLabCollTime := ItemID + U + Text;
3736              end
3737            else if Length(Text) > 0 then
3738              begin
3739                Responses.Update('START', 1, ValidCollTime(Text), Text) ;
3740                FLastLabCollTime := ValidCollTime(Text);
3741              end;
3742        end
3743      else
3744        begin
3745          with calCollTime do
3746            if FMDateTime > 0 then
3747              begin
3748                Responses.Update('START', 1, ValidCollTime(Text), Text);
3749                FLastColltime := ValidCollTime(Text);
3750              end
3751            else
3752              begin
3753                Responses.Update('START', 1, '', '') ;
3754                FLastCollTime := '';
3755              end;
3756        end;
3757      with cboCollType do if Length(ItemID) > 0 then
3758        begin
3759          Responses.Update('COLLECT', 1, ItemID, ItemID) ;
3760          FLastCollType := ItemID;
3761        end;
3762      if Length(cboUrgency.Text) > 0 then Responses.Update('URGENCY',1,cboUrgency.ItemID,cboUrgency.Text);
3763      if Length(memDiagComment.Text) > 0 then Responses.Update('COMMENT',1,memDiagComment.Text,memDiagComment.Text);
3764      if Length(cboSurgery.Text) > 0 then Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
3765      if Length(cboReasons.Text) > 0 then Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
3766      if chkConsent.Checked = true then Responses.Update('YN',1,'1','Yes');
3767      memOrder.Text := Responses.OrderText;
3768      CurAdd := 1;
3769      if uRaw.Count > 0 then
3770        for j := 0 to uRaw.Count - 1 do
3771          begin
3772            if Length(uRaw[j]) > 0 then Responses.Update('RESULTS', CurAdd, uRaw[j], piece(uRaw[j],'^',1));
3773            Inc(CurAdd);
3774          end;
3775      if uSelectedItems.Count < 1 then
3776        begin
3777          uGetTnS := 0;
3778          lblTNS.Caption := '';
3779          lblTNS.Visible := false;
3780          memMessage.Text := '';
3781          pnlMessage.Visible := false;
3782          GroupBox1.Visible := true;
3783          pnlDiagnosticTests.Caption := 'Diagnostic Tests';
3784        end;
3785    finally
3786      aList.Free;
3787    end;
3788  end;