Procedure

TfrmODBBank.cboSurgeryChange

Module

fODBBank

Last Modified

7/15/2014 3:26:40 PM

Visibility

Public/Published

Owner

TfrmODBBank

Declaration

procedure cboSurgeryChange(Sender: TObject);

Calls Hierarchy


TfrmODBBank.cboSurgeryChange
 ├TfrmODBBank.ExtractTypeScreen
 ├TLabTest.Create
 │ ├LoadLabTestData
 │ ├GetOneSpecimen
 │ ├TLabTest.FillCollSampList
 │ ├TResponses.FindResponseByName
 │ ├TLabTest.IndexOfCollSamp
 │ ├GetOneCollSamp
 │ ├TLabTest.LoadAllSamples
 │ │ ├LoadSamples
 │ │ └TLabTest.FillCollSampList
 │ └TLabTest.SetCollSampDflts
 │   ├TResponses.FindResponseByName
 │   ├TLabTest.ChangeSpecimen
 │   └TLabTest.IndexOfCollSamp
 ├TfrmODBBank.ExtractMSBOS
 ├TResponses.Update
 │ ├TResponses.FindResponseByName
 │ └TResponses.IENForPrompt
 ├TfrmODBBank.DisableComponentControls
 └TResponses.GetOrderText
   ├TResponses.NextInstance
   ├TResponses.FindResponseByName
   ├TResponses.FormatResponse
   │ └TResponses.FindResponseByIEN
   └TResponses.AppendChildren
     ├TResponses.FindPromptByIEN
     ├TResponses.FindResponseByIEN
     └TResponses.FormatResponse...

Called-By Hierarchy


    TfrmODBBank.cboSurgeryChange
       TfrmODBBank.SetupDialog┤ 
   TfrmODBBank.SetOnQuickOrder┤ 
   TfrmODBBank.cboQuickClick┘ │ 
TfrmODBBank.cboAvailCompSelect┤ 
TfrmODBBank.cboAvailCompExit┘ │ 
   TfrmODBBank.tQuantityChange┘ 

Calls

Name Declaration Comments
TLabTest.Create constructor Create(const LabTestIEN: string; Responses: TResponses); -
TfrmODBBank.DisableComponentControls procedure DisableComponentControls; -
TfrmODBBank.ExtractMSBOS procedure ExtractMSBOS(OutList:TStrings; AList:TStrings); -
TfrmODBBank.ExtractTypeScreen procedure ExtractTypeScreen(OutList:TStrings; AList:TStrings); -
TResponses.GetOrderText function GetOrderText: string; -
TResponses.Update procedure Update(const APromptID: string; AnInstance: Integer; const AnIValue, AnEValue: string); -

Called-By

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


Source

