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

PSORDS.m

Go to the documentation of this file.
PSORDS ;BHAM ISC/LC - BUILD RDS MESSAGE ; 02/22/95
 ;;7.0;OUTPATIENT PHARMACY;**11**;DEC 1997
 ;
 ;^UTILITY($J,"PSOPCE",COUNTER)=    6 pieces, which are:
 ;    Piece one   -> Internal Rx number
 ;    Piece two   -> Quantity
 ;    Piece three -> File 50 pointer
 ;    Piece four  -> 1 for Release   0 for Return to stock
 ;    Piece five  -> 0 for original, 1 for refill, 2 for partial
 ;    Piece six   -> Date/Time or Date
 ;
MSG ;
 F PSOAAA=0:0 S PSOAAA=$O(^UTILITY($J,"PSOPCE",PSOAAA)) Q:'PSOAAA  S PCENODE=^(PSOAAA) D SEND
 G END
SEND ;
 K MSG S RXP=+$P(PCENODE,"^"),RXDRUG=+$P(PCENODE,"^",3),PSORE=$P(PCENODE,"^",4),PSOFILL=$P(PCENODE,"^",5),PSODTIME=$P(PCENODE,"^",6)
 Q:'$D(^PSRX(RXP,0))!('RXP)
 S PSORXEXT=$P($G(^PSRX(RXP,0)),"^"),PSFLAG=0,PSORINST=$P($G(^DIC(4,+$P($G(^XMB(1,1,"XUS")),"^",17),99)),"^"),NULLFLDS="F JJ=0:1:LIMIT S FIELD(JJ)="""""
 S LIMIT=15 X NULLFLDS K X
 S X=PSODTIME S:'X X=DT S FIELD(3)=$$HLDATE^HLFNC(X)
 S PSND1=$P($G(^PSDRUG(RXDRUG,"ND")),"^"),PSND2=$P($G(^("ND")),"^",2),PSND3=$P($G(^("ND")),"^",3) I PSND1,PSND3 S PSFLAG=1
 S FIELD(2)=$S(PSFLAG:PSND1_"."_PSND3_"^"_PSND2_"^"_"99NDF",1:"^^")_"^"_RXDRUG_"^"_$P($G(^PSDRUG(RXDRUG,0)),"^")_"^"_"99PSD"
 S FIELD(4)=$P(PCENODE,"^",2)
 S FIELD(7)=$P(^PSRX(RXP,0),"^")
 S FIELD(9)=$S(PSORE=0&(PSOFILL=2):"PARTIAL RETURN TO STOCK",PSORE=0:"RETURN TO STOCK",PSOFILL=2:"PARTIAL RELEASE",1:"RELEASE")
 S POIPTR=+$P($G(^PSRX(RXP,"OR1")),"^") I POIPTR S PODOSE=+$P($G(^PS(50.7,POIPTR,0)),"^",2),PODOSENM=$P($G(^PS(50.606,PODOSE,0)),"^")
 S FIELD(6)=$S(POIPTR:"^^^"_$G(PODOSE)_"^"_$G(PODOSENM)_"^"_"99PSF",1:"")
 S MSG(1)="MSH|^~\&|PHARMACY|"_PSORINST_"|||||RDS"
 S MSG(2)="PID|||"_$P(^PSRX(RXP,0),"^",2)_"||"_$P($G(^DPT(+$P($G(^(0)),"^",2),0)),"^")
 S MSG(3)="ORC|OR||"_$G(RXP)
 K FSIG,BSIG I $P($G(^PSRX(RXP,"SIG")),"^",2) D FSIG^PSOUTLA("R",RXP,245) F PSREV=1:1 Q:'$D(FSIG(PSREV))  S BSIG(PSREV)=FSIG(PSREV)
 K FSIG,PSREV I '$P($G(^PSRX(RXP,"SIG")),"^",2) D EN3^PSOUTLA1(RXP,245)
 S FIELD(15)=$G(BSIG(1))
 S FIELD(0)="RXD",COUNT=3 D SEGPAR^PSOHLSN K COUNT,PVAR,PLIM,PVAR1,FIELD,SUBCOUNT,SEG1
 K LSIG I $O(BSIG(1)) D
 .S LASTSIG=$O(BSIG(1)) S LSIG=$G(BSIG(LASTSIG))
 I $G(LSIG)'="",$O(MSG(4,0)) D
 .N LAST S LAST=0 F ZZZ=0:0 S ZZZ=$O(MSG(4,ZZZ)) Q:'ZZZ  S LAST=ZZZ
 .S LTH=$L(MSG(4,LAST)) S LTH=245-LTH
 .I LTH S MSG(4,LAST)=MSG(4,LAST)_$E(LSIG,1,LTH) S LTH=LTH+1,LSIG=$E(LSIG,LTH,245)
 .S LAST=LAST+1 S:$G(LSIG)'="" MSG(4,LAST)=$G(LSIG)
 ;D MSG^XQOR("PS EVSEND OR",.MSG)
 Q
END K ^UTILITY($J,"PSOPCE"),BSIG,COUNT,FIELD,FSIG,JJ,LAST,LASTSIG,LIMIT,LTH,MSG,NULLFLDS,PODOSE,PODOSENM,POIPTR,PSFLAG,PSND1,PSND2,PSND3,PSORINST,PSORXEXT,RXP,PSREV,RXDRUG,ZZZ,PSORE,PSOFILL,PSOAAA,PCENODE S ZTREQ="@" Q