PSOHLSN3 ;BIR/SJA - Send order info to OERR from file 52 ;10/05/06
;;7.0;OUTPATIENT PHARMACY;**225**;DEC 1997;Build 29
;
ORC ; Called from PSOHLSN1 due to it's routine size.
S LIMIT=15 X NULLFLDS
S FIELD(0)="ORC"
S FIELD(1)=$G(STAT)
I $G(STAT)'="SN",$G(STAT)'="ZC" S FIELD(2)=$P($G(^PSRX(PSRXIEN,"OR1")),"^",2)
S:FIELD(2)'="" FIELD(2)=FIELD(2)_$S($G(PLACERXX):";"_PLACERXX,1:"")_"^OR"
S FIELD(3)=PSRXIEN_"^PS"
S FIELD(5)=$G(PSSTAT)
I $G(STAT)="RO",$G(PSOROPCH)'="PATCH" S FIELD(5)="CM"
I $G(FIELD(5))="" I $G(STAT)="OR"!($G(STAT)="OE") S FIELD(5)="CM"
S X=$P($G(^PSRX(PSRXIEN,2)),"^") I X S FIELD(9)=$$FMTHL7^XLFDT(X)
S EDUZ=$P($G(^PSRX(PSRXIEN,0)),"^",16) I EDUZ S FIELD(10)=EDUZ_"^"_$P($G(^VA(200,EDUZ,0)),"^")
I $G(PSOCANRC),$G(PSOCANRN)'="" I $G(STAT)="OD"!($G(STAT)="OC") S FIELD(12)=$G(PSOCANRC)_"^"_$G(PSOCANRN)
I '$G(FIELD(12)) S FIELD(12)=$P($G(^PSRX(PSRXIEN,0)),"^",4)_"^"_$P($G(^VA(200,+$P($G(^PSRX(PSRXIEN,0)),"^",4),0)),"^")
S PSOHISSD="",X=$P($G(^PSRX(PSRXIEN,0)),"^",13) I X S PSOHISSD=$$FMTHL7^XLFDT(X)
S FIELD(15)=$G(PSOHISSD) K X
D SEG^PSOHLSN1
I $G(COMM)'=""!($G(PSNOO)'="") D
.I $G(PSNOO)'="" D NOO^PSOHLSN1
.I $L($G(COMM))+($L(MSG(COUNT)))+($L($G(PSNOOTX)))+($S($G(PSNOO)'="":11,1:5))<245 S MSG(COUNT)=MSG(COUNT)_"|"_$G(PSNOO)_"^"_$G(PSNOOTX)_"^"_$S($G(PSNOO)'="":"99ORN",1:"")_"^^"_$G(COMM)_"^" Q
.S MSG(COUNT,1)="|"_$G(PSNOO)_"^"_$G(PSNOOTX)_"^"_$S($G(PSNOO)'="":"99ORN",1:"")_"^^"_$G(COMM)_"^"
Q
PSOHLSN3 ;BIR/SJA - Send order info to OERR from file 52 ;10/05/06
+1 ;;7.0;OUTPATIENT PHARMACY;**225**;DEC 1997;Build 29
+2 ;
ORC ; Called from PSOHLSN1 due to it's routine size.
+1 SET LIMIT=15
XECUTE NULLFLDS
+2 SET FIELD(0)="ORC"
+3 SET FIELD(1)=$GET(STAT)
+4 IF $GET(STAT)'="SN"
IF $GET(STAT)'="ZC"
SET FIELD(2)=$PIECE($GET(^PSRX(PSRXIEN,"OR1")),"^",2)
+5 IF FIELD(2)'=""
SET FIELD(2)=FIELD(2)_$SELECT($GET(PLACERXX):";"_PLACERXX,1:"")_"^OR"
+6 SET FIELD(3)=PSRXIEN_"^PS"
+7 SET FIELD(5)=$GET(PSSTAT)
+8 IF $GET(STAT)="RO"
IF $GET(PSOROPCH)'="PATCH"
SET FIELD(5)="CM"
+9 IF $GET(FIELD(5))=""
IF $GET(STAT)="OR"!($GET(STAT)="OE")
SET FIELD(5)="CM"
+10 SET X=$PIECE($GET(^PSRX(PSRXIEN,2)),"^")
IF X
SET FIELD(9)=$$FMTHL7^XLFDT(X)
+11 SET EDUZ=$PIECE($GET(^PSRX(PSRXIEN,0)),"^",16)
IF EDUZ
SET FIELD(10)=EDUZ_"^"_$PIECE($GET(^VA(200,EDUZ,0)),"^")
+12 IF $GET(PSOCANRC)
IF $GET(PSOCANRN)'=""
IF $GET(STAT)="OD"!($GET(STAT)="OC")
SET FIELD(12)=$GET(PSOCANRC)_"^"_$GET(PSOCANRN)
+13 IF '$GET(FIELD(12))
SET FIELD(12)=$PIECE($GET(^PSRX(PSRXIEN,0)),"^",4)_"^"_$PIECE($GET(^VA(200,+$PIECE($GET(^PSRX(PSRXIEN,0)),"^",4),0)),"^")
+14 SET PSOHISSD=""
SET X=$PIECE($GET(^PSRX(PSRXIEN,0)),"^",13)
IF X
SET PSOHISSD=$$FMTHL7^XLFDT(X)
+15 SET FIELD(15)=$GET(PSOHISSD)
KILL X
+16 DO SEG^PSOHLSN1
+17 IF $GET(COMM)'=""!($GET(PSNOO)'="")
Begin DoDot:1
+18 IF $GET(PSNOO)'=""
DO NOO^PSOHLSN1
+19 IF $LENGTH($GET(COMM))+($LENGTH(MSG(COUNT)))+($LENGTH($GET(PSNOOTX)))+($SELECT($GET(PSNOO)'="":11,1:5))<245
SET MSG(COUNT)=MSG(COUNT)_"|"_$GET(PSNOO)_"^"_$GET(PSNOOTX)_"^"_$SELECT($GET(PSNOO)'="":"99ORN",1:"")_"^^"_$GET(COMM)_"^"
QUIT
+20 SET MSG(COUNT,1)="|"_$GET(PSNOO)_"^"_$GET(PSNOOTX)_"^"_$SELECT($GET(PSNOO)'="":"99ORN",1:"")_"^^"_$GET(COMM)_"^"
End DoDot:1
+21 QUIT