Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Chart/Orders/uOrders.pas

    r456 r829  
    55uses
    66  Windows, Messages, SysUtils, Classes, Controls, Forms, uConst, rOrders, ORFn,
    7   Dialogs, ORCtrls, stdCtrls, strUtils, fODBase;
     7  Dialogs, ORCtrls, stdCtrls, strUtils, fODBase, fODMedOIFA;
    88
    99type
    1010  EOrderDlgFail = class(Exception);
     11
     12  //FQOAltOI = record
     13  //OI: integer;
     14  //end;
    1115
    1216{ Ordering Environment }
     
    5862procedure QuickOrderListEdit;
    5963function RefNumFor(AnOwner: TComponent): Integer;
    60 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0);
     64procedure PrintOrdersOnSignReleaseMult(OrderList, ClinicLst, WardLst: TStringList; Nature: Char; EncLoc, WardLoc: integer; EncLocName, WardLocName: string);
     65procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0; PrintName: string = '');
    6166procedure SetFontSize( FontSize: integer);
    6267procedure NextMove(var NMRec: TNextMoveRec; LastIndex: Integer; NewIndex: Integer);
     68//function GetQOAltOI: integer;
    6369
    6470{ Inpatient medication for Outpatient}
     
    7985ProcDisp : Integer;
    8086ImgDisp  : Integer;
     87DietDisp : Integer;
    8188NonVADisp: Integer;
    8289MedsInDlgIen  : Integer;
     
    9299OriginalMedsInHeight: Integer;
    93100OriginalNonVAMedsHeight: Integer;
     101PassDrugTstCall: boolean;
    94102
    95103implementation
     
    100108     fLkUpLocation, fOrdersPrint, fOMAction, fARTAllgy, fOMHTML, fOrders, rODBase,
    101109     fODChild, fMeds, rMeds, rPCE, frptBox, fODMedNVA, fODChangeUnreleasedRenew, rODAllergy,
    102      UBAGlobals, fClinicWardMeds, uTemplateFields;
     110     UBAGlobals, fClinicWardMeds, uTemplateFields, VAUtils;
    103111
    104112var
     
    113121  uOrderSetTime: TFMDateTime;
    114122  uNewMedDialog: Integer;
     123  //QOALTOI: FQOAltOI;
    115124
    116125const
     
    453462    tmpList.Add('Cannot be released to service(s) because of the following happened action(s):');
    454463    tmpList.Add(' ');
    455     tmpList.AddStrings(TStrings(AnErrLst));
     464    FastAddStrings(TStrings(AnErrLst), tmpList);
    456465    ReportBox(tmpList,'Cannot be released to service(s)',False);
    457466    tmpList.Free;
     
    472481  ProcDisp := DisplayGroupByName('PROC');
    473482  ImgDisp  := DisplayGroupByName('XRAY');
     483  DietDisp := DisplayGroupByName('DO');
    474484  NonVADisp := DisplayGroupByName('NV RX');
    475485  MedsInDlgIen  := DlgIENForName('PSJ OR PAT OE');
     
    763773  end else
    764774  begin
    765     //ShowMessage('Order Dialogs of type "Action" are available in List Manager only.');
     775    //Show508Message('Order Dialogs of type "Action" are available in List Manager only.');
    766776    Result := False;
    767777  end;
     
    774784  TC_NO_DEA     = 'DEA# Required';
    775785  TC_IMO_ERROR  = 'Inpatient medication order on outpatient authorization required';
     786  TX_EVTDEL_DIET_CONFLICT = 'Have you done either of the above?';
     787  TC_EVTDEL_DIET_CONFLICT = 'Possible delayed order conflict';
    776788var
    777789  ResolvedDialog: TOrderDialogResolved;
    778   x, EditedOrder, chkCopay, OrderID, PkgInfo,OrderPtEvtID,OrderEvtID,NssErr: string;
    779   ODItem: integer;
    780   IsInpatient, IsAnIMOOrder: boolean;
    781   IsPsoSupply,IsDischargeOrPass,IsPharmacyOrder,IsConsultOrder,ForIMO: boolean;
     790  x, EditedOrder, chkCopay, OrderID, PkgInfo,OrderPtEvtID,OrderEvtID,NssErr, tempUnit, tempSupply, tempDrug, tempSch: string;
     791  temp,tempDur,tempQuantity, tempRefills: string;
     792  i, ODItem, tempOI, ALTOI: integer;
     793  DrugCheck, IsInpatient, IsAnIMOOrder, DrugTestDlgType: boolean;
     794  IsPsoSupply,IsDischargeOrPass,IsPharmacyOrder,IsConsultOrder,ForIMO, IsNewOrder: boolean;
    782795  tmpResp: TResponse;
     796  CxMsg: string;
     797  AButton: TButton;
    783798begin
    784799  IsPsoSupply := False;
     
    787802  IsAnIMOOrder  := False;
    788803  ForIMO := False;
     804  IsNewOrder := True;
     805  PassDrugTstCall := False;
     806  DrugCheck := false;
     807  DrugTestDlgType := false;
     808  //QOAltOI.OI := 0;
    789809  // double check environment before continuing with order
    790810  if uOrderDialog <> nil then uOrderDialog.Close; // then x := uOrderDialog.Name else x := '';
     
    792812  if CharAt(AnID, 1) = 'X' then
    793813  begin
     814    IsNewOrder := False;
     815   // if PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E')=false then Exit;
    794816    ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_CHANGE,   x);
    795817    if ( Length(x)<1 ) and not (AnEvent.EventIFN > 0) then
     
    800822      x := RetrieveOrderText(Copy(AnID, 2, Length(AnID))) + #13#10 + x;
    801823    if ShowMsgOn(Length(x) > 0, x, TC_NO_CHANGE) then Exit;
     824    DrugCheck := true;
    802825  end;
    803826  if CharAt(AnID, 1) = 'C' then
    804827  begin
     828    IsNewOrder := False;
     829    //if PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E')=false then Exit;
    805830    ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_COPY,     x);
    806831    if Length(x) > 0 then
    807832      x := RetrieveOrderText(Copy(AnID, 2, Length(AnID))) + #13#10 + x;
    808     if ShowMsgOn(Length(x) > 0, x, TC_NO_COPY)   then Exit;
     833    if ShowMsgOn(Length(x) > 0, x, TC_NO_COPY) then Exit;
     834    DrugCheck := true;
    809835 end;
    810836  if CharAt(AnID, 1) = 'T' then
    811837  begin
     838    IsNewOrder := False;
     839    if (XfInToOutNow = true) and (PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E', false)=false) then Exit;
     840    if (XfInToOutNow = false) then
     841      begin
     842       if (XferOuttoInOnMeds = True) and (PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E', true)=false) then Exit;
     843       if (XferOuttoInOnMeds = False) and (PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E', False)=false) then Exit;
     844      end;
    812845    ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_TRANSFER, x);
    813846    if Length(x) > 0 then
     
    824857  else if ( (IsAnIMOOrder) and (AnEvent.EventIFN <= 0) ) then
    825858    ForIMO := True;
    826 
    827859  OrderPtEvtID := GetOrderPtEvtID(Copy(AnID, 2, Length(AnID)));
    828860  OrderEvtID := Piece(EventInfo(OrderPtEvtID),'^',2);
     
    831863  ResolvedDialog.InputID := AnID;
    832864  BuildResponses(ResolvedDialog, GetKeyVars, AnEvent, ForIMO);
     865  if (ResolvedDialog.DisplayGroup = InPtDisp) or (ResolvedDialog.DisplayGroup = ClinDisp) then DrugTestDlgType := true;
     866  if (DrugCheck = true) and (ResolvedDialog.DisplayGroup = OutPtDisp) and
     867  (PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E', false)=false) then Exit;
     868  if (DrugCheck = true) and (DrugTestDlgType = true) and (PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E', true)=false) then Exit;
     869  if (IsNewOrder = True) and (ResolvedDialog.DialogType = 'Q') and
     870     ((ResolvedDialog.DisplayGroup = OutptDisp) or (DrugTestDlgType = true)) then
     871    begin
     872      if (PassDrugTest(ResolvedDialog.DialogIEN, 'Q', DrugTestDlgType)=false) then Exit
     873      else PassDrugTstCall := True;
     874    end;
    833875  if (ForIMO and ( (ResolvedDialog.DialogIEN = MedsInDlgIen)
    834876    or (ResolvedDialog.DialogIEN = MedsIVDlgIen)) ) then
     
    866908     if (Length(NssErr) > 1) then
    867909     begin
    868        if (NssErr <> 'OTHER') then
    869          ShowMessage('The order contains invalid non-standard schedule.');
     910       if (NssErr <> 'OTHER') and (NssErr <> 'schedule is not defined.') then
     911         ShowMsg('The order contains invalid non-standard schedule.');
    870912       NSSchedule := True;
    871913       ResolvedDialog.QuickLevel := 0;
     
    878920      if not IsValidSchedule(Copy(AnID, 2, Length(AnID))) then
    879921      begin
    880         ShowMessage('The order contains invalid non-standard schedule.');
     922        ShowMsg('The order contains invalid non-standard schedule.');
    881923        NSSchedule := True;
    882924      end;
     
    884926    if NSSchedule then ResolvedDialog.QuickLevel := 0;
    885927  end;
     928 (* if (ResolvedDialog.DialogType = 'Q') and ((ResolvedDialog.FormID = OD_MEDINPT) or (ResolvedDialog.FormID = OD_MEDOUTPT)) then
     929    begin
     930      temp := '';
     931      tempOI := GetQOOrderableItem(ResolvedDialog.InputID);
     932      if tempOI >0 then
     933        begin
     934          ALTOI := tempOI;
     935          CheckFormularyOI(AltOI,temp,True);
     936          if ALTOI <> tempOI then
     937            begin
     938              ResolvedDialog.QuickLevel := 0;
     939              QOAltOI.OI := ALTOI;
     940            end;
     941        end;
     942    end; *)
     943  //   ((ResolvedDialog.DisplayGroup = InptDisp) or (ResolvedDialog.DisplayGroup = OutptDisp) or (ResolvedDialog.DisplayGroup = MedsDisp)) then
     944 //    ResolvedDialog.QuickLevel := 0;
    886945  with ResolvedDialog do if (QuickLevel = QL_VERIFY) and (HasTemplateField(ShowText)) then QuickLevel := QL_DIALOG;
     946
     947  // Check for potential conflicting auto-accept delayed-release diet orders (CQ #10946 - v27.36 - RV)
     948  with ResolvedDialog do if (QuickLevel = QL_AUTO) and (DisplayGroup = DietDisp) and (AnEvent.EventType <> 'C') then
     949  begin
     950    AButton := TButton.Create(Application);
     951    try
     952      CheckForAutoDCDietOrders(AnEvent.EventIFN, DisplayGroup, '', CxMsg, AButton);
     953      if CxMsg <> '' then
     954      begin
     955        if InfoBox(CxMsg + CRLF + CRLF + TX_EVTDEL_DIET_CONFLICT,
     956           TC_EVTDEL_DIET_CONFLICT,
     957           MB_ICONWARNING or MB_YESNO) = ID_NO
     958           then QuickLevel := QL_DIALOG;
     959      end;
     960    finally
     961      AButton.Free;
     962    end;
     963  end;
     964
    887965  with ResolvedDialog do
    888966  begin
     
    10351113          else
    10361114             begin
     1115             if uOrderDialog.DisplayGroup = OutptDisp then
     1116               begin
     1117                 tempUnit := '';
     1118                 tempSupply := '';
     1119                 tempDrug := '';
     1120                 tempSch := '';
     1121                 tempDur := '';
     1122                 tmpResp := uOrderDialog.Responses.FindResponseByName('SUPPLY', 1);
     1123                 if tmpResp = nil then tempSupply := '0'
     1124                 else tempSupply := tmpResp.EValue;
     1125                 tmpResp := uOrderDialog.Responses.FindResponseByName('QTY', 1);
     1126                 if tmpResp = nil then tempQuantity := '0'
     1127                 else tempQuantity := tmpResp.EValue;
     1128                 tmpResp := uOrderDialog.Responses.FindResponseByName('REFILLS', 1);
     1129                 if tmpResp = nil then tempRefills := '0'
     1130                 else tempRefills := tmpResp.EValue;
     1131                 tmpResp := uOrderDialog.Responses.FindResponseByName('ORDERABLE', 1);
     1132                 tempOI := StrToIntDef(tmpResp.IValue,0);
     1133                 i := uORderDialog.Responses.NextInstance('DOSE',0);
     1134                 while i > 0 do
     1135                   begin
     1136                      x := Piece(uOrderDialog.Responses.IValueFor('DOSE',i), '&', 3);
     1137                      tempUnit := tempUnit + X + U;
     1138                      x := uOrderDialog.Responses.IValueFor('SCHEDULE',i);
     1139                      tempSch := tempSch + x + U;
     1140                      x := uOrderDialog.Responses.IValueFor('DRUG', i);
     1141                      tempDrug := Piece(x, U, 1);
     1142                      i := Responses.NextInstance('DOSE', i);
     1143                      x := UORderDialog.Responses.IValueFor('DAYS', i);
     1144                      tempDur := tempDur + x + '~';
     1145                      x := uOrderDialog.Responses.IValueFor('CONJ', i);
     1146                      tempDur := tempDur + x + U;
     1147                   end;
     1148                 if ValidateDrugAutoAccept(tempDrug, tempUnit, tempSch, tempDur, tempOI, StrtoInt(tempSupply), StrtoInt(tempQuantity), StrtoInt(tempRefills)) = false then Exit;
     1149               end;
    10371150             cmdAcceptClick(Application);  // auto-accept order
    10381151             Result := uOrderDialog.AcceptOK;
    10391152
    10401153             //BAPHII 1.3.2
    1041              //showmessage('DEBUG: About to copy BA CI''s to copied order from Order: '+AnID+'#13'+' in uOrders.ActivateOrderDialog()');
     1154             //Show508Message('DEBUG: About to copy BA CI''s to copied order from Order: '+AnID+'#13'+' in uOrders.ActivateOrderDialog()');
    10421155
    10431156             //End BAPHII 1.3.2
     
    10611174  if (ResolvedDialog.DialogType = 'X') and not Changes.ExistForOrder(EditedOrder)
    10621175    then UnlockOrder(EditedOrder);
    1063 
     1176  //QOAltOI.OI := 0;
    10641177end;
    10651178
     
    11121225  uOrderHTML.ShowModal;
    11131226  ASetList := TStringList.Create;
    1114   ASetList.Assign(uOrderHTML.SetList);
     1227  FastAssign(uOrderHTML.SetList, ASetList);
    11151228  uOrderHTML.Release;
    11161229  if ASetList.Count = 0 then Exit;
     
    16691782end;
    16701783
    1671 
    1672 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0);
     1784procedure PrintOrdersOnSignReleaseMult(OrderList, ClinicLst, WardLst: TStringList; Nature: Char; EncLoc, WardLoc: integer;
     1785EncLocName, WardLocName: string);
     1786var
     1787i,j: integer;
     1788tempOrder: string;
     1789tempOrderList: TStringList;
     1790begin
     1791  tempOrderList := TStringList.Create;
     1792  if (ClinicLst <> nil) and (ClinicLst.Count > 0) then
     1793    begin
     1794      for i := 0 to ClinicLst.Count - 1 do
     1795        begin
     1796          tempOrder := ClinicLst.Strings[i];
     1797          for j := 0 to OrderList.Count - 1 do
     1798            if Piece(OrderList.Strings[j], U,1) = tempOrder then tempOrderList.Add(OrderList.Strings[j]);
     1799        end;
     1800      if tempOrderList.Count > 0 then PrintOrdersOnSignRelease(tempOrderList, Nature, EncLoc, EncLocName);
     1801    end;
     1802  if (WardLst <> nil) and (WardLst.Count > 0) then
     1803    begin
     1804      if tempOrderList.Count > 0 then
     1805        begin
     1806          tempOrderList.Free;
     1807          tempOrderList := TStringList.Create;
     1808        end;
     1809      for i := 0 to WardLst.Count - 1 do
     1810        begin
     1811          tempOrder := WardLst.Strings[i];
     1812          for j := 0 to OrderList.Count - 1 do
     1813            if Piece(OrderList.Strings[j], U,1) = tempOrder then tempOrderList.Add(OrderList.Strings[j]);
     1814        end;
     1815      if tempOrderList.Count > 0 then PrintOrdersOnSignRelease(tempOrderList, Nature, WardLoc, WardLocName);
     1816    end;
     1817    tempOrderList.Free;
     1818end;
     1819
     1820procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0; PrintName: string = '');
    16731821const
    16741822  TX_NEW_LOC1   = 'The patient''s location has changed to ';
     
    16911839          then Encounter.Location := ALocation;
    16921840        end;
    1693     end
    1694   else
    1695     Encounter.Location := PrintLoc;
     1841    end;
     1842  //else
     1843  //Encounter.Location := PrintLoc;
     1844  if PrintLoc = 0
     1845    then PrintLoc := CommonLocationForOrders(OrderList);
     1846  if (PrintLoc = 0) and (Encounter.Location > 0) then PrintLoc := Encounter.Location;
     1847 
     1848  if PrintLoc = 0 then                      // location required for DEVINFO
     1849  begin
     1850    LookupLocation(ALocation, AName, LOC_ALL, TX_LOC_PRINT);
     1851    if ALocation > 0 then
     1852      begin
     1853        PrintLoc := ALocation;
     1854        Encounter.Location := ALocation;
     1855      end;
     1856  end;
     1857  if printLoc = 0 then frmFrame.DisplayEncounterText;
     1858  if PrintLoc <> 0 then
     1859  begin
     1860    SetupOrdersPrint(OrderList, DeviceInfo, Nature, False, PrintIt, PrintName, PrintLoc);
     1861    if PrintIt then
     1862      PrintOrdersOnReview(OrderList, DeviceInfo, PrintLoc)
     1863    else
     1864      PrintServiceCopies(OrderList, PrintLoc);
     1865  end
     1866  else InfoBox(TX_SIGN_LOC, TC_REQ_LOC, MB_OK or MB_ICONWARNING);
     1867 (*   Encounter.Location := PrintLoc;
    16961868  if Encounter.Location = 0
    16971869    then Encounter.Location := CommonLocationForOrders(OrderList);
     
    17011873    if ALocation > 0 then Encounter.Location := ALocation;
    17021874  end;
    1703   frmFrame.DisplayEncounterText;
     1875  if printLoc = 0 then frmFrame.DisplayEncounterText;
    17041876  if Encounter.Location <> 0 then
    17051877  begin
    1706     SetupOrdersPrint(OrderList, DeviceInfo, Nature, False, PrintIt);
     1878    SetupOrdersPrint(OrderList, DeviceInfo, Nature, False, PrintIt, PrintName);
    17071879    if PrintIt then
    17081880      PrintOrdersOnReview(OrderList, DeviceInfo)
     
    17101882      PrintServiceCopies(OrderList);
    17111883  end
    1712   else InfoBox(TX_SIGN_LOC, TC_REQ_LOC, MB_OK or MB_ICONWARNING);
     1884  else InfoBox(TX_SIGN_LOC, TC_REQ_LOC, MB_OK or MB_ICONWARNING);  *)
    17131885end;
    17141886
     
    17311903   NMRec.LastIndex := NewIndex;
    17321904end;
     1905
     1906(*function GetQOAltOI: integer;
     1907begin
     1908  Result := QOAltOI.OI;
     1909end; *)
    17331910
    17341911function IsIMODialog(DlgID: integer): boolean; //IMO
Note: See TracChangeset for help on using the changeset viewer.