source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOLBL4.m@ 1036

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

revised back to 6/30/08 version

File size: 7.6 KB
Line 
1PSOLBL4 ;BIR/RTR-Set up routine for HL7 interface ;10/20/96
2 ;;7.0;OUTPATIENT PHARMACY;**26,70,156,244,233**;DEC 1997;Build 8
3 ;External reference to ^PSDRUG supported by DBIA 221
4 ;
5 ;*244 - ignore RX's with a status > 11
6 ;
7 N DIC,AP,X,Y,DPRT,QPRT
8 I $G(ZTIO)]"" D
9 .Q:'$O(^PS(59,PSOSITE,"P",0))
10 .S DIC=3.5,DIC(0)="",X=ZTIO D ^DIC K DIC,X Q:Y=-1
11 .S DPRT=+Y
12 .F AP=0:0 S AP=$O(^PS(59,PSOSITE,"P",AP)) Q:'AP I +$P(^PS(59,PSOSITE,"P",AP,0),"^")=DPRT S QPRT=1
13 .I '$G(QPRT) S $P(PSOPAR,"^",30)=0
14 Q:'$P($G(PSOPAR),"^",30)
15 Q:$G(PSOEXREP)
16HL N PSODTM,HHHH,HLCOT,HLFLAG,HLFOUR,HLINGF,HLINRX,HLINRX0,HLLOOP,HLNEXT,HLRR,HLRX,HLRXY,LL,PPLHL,PSHALP,HDFN,HLDFN,HNEWDFN,HLDAI,HLOSITE,HLJUST,HLRXYZ,PSOLLN,PSOLLL,PSFLG,HDFN1
17 S HLOSITE=$P($G(PSOPAR),"^",30)
18 K ^UTILITY($J,"PSOHL"),^UTILITY($J,"PSOHLL"),HLRXY
19 S PPLHL=PPL G:HLOSITE=4 SOMD
20 S HLFLAG=0 F HLLOOP=1:1 S HLRX=$P(PPLHL,",",HLLOOP) D Q:$G(HLFLAG)
21 .S HLNEXT=$P(PPLHL,",",(HLLOOP+1)) I HLNEXT=""!(HLNEXT=",") S HLFLAG=1
22 .Q:'$G(HLRX)
23 .Q:'$D(^PSRX(HLRX,0))
24 .Q:$P($G(^PSRX(HLRX,"STA")),"^")=4
25 .Q:$G(RXRP(HLRX,"RP"))
26 .I $P($G(^PSRX(HLRX,"STA")),"^")>11!('$P(^PSRX(HLRX,0),"^",2)) Q
27 .I $G(PSODBQ) S HLRR=$O(^PS(52.5,"B",HLRX,0)) Q:'HLRR I $G(^PS(52.5,+HLRR,"P"))=1 Q
28 .;Here, if Site Parameter is 3, check entry in Drug File for National Id
29 .I $G(HLOSITE)=3 S HLJUST=+$P($G(^PSRX(HLRX,0)),"^",6) I '$P($G(^PSDRUG(HLJUST,6)),"^") Q
30 .S HLRXY(HLLOOP,HLRX)="" ; VALID RXS
31 .S:$G(HLOSITE)=3 HLRXYZ(HLRX)=""
32 I $G(HLOSITE)=3,$D(HLRXY) D
33 .N HLZFLAG,HLZ,HLZRX,HLZNEXT
34 .S HLZFLAG=0 K PPL F HLZ=1:1 S HLZRX=$P(PPLHL,",",HLZ) D Q:$G(HLZFLAG)
35 ..S HLZNEXT=$P(PPLHL,",",(HLZ+1)) I HLZNEXT=""!(HLZNEXT=",") S HLZFLAG=1
36 ..Q:'$G(HLZRX)
37 ..Q:$D(HLRXYZ(HLZRX))
38 ..I $G(RXRP(HLZRX,"RP")) D Q
39 ...I $G(PPL)="" S PPL=HLZRX_"," Q
40 ...S PPL=PPL_HLZRX_","
41 ..I $G(PPL)="" S PPL=HLZRX_"," Q
42 ..S PPL=PPL_HLZRX_","
43SOMDQ S HLCOT=1,PSHALP="" F S PSHALP=$O(HLRXY(PSHALP)) Q:PSHALP="" S ^UTILITY($J,"PSOHLL",HLCOT)=$O(HLRXY(PSHALP,0)),HLCOT=HLCOT+1
44 I HLCOT=1 G ENDHL ; NOTHING SET, BYPASS CALL TO QUEUE
45 F HLCOT=0:0 S HLCOT=$O(^UTILITY($J,"PSOHLL",HLCOT)) Q:'HLCOT S HLINRX=^(HLCOT),HLINRX0=$G(^PSRX(HLINRX,0)) D
46 .S ^UTILITY($J,"PSOHLL",HLCOT)=HLINRX_"^"_+$P(HLINRX0,"^",6)_"^"_$S($G(RXPR(HLINRX)):"P",1:"F")
47 .I '$G(RXPR(HLINRX)) S HLFOUR=0 F HHHH=0:0 S HHHH=$O(^PSRX(HLINRX,1,HHHH)) Q:'HHHH I +^(HHHH,0) S HLFOUR=HHHH
48 .I '$G(RXPR(HLINRX)),$G(RXFL(HLINRX))'="" S HLFOUR=$S($G(RXFL(HLINRX))=0:0,$D(^PSRX(HLINRX,1,+$G(RXFL(HLINRX)),0)):+$G(RXFL(HLINRX)),1:$G(HLFOUR))
49 .S ^UTILITY($J,"PSOHLL",HLCOT)=^UTILITY($J,"PSOHLL",HLCOT)_"^"_$S($G(RXPR(HLINRX)):RXPR(HLINRX),1:HLFOUR)_"^"_$S($P($G(^PSRX(HLINRX,3)),"^",6)&('$G(RXPR(HLINRX)))&('$G(RXFL(HLINRX))):1,1:0) D ACLOG
50 .S HLINGF=0 I $P(^UTILITY($J,"PSOHLL",HLCOT),"^",5),$O(^PSRX(HLINRX,"DAI",0)) S HLINGF=1 D
51 ..F LL=0:0 S LL=$O(^PSRX(HLINRX,"DAI",LL)) Q:'LL S ^UTILITY($J,"PSOHLL",HLCOT,HLINGF)=$G(^PSRX(HLINRX,"DAI",LL,0)),HLINGF=HLINGF+1
52 .S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",6)=$S($G(HLINGF):1,1:0)
53 .I $D(^PSRX(HLINRX,"DRI")),'$G(RXPR(HLINRX)),'$G(RXFL(HLINRX)) S ^UTILITY($J,"PSOHLL",HLCOT,"DRI")=^PSRX(HLINRX,"DRI"),$P(^UTILITY($J,"PSOHLL",HLCOT),"^",7)=1
54 .E S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",7)=0
55 .S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",8)=0 D RPT Q:'$G(^PSRX(HLINRX,"IB"))
56 .I $P(^PSRX(HLINRX,"STA"),"^")>0,$P(^("STA"),"^")'=2,'$G(PSODBQ) Q
57 .S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",8)=1
58 ;
59AAA D STRT^PSOHLSG5
60 S (HDFN,HDFN1)=$O(^UTILITY($J,"PSOHLL",0)),HDFN=$P(^PSRX($P(^(HDFN),"^"),0),"^",2),PSOLLL=$P(^UTILITY($J,"PSOHLL",HDFN1),"^",12)
61 F HLDFN=0:0 S HLDFN=$O(^UTILITY($J,"PSOHLL",HLDFN)) Q:'HLDFN D S ^UTILITY($J,"PSOHL",HLDFN)=^UTILITY($J,"PSOHLL",HLDFN) D OTHER
62 .S PSFLG=0,PSOLLN=$P(^UTILITY($J,"PSOHLL",HLDFN),"^",12),HNEWDFN=$P(^PSRX($P(^UTILITY($J,"PSOHLL",HLDFN),"^"),0),"^",2) D
63 ..I HDFN'=HNEWDFN S HDFN=HNEWDFN,PSFLG=1
64 ..I PSOLLL'=PSOLLN S PSOLLL=PSOLLN,PSFLG=1
65 ..I PSFLG=1 D SETZ
66 I '$D(^UTILITY($J,"PSOHL")) G ENDHL
67CALL D SETZ
68ENDHL K ^UTILITY($J,"PSOHL"),^UTILITY($J,"PSOHLL"),HLRXY
69 Q
70OTHER I $G(^UTILITY($J,"PSOHLL",HLDFN,"DRI"))'="" S ^UTILITY($J,"PSOHL",HLDFN,"DRI")=^UTILITY($J,"PSOHLL",HLDFN,"DRI")
71 F HLDAI=0:0 S HLDAI=$O(^UTILITY($J,"PSOHLL",HLDFN,HLDAI)) Q:'HLDAI S ^UTILITY($J,"PSOHL",HLDFN,HLDAI)=^UTILITY($J,"PSOHLL",HLDFN,HLDAI)
72 Q
73ACLOG ;Activity log (sending to Hl7 interface)
74 N DTTM,HCOM,HCNT,HJJ
75 D NOW^%DTC S DTTM=%,HCOM="Prescription"_$S($G(RXPR(HLINRX)):" (Partial)",1:"")_$S($G(PSOSUREP)!($G(RXRP(HLINRX))):" (Reprint)",1:"")_" sent to external interface."
76 S HCNT=0 F HJJ=0:0 S HJJ=$O(^PSRX(HLINRX,"A",HJJ)) Q:'HJJ S HCNT=HJJ
77 S HCNT=HCNT+1,^PSRX(HLINRX,"A",0)="^52.3DA^"_HCNT_"^"_HCNT S ^PSRX(HLINRX,"A",HCNT,0)=DTTM_"^X^"_$G(PDUZ)_"^"_$S($G(RXPR(HLINRX)):6,$G(HLFOUR)<6:$G(HLFOUR),1:(HLFOUR+1))_"^"_HCOM
78 Q
79SUS(HSREX,HSFL,HSFILL,HSRP) ;
80 N DA,DIK,DTTM,HSCOM,HSCNT,HSJJ,HSLDUZ,PSHLCPRS
81 I $P($G(^PSRX(HSREX,"STA")),"^")=5 S $P(^PSRX(HSREX,"STA"),"^")=0 S PSHLCPRS="Removed from Suspense, External Interface." D EN^PSOHLSN1(HSREX,"SC","ZU",PSHLCPRS)
82 S DA=$O(^PS(52.5,"B",HSREX,0)) I DA K DIK S DIK="^PS(52.5," D ^DIK
83 I $G(HSFL)="P" S HSLDUZ=+$P($G(^PSRX(HSREX,"P",HSFILL,0)),"^",7)
84 E S HSLDUZ=$S('HSFILL:+$P($G(^PSRX(HSREX,0)),"^",16),1:+$P($G(^PSRX(HSREX,1,HSFILL,0)),"^",7))
85 D NOW^%DTC S DTTM=%,HSCOM="Removed from Suspense"_$S($G(HSFL)="P":" (Partial)",1:"")_$S($G(HSRP):" (Reprint)",1:"")_" (External Interface)"
86 S HSCNT=0 F HSJJ=0:0 S HSJJ=$O(^PSRX(HSREX,"A",HSJJ)) Q:'HSJJ S HSCNT=HSJJ
87 S HSCNT=HSCNT+1,^PSRX(HSREX,"A",0)="^52.3DA^"_HSCNT_"^"_HSCNT S ^PSRX(HSREX,"A",HSCNT,0)=DTTM_"^X^"_$G(HSLDUZ)_"^"_$S($G(HSFL)="P":6,$G(HSFILL)<6:$G(HSFILL),1:(HSFILL+1))_"^"_$G(HSCOM)
88 Q
89LAB(HLREX,HLFL,HLFILL,HLREPT) ;
90 N HLDUZ,NOW,DA,HCT,HFF
91 D NOW^%DTC S NOW=% S HCT=0 F HFF=0:0 S HFF=$O(^PSRX(HLREX,"L",HFF)) Q:'HFF S HCT=HFF
92 I HLFL="F" S HLDUZ=$S('HLFILL:+$P($G(^PSRX(HLREX,0)),"^",16),1:+$P($G(^PSRX(HLREX,1,HLFILL,0)),"^",7))
93 I HLFL="P" S HLDUZ=+$P($G(^PSRX(HLREX,"P",HLFILL,0)),"^",7)
94 S HCT=HCT+1,^PSRX(HLREX,"L",0)="^52.032DA^"_HCT_"^"_HCT
95 S ^PSRX(HLREX,"L",HCT,0)=NOW_"^"_$S($G(HLFL)="F":HLFILL,1:(99-HLFILL))_"^"_"From Rx number "_$P(^PSRX(HLREX,0),"^")_$S($G(HLFL)="P":" (Partial)",1:"")_$S($G(HLREPT):" (Reprint)",1:"")_" (External Interface)"_"^"_$G(HLDUZ)
96 N PSOBADR,PSOTEMP
97 S PSOBADR=$$CHKRX^PSOBAI(HLREX)
98 I $G(PSOBADR) S PSOTEMP=$P(PSOBADR,"^",2),PSOBADR=$P(PSOBADR,"^")
99 I $G(PSOBADR),'$G(PSOTEMP) D
100 .S HCT=HCT+1,^PSRX(HLREX,"L",0)="^52.032DA^"_HCT_"^"_HCT
101 .S ^PSRX(HLREX,"L",HCT,0)=NOW_"^"_$S($G(HLFL)="F":HLFILL,1:(99-HLFILL))_"^"_"ROUTING="_$G(MW)_" (BAD ADDRESS)"_"^"_$G(HLDUZ)
102 Q
103RPT ;
104 S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",9)=$S($G(PSOSUREP)!($G(RXRP(HLINRX))):1,1:0)
105 S $P(^UTILITY($J,"PSOHLL",HLCOT),"^",10)=+$G(PDUZ)
106 Q
107SETZ ;
108 D NOW^%DTC S PSODTM=%
109 S ZTRTN=$S($$GET1^DIQ(59,PSOSITE_",",105,"I")=2.4:"INIT^PSOHLDS",1:"INIT^PSOHLSG")
110 S ZTIO="",ZTDTH=$H,ZTSAVE("^UTILITY($J,""PSOHL"",")="",ZTSAVE("PSOPAR")="",ZTSAVE("PSOSITE")="",ZTSAVE("PSODTM")="",ZTSAVE("PSOLAP")=""
111 S ZTSAVE("RXRP(")="",ZTSAVE("RXPR(")="",ZTSAVE("RXFL(")="",ZTSAVE("RXRS(")=""
112 S ZTDESC=$S($$GET1^DIQ(59,PSOSITE_",",105,"I")=2.4:"Outpatient Automation External Interface",1:"GENERIC INTERFACE LABEL INFORMATION")
113 D ^%ZTLOAD
114 Q
115SOMD ;send only mark drugs to external interface and print in vista
116 S HLFLG=0 F HLLP=1:1 S HLRX=$P(PPLHL,",",HLLP) D Q:$G(HLFLG)
117 .S HLNEXT=$P(PPLHL,",",(HLLP+1)) I HLNEXT=""!(HLNEXT=",") S HLFLG=1
118 .Q:'$G(HLRX)
119 .Q:'$D(^PSRX(HLRX,0))
120 .Q:$P($G(^PSRX(HLRX,"STA")),"^")=4
121 .I $P($G(^PSRX(HLRX,"STA")),"^")>11!('$P(^PSRX(HLRX,0),"^",2)) Q
122 .Q:$G(RXRP(HLRX,"RP"))
123 .S HLRR=$O(^PS(52.5,"B",HLRX,0)) Q:'HLRR I $G(^PS(52.5,+HLRR,"P"))=1 K HLRR Q
124 .S DRG=+$P($G(^PSRX(HLRX,0)),"^",6) I '$P($G(^PSDRUG(DRG,6)),"^") Q
125 .S HLRXY(HLRX)="" ; VALID RXS
126 I $D(HLRXY) G SOMDQ
127 Q
Note: See TracBrowser for help on using the repository browser.