source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOHLDS3.m@ 1446

Last change on this file since 1446 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 6.9 KB
Line 
1PSOHLDS3 ;BHAM ISC/SAB,LC,PWC - BUILD PROFILE FOR AUTOMATED INTERFACE ;4/13/05 1:53pm
2 ;;7.0;OUTPATIENT PHARMACY;**156,198**;DEC 1997
3 ;reference to PSDRUG suppoprted by DBIA # 221
4 ;reference to PS(50.606 supported by DBIA # 2174
5 ;reference to PS(50.7 supported by DBIA #2223
6 ;reference to PS(55 supported by DBIA # 2228
7 ;reference to PS(56 supported by DBIA # 2229
8 ;
9 ;PSO*198 add check to insert spaces into PMI segments, also add
10 ; "NTE|6||" to beginning of NTE6 segment
11 ;
12START ;build profile for the NTE4 segment
13 Q:'$D(DFN)
14 N II K ^TMP($J,"PRF")
15 S PSODFN=DFN I '$D(PSODTCUT) D CUTDATE^PSOFUNC
16 S:'$D(Z) Z=1 S:'$D(NEW1) (NEW1,NEW11)="^" S %DT="",X="T" D ^%DT S DT1=Y S X1=DT1,X2=-365 D C^%DTC S EXPS=X S X1=DT1,X2=-182 D C^%DTC S EXP=X
17 F RXX=0:0 S RXX=$O(^PS(55,DFN,"P",RXX)) Q:'RXX S RXNN=+^(RXX,0) I $D(^PSRX(RXNN,0)),$P($G(^("STA")),"^")'=13 S RXPX=^PSRX(RXNN,0),$P(RXPX,"^",15)=$P($G(^("STA")),"^"),RXPX2=^(2) D CHK
18 I '$D(^TMP($J,"PRF")) G PPP
19 ;
20SD S CNT=1 F SD="A","C","S" I $D(^TMP($J,"PRF",SD)) S DRNME="" D DRNME
21PPP D PEND
22 K ^TMP($J,"PRF")
23 K A,B,DRNME,DRP,EXP,EXPS,I,II,ISSD,J,LINE,LN,MESS,MJK,NEW1,NEW11,PHYS,POP,PQTY,TTTT,RFL,RFS,RXF,RXNN,RXPX,RXPX2,RXPNO,RXX
24 K SD,SIG,STA,X,X1,X2,Y,Z,CNT,PEND,PSODTCUT,PSOPRPAS,PZZODRUG,RFDATE
25 Q
26DRNME S DRNME=$O(^TMP($J,"PRF",SD,DRNME)) Q:DRNME="" D ISSD G DRNME
27 ;
28ISSD F ISSD=0:0 S ISSD=$O(^TMP($J,"PRF",SD,DRNME,ISSD)) Q:'ISSD S RXPNO="" D RXPNO
29 Q
30RXPNO S RXPNO=$O(^TMP($J,"PRF",SD,DRNME,ISSD,RXPNO)) Q:RXPNO="" S RXNN=^(RXPNO) I $D(^PSRX(RXNN,0)) S RXPX=^(0),RXPX2=^(2) D PRT G RXPNO
31 ;
32CHK Q:PSODTCUT>$P(RXPX2,"^",6)
33 I $P(^PSRX(RXNN,"STA"),"^")=12 S II=RXNN D LAST^PSORFL Q:PSODTCUT>RFDATE
34 I $P(RXPX,"^",3)=7!($P(RXPX,"^",3)=8)&('PSOPRPAS) Q
35 S J="^"_RXNN_"^" Q:(NEW1[J)!(NEW11[J) Q:$P(RXPX,"^",13)<EXPS S RXPNO=$P(RXPX,"^"),ISSD=$P(RXPX,"^",13)
36 Q:'$D(^PSDRUG($P(RXPX,"^",6),0)) S DRP=^(0),SD=$S($P(DRP,"^",3)["S":"S",$P(RXPX,"^",15)=12:"C",1:"A"),DRNME=$P(DRP,"^"),^TMP($J,"PRF",SD,DRNME,ISSD,RXPNO)=RXNN
37 Q
38PRT S RFS=$P(RXPX,"^",9),PQTY=$P(RXPX,"^",7)
39 K DIC,X,Y S DIC="^VA(200,",DIC(0)="N,Z",X=$P(RXPX,"^",4) D ^DIC
40 S PHYS=$S(+Y:$P(Y,"^",2),1:"UNKNOWN"),II=RXNN D LAST^PSORFL S RXF=0 F MJK=0:0 S MJK=$O(^PSRX(RXNN,1,MJK)) Q:'MJK S RXF=RXF+1
41 S STA=$S($P(^PSRX(RXNN,"STA"),"^")=14:"DC",$P(^PSRX(RXNN,"STA"),"^")=15:"DE",$P(^PSRX(RXNN,"STA"),"^")=16:"PH",1:$E("ANRHPS ECD",(1+$P(^PSRX(RXNN,"STA"),"^")))),STA=$S(DT1>$P(RXPX2,"^",6):"E",1:STA)
42 D SIG S FSIG=$O(FSIG(""),-1)
43 S ^TMP("PSO",$J,PSI)="NTE"_FS_4_FS_FS,NTE4=1
44 S ^TMP("PSO",$J,PSI,CNT)=SD_CS_RXPNO_CS_DRNME_CS_$E(ISSD,4,5)_"/"_$E(ISSD,6,7)
45 S ^TMP("PSO",$J,PSI,CNT)=^TMP("PSO",$J,PSI,CNT)_CS_$E(RFL,1,5)_CS_RFS_CS_RXF_CS_PQTY_CS_STA_CS_$E(PHYS,1,20)_CS_$S($G(FSIG)'="":FSIG,1:"""""")_FS_"Profile Information"
46 S CNT=CNT+1
47 Q
48SIG ;Format Sig
49 S PSPROSIG=$P($G(^PSRX(RXNN,"SIG")),"^",2) K FSIG,BSIG D
50 .I PSPROSIG D FSIG^PSOUTLA("R",RXNN,80) Q
51 .D EN2^PSOUTLA1(RXNN,80) F GGGGG=0:0 S GGGGG=$O(BSIG(GGGGG)) Q:'GGGGG S FSIG(GGGGG)=BSIG(GGGGG)
52 K PSPROSIG,GGGGG,BSIG Q
53PEND ;include pending orders in profile
54 N PSPCOUNT,PSPPEND,ZXXX,PSPSTAT,FSIGZZ,PZZDRUG,PSSODRUG,PZXZERO,PPPPP,GGGGG
55 S PSPCOUNT=1,PSPPEND="" F PPPPP=0:0 S PPPPP=$O(^PS(52.41,"P",DFN,PPPPP)) Q:'PPPPP S PSPSTAT=$P($G(^PS(52.41,PPPPP,0)),"^",3) I PSPSTAT="NW"!(PSPSTAT="HD")!(PSPSTAT="RNW") S PSPPEND(PSPCOUNT)=PPPPP,PSPCOUNT=PSPCOUNT+1
56 Q:'$O(PSPPEND(0))
57 F ZXXX=0:0 S ZXXX=$O(PSPPEND(ZXXX)) Q:'ZXXX S PZXZERO=$G(^PS(52.41,PSPPEND(ZXXX),0)) D:$P(PZXZERO,"^")
58 .S PZZDRUG=$P(PZXZERO,"^",9),PZZODRUG=$P(PZXZERO,"^",8) Q:'PZZDRUG Q:'PZZODRUG
59 .S PEND="P"_CS_$S(PZZDRUG:$P($G(^PSDRUG(+PZZDRUG,0)),"^"),1:$P($G(^PS(50.7,+PZZODRUG,0)),"^")_" "_$P($G(^PS(50.606,+$P($G(^(0)),"^",2),0)),"^"))
60 .S PEND=PEND_CS_$E($P(PZXZERO,"^",6),4,5)_"/"_$E($P(PZXZERO,"^",6),6,7)_"/"_$E($P(PZXZERO,"^",6),2,3)
61 . K DIC,X,Y S DIC="^VA(200,",DIC(0)="N,Z",X=+$P(PZXZERO,"^",5) D ^DIC
62 .S PEND=PEND_CS_$P(PZXZERO,"^",10)_CS_$P(PZXZERO,"^",11)_CS_$S(+Y:$P(Y,"^",2),1:"")
63 .D FSIG^PSOUTLA("P",PSPPEND(ZXXX),100) S PEND=PEND_CS_$G(FSIG(1)) F FSIGZZ=1:0 S FSIGZZ=$O(FSIG(FSIGZZ)) Q:'FSIGZZ S PEND=PEND_CS_$G(FSIG(FSIGZZ))
64 S:$D(PEND) ^TMP("PSO",$J,PSI,CNT)=PEND
65 S CNT=CNT+1
66 Q
67 ;
68START2 ;build NTE for drug interactions
69 K PSOSERV
70 S RX=IRXN,RXY=^PSRX(RX,0)
71 I $D(^PS(52.4,RX,0)) S SCRIPT=$P(^PS(52.4,RX,0),"^",10),SEV=$P(^PS(52.4,RX,0),"^",9) F X=1:1 S RXX(X)=$P(SCRIPT,",",X),SEV(X)=$P(SEV,",",X) Q:RXX(X)="" D
72 .S SER=$P(^PS(56,SEV(X),0),"^",4) S:$G(SER)=1 PSOSERV=1
73 .S DIRX=$P($G(^PSRX(RXX(X),0)),"^"),TYP=$S(SER=1:"CRITICAL",SER=2:"SIGNIFICANT",1:"UNKNOWN")
74 .S DRG=$P(^PSDRUG($P(^PSRX(RXX(X),0),"^",6),0),"^")
75 .S:X=1 NTE5=DIRX_CS_TYP_CS_DRG
76 .S:X>1 NTE5=RS_DIRX_CS_TYP_CS_DRG
77 I '$D(^PS(52.4,RX,0)),$D(^PSRX(RX,"DRI")) S SCRIPT=$P(^PSRX(RX,"DRI"),"^",2),SEV=$P(^PSRX(RX,"DRI"),"^") F X=1:1 S RXX(X)=$P(SCRIPT,",",X),SEV(X)=$P(SEV,",",X) Q:RXX(X)="" D
78 .S SER=$P(^PS(56,SEV(X),0),"^",4)
79 .S DIRX=$P($G(^PSRX(RXX(X),0)),"^"),TYP=$S(SER=1:"CRITICAL",SER=2:"SIGNIFICANT",1:"UNKNOWN")
80 .S DRG=$P(^PSDRUG($P(^PSRX(RXX(X),0),"^",6),0),"^")
81 .S:X=1 NTE5=DIRX_CS_TYP_CS_DRG
82 .S:X>1 NTE5=RS_DIRX_CS_TYP_CS_DRG
83 S NTE5=NTE5_CS_$S('$G(PSOSERV):"MAY REQUIRE",1:"REQUIRES")_$S('$G(PSOSERV):" REVIEWING BY A PHARMACIST",1:" INTERVENTION BY A PHARMACIST")
84 K SER,SCRIPT,DIRX,TYP,DRG,SEV,RXX,RX,RXY
85 Q
86START3 ;build NTE for drug allergy warning label ;PSO*198
87 Q:'$G(DAW)
88 S NTE6="NTE"_FS_6_FS_FS
89 I '$G(DIN) D
90 . S DARX=$P(^PSRX(IRXN,0),"^"),DRG=$P(^PSDRUG(IDGN,0),"^")
91 . S NTE6=NTE6_DARX_CS_DRG
92 I $G(DIN) D
93 . S DARX=$P(^PSRX(IRXN,0),"^"),DRG=$P(^PSDRUG(IDGN,0),"^") D
94 . . S NTE6=NTE6_DARX_CS_DRG
95 . . F XY=1:1 S INGRE=ING(XY) S:XY=1 NTE6=NTE6_CS_INGRE S:XY>1 NTE6=NTE6_RS_INGRE Q:'INGRE
96 K DARX,DRG,XY,INGRE
97 Q
98 ;PSO*198
99SPACE(PLN,CLN) ;check if a space should be inserted between lines of text
100 ; Input: PLN - previous line of text
101 ; CLN - current line of text to be appended to previous
102 ; function return: 0 - do not insert space
103 ; 1 - insert space
104 ;
105 ;quit 0, on cases where a space should NOT be inserted else assume 1
106 ;
107 N TSTP,TSTC,PCHR2,CCHR2 ; QUIT 0 CASES BELOW
108 Q:PLN="" 0 ;no previous line, ignore
109 Q:$E(PLN,$L(PLN))=" " 0 ;prev line ends in " "
110 Q:$E(CLN,1)=" " 0 ;curr line begins in " "
111 S PCHR2=$E(PLN,$L(PLN)-1,$L(PLN)) ;last 2 char of prev line
112 S CCHR2=$E(CLN,1,2) ;first 2 char of curr line
113 Q:PCHR2?1A1"/" 0 ;the prev & curr lines
114 Q:CCHR2?1"/"1A 0 ; split, ex: "and/or"
115 Q:PCHR2?1A1"-" 0 ;the prev & curr lines
116 Q:CCHR2?1"-"1A 0 ; split ex: "15-25 degrees"
117 S TSTP=$TR(PCHR2,"abcdefghijklmnoqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
118 S TSTC=$TR(CCHR2,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
119 S TSTP=TSTP_TSTC
120 Q:TSTP="E.G." 0 ;lines are splitting "e.g."
121 Q:TSTP="I.E." 0 ;lines are splitting "i.e."
122 ;
123 Q 1
Note: See TracBrowser for help on using the repository browser.