Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ORMORG

ORMORG.m

Go to the documentation of this file.
ORMORG ; SLC/MKB - Receive Generic Orders messages ; 08 May 2002  2:12 PM
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**3,79,141**;Dec 17, 1997
 ;
EN ; -- entry point for ORG msgs
 I '$L($T(@ORDCNTRL)) S ORERR="Invalid order control code" Q
 I 'ORIFN!('$D(^OR(100,+ORIFN,0))) S ORERR="Invalid OE/RR order number" Q
 D @ORDCNTRL
 Q
 ;
XO ; -- edited order
NW ; -- new order
 N OR0,OR3,ORSTS,ORSTRT,ORSTOP,ORIG,ORTYP,ORNOW,OREVT
 S ^OR(100,+ORIFN,4)=+ORIFN,OR0=$G(^(0)),OR3=$G(^(3))
 S ORNOW=+$E($$NOW^XLFDT,1,12),ORSTRT=$P(OR0,U,8),OREVT=+$P(OR0,U,17)
 I 'ORSTRT S ORSTRT=ORNOW D DATES^ORCSAVE2(+ORIFN,ORSTRT)
 S ORSTS=$S(ORSTRT>ORNOW:8,1:6) D STATUS^ORCSAVE2(+ORIFN,ORSTS)
 ;I OREVT,$P($G(^ORE(100.2,OREVT,0)),U,4)=+ORIFN,$G(^(1)) D COMP^ORCSAVE2(ORIFN)
 S ORIG=+$P(OR3,U,5),ORTYP=$P(OR3,U,11) I ORIG,ORTYP D  ;edit or renewal
 . S (ORSTOP,ORSTS)=""
 . S:ORTYP=1 ORSTOP=ORNOW,ORSTS=12 I ORTYP=2 D
 .. N STOP,STS S STOP=$P($G(^OR(100,ORIG,0)),U,9),STS=$P($G(^(3)),U,3)
 .. I "^1^2^7^12^13^"[(U_STS_U),STOP'>ORNOW Q  ;already terminated
 .. S ORSTOP=$S(STOP'>ORNOW:"",ORSTRT<ORNOW:ORNOW,1:ORSTRT)
 .. S ORSTS=$S("^1^2^7^12^13^"[(U_STS_U):"",ORSTOP>ORNOW:15,1:7)
 . D:ORSTOP DATES^ORCSAVE2(ORIG,,ORSTOP)
 . D:ORSTS STATUS^ORCSAVE2(ORIG,ORSTS)
 . S:'OREVT OREVT=+$P($G(^OR(100,ORIG,0)),U,17)
 . I OREVT,$P($G(^ORE(100.2,OREVT,0)),U,4)=ORIG,'$G(^(1)) D
 .. K ^ORE(100.2,"AO",OREVT,ORIG)
 .. S $P(^ORE(100.2,OREVT,0),U,4)=+ORIFN,^ORE(100.2,"AO",OREVT,+ORIFN)=""
 .. S:'$P(OR0,U,17) $P(^OR(100,+ORIFN,0),U,17)=OREVT,^OR(100,"AEVNT",ORVP,OREVT,+ORIFN)=""
 Q
 ;
CA ; -- cancel
DC ; -- discontinue
 D STATUS^ORCSAVE2(+ORIFN,1) ;also sets stop date
 Q
 ;
HD ; -- hold
 D STATUS^ORCSAVE2(+ORIFN,3)
 Q
 ;
RL ; -- release hold
 N STS,NOW,ORSTRT,ORSTOP
 S ORSTRT=$P(^OR(100,+ORIFN,0),U,8),ORSTOP=$P(^(0),U,9),NOW=$$NOW^XLFDT
 S STS=$S(ORSTRT>NOW:8,'ORSTOP:6,ORSTOP'>NOW:7,1:6)
 D STATUS^ORCSAVE2(+ORIFN,STS)
 Q