ORCACT0 ;SLC/MKB-Validate order action ;2/24/03 10:35 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**7,27,48,72,86,92,94,141,165,177,173,190,215**;Dec 17, 1997 ; VALID(IFN,ACTION,ERROR,NATR) ; -- Determines if action is valid for order IFN N OR0,OR3,ORA0,AIFN,PKG,DG,ORDSTS,ACTSTS,VER,X,Y,MEDPARM K ERROR S OR0=$G(^OR(100,+IFN,0)),OR3=$G(^(3)),PKG=$$NMSP^ORCD($P(OR0,U,14)) S DG=$P($G(^ORD(100.98,+$P(OR0,U,11),0)),U,3) S MEDPARM=$S($G(NATR)="A":2,PKG'="PS":2,'$D(^XUSEC("OREMAS",DUZ)):2,DG="NV RX":$$GET^XPAR("ALL","OR OREMAS NON-VA MED ORDERS"),1:$$GET^XPAR("ALL","OR OREMAS MED ORDERS")) S AIFN=$P(IFN,";",2) S:'AIFN AIFN=+$P(OR3,U,7) S ORA0=$G(^OR(100,+IFN,8,AIFN,0)),ACTSTS=$P(ORA0,U,15) S ORDSTS=$P(OR3,U,3),VER=$S($P(OR0,U,5)["101.41":3,1:2) CM I ACTION="CM" S ERROR="This action is no longer available!" G VQ ; ward comments - no restrictions FL I ACTION="FL" D G VQ ; flag . I +$G(^OR(100,+IFN,8,AIFN,3)) S ERROR="This order is already flagged!" Q UF I ACTION="UF" D G VQ ; unflag . I '+$G(^OR(100,+IFN,8,AIFN,3)) S ERROR="This order is not flagged!" Q DC1 I ACTION="DC",ACTSTS D G VQ ; discontinue/cancel unrel or canc order . I (ACTSTS=11)!(ACTSTS=10) D Q ; unreleased .. I 'MEDPARM S ERROR="You are not authorized to cancel med orders!" Q .. I $G(NATR)="A" S X=$O(^ORE(100.2,"AO",+IFN,0)) I X,'$G(^ORE(100.2,X,1)) S ERROR="Future event orders may not be auto-discontinued!" Q . I ACTSTS=12 S ERROR="This order has been dc'd due to edit!" Q . I ACTSTS=13 S ERROR="This order has been cancelled!" Q ES I (ACTION="ES")!(ACTION="OC")!(ACTION="RS")!(ACTION="DS") D ES^ORCACT01 G VQ ; sign VR I ACTION="VR" D G VQ ; verify . I $G(ORVER)="N",$P(ORA0,U,9) S ERROR="This order has been verified!" Q . I $G(ORVER)="C",$P(ORA0,U,11) S ERROR="This order has been verified!" Q . I $G(ORVER)="R",$P(ORA0,U,19) S ERROR="This order has been reviewed!" Q . I (ACTSTS=11)!(ACTSTS=10) S ERROR="This order has not been released to the service." Q . I AIFN=1,ORDSTS=5,PKG="PS" S X=$$DISABLED I X S ERROR=$P(X,U,2) Q DIS S X=$$DISABLED I X S ERROR=$P(X,U,2) G VQ MN I ACTION="MN" D G VQ ; manually release (delayed) . I ACTSTS'=10,ACTSTS'=11 S ERROR="This order has already been released!" Q . I $P(OR0,U,12)="I",'$G(^DPT(+ORVP,.105)) S ERROR="This patient is not currently admitted!" GMRA I PKG="GMRA" S ERROR="This action is not allowed on an allergy/adverse reaction!" G VQ ; no actions allowed on Allergies MEDS I PKG="PS",'MEDPARM S ERROR="You are not authorized to enter med orders!" G VQ RW I ACTION="RW" D RW^ORCACT01 G VQ ; rewrite/copy XFR I ACTION="XFR" D XFR^ORCACT01 G VQ ; transfer to in/outpt RN I ACTION="RN" D RN^ORCACT01 G VQ ; renew TRM I $$DONE G VQ ; ORDSTS=1,2,7,12,13 EV I ACTION="EV" D G VQ ; change delay event . I ORDSTS'=10,ORDSTS'=11 S ERROR="This order has been released!" Q . I DG="NV RX" S ERROR="Non-VA Med orders do not support this action!" Q . I $$EVTORDER^OREVNTX(IFN) S ERROR="The release event for this order may not be changed!" Q . S X=$P(ORA0,U,4) I X'=2,X'=3 S ERROR="Signed orders may not be delayed to another event!" Q DC2 I ACTION="DC",ACTSTS="" D G VQ ; DC released order . I $G(NATR)="A" D Q:$D(ERROR) .. S X=$O(^ORE(100.2,"AO",+IFN,0)) I X S:'$G(^ORE(100.2,X,1)) ERROR="Future event orders may not be auto-discontinued!" Q .. I $$GET1^DIQ(9.4,+$P(OR0,U,14)_",",1)="PSO",$G(DGPMT)=1 Q ;177 If admission auto-dc and order is outpt med then no further checking needed .. I $G(DGPMT)=1,$P($G(^SC(+$P(OR0,U,10),0)),U,3)'="C" S ERROR="Only outpatient orders may be auto-discontinued!" Q .. I $G(DGPMT)'=1,$P($G(^SC(+$P(OR0,U,10),0)),U,3)="C" S ERROR="Only inpatient orders may be auto-discontinued!" Q . I PKG="RA",ORDSTS=6 S ERROR="Active Radiology orders cannot be discontinued!" Q . I PKG="VBEC",ORDSTS=6 S ERROR="Active Blood Product orders cannot be discontinued!" Q . I PKG="LR" D Q .. I $$COLLECTD S ERROR="Lab orders that have been collected may not be discontinued!" Q .. I $G(NATR)="A","^12^38^"'[(U_$P($G(DGPMA),U,18)_U),$$VALUE^ORX8(+IFN,"COLLECT")="SP",$P(OR0,U,8)'