Changeset 829 for cprs/trunk/CPRS-Chart/Orders/uOrders.pas
- Timestamp:
- Jul 7, 2010, 4:31:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/trunk/CPRS-Chart/Orders/uOrders.pas
r456 r829 5 5 uses 6 6 Windows, Messages, SysUtils, Classes, Controls, Forms, uConst, rOrders, ORFn, 7 Dialogs, ORCtrls, stdCtrls, strUtils, fODBase ;7 Dialogs, ORCtrls, stdCtrls, strUtils, fODBase, fODMedOIFA; 8 8 9 9 type 10 10 EOrderDlgFail = class(Exception); 11 12 //FQOAltOI = record 13 //OI: integer; 14 //end; 11 15 12 16 { Ordering Environment } … … 58 62 procedure QuickOrderListEdit; 59 63 function RefNumFor(AnOwner: TComponent): Integer; 60 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0); 64 procedure PrintOrdersOnSignReleaseMult(OrderList, ClinicLst, WardLst: TStringList; Nature: Char; EncLoc, WardLoc: integer; EncLocName, WardLocName: string); 65 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0; PrintName: string = ''); 61 66 procedure SetFontSize( FontSize: integer); 62 67 procedure NextMove(var NMRec: TNextMoveRec; LastIndex: Integer; NewIndex: Integer); 68 //function GetQOAltOI: integer; 63 69 64 70 { Inpatient medication for Outpatient} … … 79 85 ProcDisp : Integer; 80 86 ImgDisp : Integer; 87 DietDisp : Integer; 81 88 NonVADisp: Integer; 82 89 MedsInDlgIen : Integer; … … 92 99 OriginalMedsInHeight: Integer; 93 100 OriginalNonVAMedsHeight: Integer; 101 PassDrugTstCall: boolean; 94 102 95 103 implementation … … 100 108 fLkUpLocation, fOrdersPrint, fOMAction, fARTAllgy, fOMHTML, fOrders, rODBase, 101 109 fODChild, fMeds, rMeds, rPCE, frptBox, fODMedNVA, fODChangeUnreleasedRenew, rODAllergy, 102 UBAGlobals, fClinicWardMeds, uTemplateFields ;110 UBAGlobals, fClinicWardMeds, uTemplateFields, VAUtils; 103 111 104 112 var … … 113 121 uOrderSetTime: TFMDateTime; 114 122 uNewMedDialog: Integer; 123 //QOALTOI: FQOAltOI; 115 124 116 125 const … … 453 462 tmpList.Add('Cannot be released to service(s) because of the following happened action(s):'); 454 463 tmpList.Add(' '); 455 tmpList.AddStrings(TStrings(AnErrLst));464 FastAddStrings(TStrings(AnErrLst), tmpList); 456 465 ReportBox(tmpList,'Cannot be released to service(s)',False); 457 466 tmpList.Free; … … 472 481 ProcDisp := DisplayGroupByName('PROC'); 473 482 ImgDisp := DisplayGroupByName('XRAY'); 483 DietDisp := DisplayGroupByName('DO'); 474 484 NonVADisp := DisplayGroupByName('NV RX'); 475 485 MedsInDlgIen := DlgIENForName('PSJ OR PAT OE'); … … 763 773 end else 764 774 begin 765 //Show Message('Order Dialogs of type "Action" are available in List Manager only.');775 //Show508Message('Order Dialogs of type "Action" are available in List Manager only.'); 766 776 Result := False; 767 777 end; … … 774 784 TC_NO_DEA = 'DEA# Required'; 775 785 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'; 776 788 var 777 789 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; 782 795 tmpResp: TResponse; 796 CxMsg: string; 797 AButton: TButton; 783 798 begin 784 799 IsPsoSupply := False; … … 787 802 IsAnIMOOrder := False; 788 803 ForIMO := False; 804 IsNewOrder := True; 805 PassDrugTstCall := False; 806 DrugCheck := false; 807 DrugTestDlgType := false; 808 //QOAltOI.OI := 0; 789 809 // double check environment before continuing with order 790 810 if uOrderDialog <> nil then uOrderDialog.Close; // then x := uOrderDialog.Name else x := ''; … … 792 812 if CharAt(AnID, 1) = 'X' then 793 813 begin 814 IsNewOrder := False; 815 // if PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E')=false then Exit; 794 816 ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_CHANGE, x); 795 817 if ( Length(x)<1 ) and not (AnEvent.EventIFN > 0) then … … 800 822 x := RetrieveOrderText(Copy(AnID, 2, Length(AnID))) + #13#10 + x; 801 823 if ShowMsgOn(Length(x) > 0, x, TC_NO_CHANGE) then Exit; 824 DrugCheck := true; 802 825 end; 803 826 if CharAt(AnID, 1) = 'C' then 804 827 begin 828 IsNewOrder := False; 829 //if PassDrugTest(StrtoINT(Copy(AnID, 2, Length(AnID)-3)), 'E')=false then Exit; 805 830 ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_COPY, x); 806 831 if Length(x) > 0 then 807 832 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; 809 835 end; 810 836 if CharAt(AnID, 1) = 'T' then 811 837 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; 812 845 ValidateOrderAction(Copy(AnID, 2, Length(AnID)), OA_TRANSFER, x); 813 846 if Length(x) > 0 then … … 824 857 else if ( (IsAnIMOOrder) and (AnEvent.EventIFN <= 0) ) then 825 858 ForIMO := True; 826 827 859 OrderPtEvtID := GetOrderPtEvtID(Copy(AnID, 2, Length(AnID))); 828 860 OrderEvtID := Piece(EventInfo(OrderPtEvtID),'^',2); … … 831 863 ResolvedDialog.InputID := AnID; 832 864 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; 833 875 if (ForIMO and ( (ResolvedDialog.DialogIEN = MedsInDlgIen) 834 876 or (ResolvedDialog.DialogIEN = MedsIVDlgIen)) ) then … … 866 908 if (Length(NssErr) > 1) then 867 909 begin 868 if (NssErr <> 'OTHER') then869 ShowM essage('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.'); 870 912 NSSchedule := True; 871 913 ResolvedDialog.QuickLevel := 0; … … 878 920 if not IsValidSchedule(Copy(AnID, 2, Length(AnID))) then 879 921 begin 880 ShowM essage('The order contains invalid non-standard schedule.');922 ShowMsg('The order contains invalid non-standard schedule.'); 881 923 NSSchedule := True; 882 924 end; … … 884 926 if NSSchedule then ResolvedDialog.QuickLevel := 0; 885 927 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; 886 945 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 887 965 with ResolvedDialog do 888 966 begin … … 1035 1113 else 1036 1114 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; 1037 1150 cmdAcceptClick(Application); // auto-accept order 1038 1151 Result := uOrderDialog.AcceptOK; 1039 1152 1040 1153 //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()'); 1042 1155 1043 1156 //End BAPHII 1.3.2 … … 1061 1174 if (ResolvedDialog.DialogType = 'X') and not Changes.ExistForOrder(EditedOrder) 1062 1175 then UnlockOrder(EditedOrder); 1063 1176 //QOAltOI.OI := 0; 1064 1177 end; 1065 1178 … … 1112 1225 uOrderHTML.ShowModal; 1113 1226 ASetList := TStringList.Create; 1114 ASetList.Assign(uOrderHTML.SetList);1227 FastAssign(uOrderHTML.SetList, ASetList); 1115 1228 uOrderHTML.Release; 1116 1229 if ASetList.Count = 0 then Exit; … … 1669 1782 end; 1670 1783 1671 1672 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0); 1784 procedure PrintOrdersOnSignReleaseMult(OrderList, ClinicLst, WardLst: TStringList; Nature: Char; EncLoc, WardLoc: integer; 1785 EncLocName, WardLocName: string); 1786 var 1787 i,j: integer; 1788 tempOrder: string; 1789 tempOrderList: TStringList; 1790 begin 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; 1818 end; 1819 1820 procedure PrintOrdersOnSignRelease(OrderList: TStringList; Nature: Char; PrintLoc : Integer =0; PrintName: string = ''); 1673 1821 const 1674 1822 TX_NEW_LOC1 = 'The patient''s location has changed to '; … … 1691 1839 then Encounter.Location := ALocation; 1692 1840 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; 1696 1868 if Encounter.Location = 0 1697 1869 then Encounter.Location := CommonLocationForOrders(OrderList); … … 1701 1873 if ALocation > 0 then Encounter.Location := ALocation; 1702 1874 end; 1703 frmFrame.DisplayEncounterText;1875 if printLoc = 0 then frmFrame.DisplayEncounterText; 1704 1876 if Encounter.Location <> 0 then 1705 1877 begin 1706 SetupOrdersPrint(OrderList, DeviceInfo, Nature, False, PrintIt );1878 SetupOrdersPrint(OrderList, DeviceInfo, Nature, False, PrintIt, PrintName); 1707 1879 if PrintIt then 1708 1880 PrintOrdersOnReview(OrderList, DeviceInfo) … … 1710 1882 PrintServiceCopies(OrderList); 1711 1883 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); *) 1713 1885 end; 1714 1886 … … 1731 1903 NMRec.LastIndex := NewIndex; 1732 1904 end; 1905 1906 (*function GetQOAltOI: integer; 1907 begin 1908 Result := QOAltOI.OI; 1909 end; *) 1733 1910 1734 1911 function IsIMODialog(DlgID: integer): boolean; //IMO
Note:
See TracChangeset
for help on using the changeset viewer.