PSOHLNE1 ;BIR/RTR-Parsing out segments from OERR ;01/20/95 ;;7.0;OUTPATIENT PHARMACY;**1,9,46,71,98,111,117,131,157,181,143,235,239**;DEC 1997 ;External reference to EN^ORERR supported by DBIA 2187 ;External reference to PS(50.607 supported by DBIA 2221 ;External reference to OR(100 supported by DBIA 2219 ;External reference to PSDRUG( supported by DBIA 221 ;External reference VADPT supported by DBIA 10061 ; EN ;ORC segment N Q1,Q2,Q3,Q4,Q5,Q6,Q7,PSOPOSSD K PSOLQ1I,PSOLQ1II,PSOLQ1IX I '$O(MSG(ZZ,0)) D .S PSOOC="NW",PLACER=+$P(PSOSEG,"|",2),PLACERXX=+$P($P(PSOSEG,"|",2),";",2),ENTERED=$P(PSOSEG,"|",10),PROV=$P(PSOSEG,"|",12) .S X=$P(PSOSEG,"|",15) S EFFECT=$$HL7TFM^XLFDT(X) K X .D NOW^%DTC S PSOLOG=% K % .;S RSN=$P(PSOSEG,"|",16) .S ORCSEG=$P(PSOSEG,"|",7),QCOUNT=1 Q:$G(ORCSEG)'["~" .F JJ=1:1:$L(ORCSEG) S:$E(ORCSEG,JJ)="~" QCOUNT=QCOUNT+1 I '$O(MSG(ZZ,0)) D Q .F JJJ=1:1:QCOUNT S QQQ=$P(ORCSEG,"~",JJJ) D:QQQ'="" ..S PSOPOSSD=$S($P($P(QQQ,"^"),"&"):1,1:0) ;PSOPOSSD=1 if possible dose ..S Q1I(JJJ)=$S(PSOPOSSD:$P(QQQ,"^"),1:$P(QQQ,"^",8)),PSOLQ1IX(JJJ)=$P($P(QQQ,"^"),"&",5) S PSOLQ1I(JJJ)=$P(QQQ,"^",8),PSOLQ1II(JJJ)=PSOPOSSD ;ORC piece 1 if Possible Dosage, ORC piece 8 if Local Possible Dosage ..S Q1(JJJ)=$P(QQQ,"^",2) ;schedule ..S Q2(JJJ)=$P(QQQ,"^",3) ;duration ..S Q3(JJJ)=$P(QQQ,"^",4) I Q3(JJJ) S X=Q3(JJJ) S Q3(JJJ)=$$HL7TFM^XLFDT(X) K X ;start date ..S Q4(JJJ)=$P(QQQ,"^",5) ;end date ..S:$G(PRIOR)="" PRIOR=$P(QQQ,"^",6) ..S Q6(JJJ)=$P(QQQ,"^",9) ;conjunction ..S Q7(JJJ)=$P(QQQ,"^",10) ;sequencing ..S QTARRAY(JJJ)=Q1(JJJ)_"^"_Q2(JJJ)_"^"_Q3(JJJ)_"^"_Q4(JJJ)_"^^"_Q6(JJJ)_"^"_Q7(JJJ) ..S QTARRAY2(JJJ)=$S(PSOPOSSD:$P(Q1I(JJJ),"&"),1:Q1I(JJJ))_"^"_$S(PSOPOSSD:$P(Q1I(JJJ),"&",3),1:"") ..I PSOPOSSD S $P(QTARRAY(JJJ),"^",5)=$P(Q1I(JJJ),"&",4) ..I PSOPOSSD S PSOUNN=$P(Q1I(JJJ),"&",2) I PSOUNN'="" S PSOUNN=$O(^PS(50.607,"B",PSOUNN,0)) S $P(QTARRAY(JJJ),"^",9)=$G(PSOUNN) ..K PSOUNN ;For multiple ORC subscripts S (POVAR,POVAR1)="",(NNCK,NNN,NNNN)=0,PSOIII=1,MSG(ZZ,0)=$E(MSG(ZZ),5,$L(MSG(ZZ))) S AAA="" F S AAA=$O(MSG(ZZ,AAA)) Q:AAA="" S NNN=0 F OOO=1:1:$L(MSG(ZZ,AAA)) S NNN=NNN+1 D D:$G(POVAR1)="~"&(NNNN=6) PARSE D:$G(POVAR1)="|" PARSE .I $E(MSG(ZZ,AAA),OOO)="|" S NNNN=NNNN+1 .S POVAR1=$E(MSG(ZZ,AAA),OOO) .S POLIM=POVAR .S POVAR=$S(POVAR="":POVAR1,1:POVAR_POVAR1) .;I NNNN=6 I $G(POVAR1)="~"!($G(POVAR1)="|") END ;16 OF ORC? ;I $G(POVAR)'="" I NNNN=14!(NNNN=15) S EFFECT=$G(POVAR) S QCOUNT=0 F JJJ=0:0 S JJJ=$O(QTVAR(JJJ)) Q:'JJJ I $L($G(QTVAR(JJJ))) S QCOUNT=QCOUNT+1 D .S PS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S EFFECT=$$HL7TFM^XLFDT(X) K X D NOW^%DTC S PSOLOG=% S:'$G(EFFECT) EFFECT=% K % K MSG(ZZ,0) Q PARSE I NNNN=1 S PSOOC="NW" G SET I NNNN=2 S PLACER=+$G(POLIM),PLACERXX=+$P($G(POLIM),";",2) G SET I NNNN=3!(NNNN=4)!(NNNN=5) G SET I NNNN=6,$G(POVAR1)="~" S NNCK=NNCK+1,QTVAR(NNCK)=$G(POLIM) G SET I NNNN=7 S NNCK=NNCK+1 S QTVAR(NNCK)=$G(POLIM) G SET I NNNN=8!(NNNN=9) G SET I NNNN=10 S ENTERED=$G(POLIM) G SET I NNNN=11 G SET I NNNN=12 S PROV=$G(POLIM) G SET I NNNN=13!(NNNN=14) G SET I NNNN=15 S EFFECT=$G(POLIM) SET S (POVAR,POLIM)="" Q ; EXP ; ;Q:'$G(OR("PLACE")) Q:'$G(PSOFILNM) S PSOMSORR=1 N PSOSSMES S PSOSSMES="CPRSUP" I $G(PSOFILNM),$G(PSOFILNM)["S" S LL=+$G(PSOFILNM) I $D(^PS(52.41,LL,0)),$P($G(^(0)),"^",3)'="RF" G EXPEN S LL=$G(PSOFILNM) I 'LL!('$D(^PSRX(+$G(LL),0))) S COMM="Order was not located by Pharmacy" D EN^ORERR(COMM,.MSG) D G EXPQ .F EER=0:0 S EER=$O(MSG(EER)) Q:'EER S:$P(MSG(EER),"|")="PV1" PSERRPV1=MSG(EER) S:$P(MSG(EER),"|")="PID" PSERRPID=MSG(EER) S:$P(MSG(EER),"|")="ORC"&($G(PSERRORC)="") PSERRORC=MSG(EER) .N MSG,PSOHINST D INIT^PSOHLSN S MSG(2)=$G(PSERRPID),MSG(3)=$G(PSERRPV1),MSG(4)="ORC|DE|"_$G(OR("PLACE"))_$S($G(PLACERXX):";"_PLACERXX,1:"")_"^OR"_"|"_$S($P($G(PSERRORC),"|",4)'="":$P(PSERRORC,"|",4),1:"") S:$G(COMM)'="" MSG(5)="NTE|16||"_COMM .D SEND^PSOHLSN Q:'$D(^PSRX(LL,0)) I +$P($G(^PSRX(LL,2)),"^",6)