4023  procedure TfrmODBBank.cboSurgeryChange(Sender: TObject);
4024  var
4025    aList, bList, cList: TStringList;
4026    i,j,aMSBOS,aMSBOSContinue: integer;
4027    x,aTypeScreen: string;
4028    handled,aGotTNS: boolean;
4029    xLabTest: TLabTest;
4030  begin
4031    inherited;
4032    cboSurgery.Text := StringReplace(cboSurgery.Text,CRLF,'  ',[rfReplaceAll]);
4033    aList := TStringList.Create;
4034    bList := TStringList.Create;
4035    cList := TStringList.Create;
4036    handled := false;
4037    //uGetTNS := 0;
4038    //aGotTNS := false;
4039    ExtractTypeScreen(aList, uVBECList);
4040    if aList.Count > 0 then aTypeScreen := aList[0];
4041    aList.Clear;
4042    bList.Clear;
4043    cList.Clear;
4044    try
4045      cboSurgery.DroppedDown := false;
4046      if (Length(cboSurgery.ItemID) > 0) then
4047        begin
4048          for j := 0 to uSelectedItems.Count - 1 do
4049            begin
4050              xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
4051              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
4052                begin
4053                  cList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3));
4054                end;
4055              xLabTest.Free;
4056            end;
4057        end;
4058      if (Length(cboSurgery.ItemID) > 0) and (Length(tQuantity.Text) > 0) and (Length(cboAvailComp.Text) > 0) then
4059        begin
4060          aList.Clear;
4061          ExtractMSBOS(aList, uVBECList);    //Get maximum units for selected Surgey
4062          for i := 0 to aList.Count - 1 do
4063            begin
4064              if (StrToInt(piece(aList[i],'^',1)) = aLabTest.ItemID)
4065               and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
4066                begin
4067                  aMSBOS := StrToInt(piece(aList[i],'^',4));
4068                  if (aMSBOS > 0) and (StrToInt(tQuantity.Text) > aMSBOS) then
4069                    begin
4070                      bList.Add(aLabTest.TestName + '^' + tQuantity.Text + '^' + IntToStr(aMSBOS));
4071                    end;
4072                  handled := true;
4073                  break;
4074                end;
4075            end;
4076        end;
4077      if (handled = false) and (Length(cboSurgery.ItemID) > 0) and (uSelectedItems.Count > 0) then
4078        begin
4079          aList.Clear;
4080          ExtractMSBOS(aList, uVBECList);    //Get maximum units for selected Surgey
4081          for j := 0 to uSelectedItems.Count - 1 do
4082            begin
4083              xLabTest := TLabTest.Create(piece(uSelectedItems[j],'^',2), Responses);
4084              for i := 0 to aList.Count - 1 do
4085                begin
4086                  if (piece(uSelectedItems[j],'^',1) = '0')
4087                   and (StrToInt(piece(aList[i],'^',1)) = xLabTest.ItemID)
4088                   and (uppercase((piece(aList[i],'^',3))) = uppercase(cboSurgery.Text)) then
4089                    begin
4090                      aMSBOS := StrToInt(piece(aList[i],'^',4));
4091                      if (aMSBOS > 0) and (length(piece(uSelectedItems[j],'^',3)) > 0) and (StrToInt(piece(uSelectedItems[j],'^',3)) > aMSBOS) then
4092                        begin
4093                          bList.Add(xLabTest.TestName + '^' + piece(uSelectedItems[j],'^',3) + '^' + IntToStr(aMSBOS));
4094                        end;
4095                      break;
4096                    end;
4097                end;
4098              xLabTest.Free;
4099            end;
4100        end;
4101      if (uChangingMSBOS = false) and (cList.Count > 0) then
4102        begin
4103          lblNoBloodReq.Visible := true;
4104          with Application do
4105            begin
4106              NormalizeTopMosts;
4107              aMSBOSContinue :=
4108                MessageBox(PChar('No blood is required for the surgical procedure: ' + cboSurgery.text +
4109                 '.' + CRLF +
4110                 'If you still need to order any components, please enter a justification in the Comment box.'
4111                  + CRLF + CRLF + 'Do you want me to remove ALL the component orders you''ve just entered? '),
4112                 PChar('No Blood Required'),MB_YESNO);
4113              RestoreTopMosts;
4114            end;
4115          if aMSBOSContinue = 6 then
4116            begin
4117              tQuantity.Text := '';
4118              bList.Clear;
4119              for j := uSelectedItems.Count - 1 downto 0 do
4120                begin
4121                  if not(lvSelectionList.Items[j] = nil) and (piece(uSelectedItems[j],'^',1) = '0') then
4122                    begin
4123                      lvSelectionList.Items[j].Delete;
4124                      uSelectedItems.Delete(j);
4125                      Responses.Update('ORDERABLE', (j+1) ,'', '');
4126                      Responses.Update('MODIFIER', (j+1), '', '');
4127                      Responses.Update('QTY', (j+1), '', '');
4128                    end;
4129                end;
4130              cboAvailComp.Text := '';
4131              cboAvailComp.ItemIndex := -1;
4132              cboModifiers.Text := '';
4133              cboModifiers.ItemIndex := -1;
4134              lblNoBloodReq.Visible := false;
4135              //if fODBBank. Active then cboAvailTest.SetFocus;
4136              lblTNS.Caption := '';
4137              lblTNS.Visible := false;
4138              uGetTNS := 0;
4139              aGotTNS := false;
4140              DisableComponentControls;
4141              for i := lvSelectionList.Items.Count - 1 downto 0 do
4142                begin
4143                  if lvSelectionList.Items[i].SubItems[3] = aTypeScreen then
4144                    begin
4145                      aGotTNS := true;
4146                      break;
4147                    end;
4148                end;
4149              for i := uSelectedItems.Count - 1 downto 0 do
4150                begin
4151                  if (aGotTNS = false) and not(piece(uSelectedItems[i],'^',1) = '1') and (uTNSOrders.Count < 1) and (piece(uSelectedItems[i],'^',5) = '1') then //CQ 17349
4152                    begin
4153                      uGetTnS := 1;
4154                      lblTNS.Caption := 'TYPE + SCREEN must be added to order';
4155                      lblTNS.Visible := true;
4156                      memMessage.Text := 'TYPE + SCREEN must be added to order';
4157                      pnlMessage.Visible := true;
4158                      pnlDiagnosticTests.Caption := 'Diagnostic Tests*';
4159                      break;
4160                    end
4161                    else pnlDiagnosticTests.Caption := 'Diagnostic Tests';
4162                end;
4163            end;
4164        end
4165        else
4166          begin
4167            lblNoBloodReq.Visible := false;
4168          end;
4169  
4170      if (uChangingMSBOS = false) and (bList.Count > 0) then
4171        begin
4172          x := '';
4173          for i := 0 to bList.Count - 1 do
4174            begin
4175              x := x + CRLF + piece(bList[i],'^',1) + ' (' + piece(bList[i],'^',2) + ') Max allowed: ' + piece(bList[i],'^',3);
4176            end;
4177          with Application do
4178            begin
4179              NormalizeTopMosts;
4180              aMSBOSContinue :=
4181                MessageBox(PChar('The number of units ordered' + x + CRLF +
4182                 'Exceeds the maximum number recommended for '
4183                 + cboSurgery.text + CRLF + CRLF +
4184                 'If you need to order more than the recommended maximum units, please enter a justification in the Comment box.')
4185                 ,PChar('Maximum Number of Units Exceeded'),
4186                 MB_OK);
4187              RestoreTopMosts;
4188            end;
4189        end;
4190      if uSelectedItems.Count > 0 then
4191        if Length(cboSurgery.Text) > 0 then
4192          Responses.Update('MISC',1,cboSurgery.Text,cboSurgery.Text);
4193      uSelSurgery := 0;
4194      if Length(cboSurgery.Text) > 0 then
4195        begin
4196          if length(cboSurgery.ItemID) > 0 then uSelSurgery := cboSurgery.ItemID;
4197          cboReasons.Text := cboSurgery.Text;
4198          Responses.Update('REASON',1,cboReasons.Text,cboReasons.Text);
4199        end;
4200      memOrder.Text := Responses.OrderText;
4201      finally
4202        aList.Free;
4203        bList.Free;
4204        cList.Free;
4205      end;
4206  end;