source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOSPSIG.m@ 1073

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

initial load of WorldVistAEHR

File size: 8.8 KB
Line 
1PSOSPSIG ;BIR/RTR,SAB-Parse out and create other lang. Sig ;9/24/01
2 ;;7.0;OUTPATIENT PHARMACY;**117**;DEC 1997
3 ;PSSORPH - DBIA 3234 ;^PS(50.606 - DBIA 2174 ;^PS(50.7 - DBIA 2223
4 ;^PS(51.2 - DBIA 2226 ;^PS(51 - DBIA 2224 ;^PSDRUG - DBIA 221
5 ;^PS(59.7 - DBIA 694 ;^PS(51.1 - DBIA 2225
6 ;
7EN(PSOFX) ;
8 K SIG9,PSNOUN,PSOROUTE,SIG0 S OI=$P($G(^PSRX(RX,"OR1")),"^") Q:'$G(OI)
9 S (FND,TODOSE)=0 F WW=0:0 S WW=$O(PSOFX("DOSE",WW)) Q:'WW S TODOSE=WW
10 S:TODOSE FND=1 Q:'TODOSE S SIGDS=+$P($G(^PS(50.7,OI,0)),"^",2)
11 S PREP=$S($P($G(^PS(50.606,SIGDS,"MISC1")),"^",2)]"":$P(^PS(50.606,SIGDS,"MISC1"),"^",2),1:$P($G(^PS(50.606,SIGDS,"MISC")),"^",3))
12 S RTCNT=0 K RTC,RTCA,RTCF F SSS=1:1:TODOSE D
13 .S SIG0(SSS)=$S($G(PSOFX("DOSE ORDERED",SSS))'="":$G(PSOFX("DOSE ORDERED",SSS)),1:$G(PSOFX("DOSE",SSS))) ;local dosage check
14 .I $G(PSOFX("DOSE ORDERED",SSS))="" S LODS=$O(^PSDRUG($P(^PSRX(RX,0),"^",6),"DOS2","B",SIG0(SSS),0)) I LODS D
15 ..S:$P(^PSDRUG($P(^PSRX(RX,0),"^",6),"DOS2",LODS,0),"^",4)]"" PSOFX("DOSE ORDERED",SSS)=$P(^PSDRUG($P(^PSRX(RX,0),"^",6),"DOS2",LODS,0),"^",4) K LODS
16 .S VERBX(SSS)=$S($G(PSOFX("VERB",SSS))]""&($P($G(^PS(50.606,SIGDS,"MISC1")),"^")]""):$P(^PS(50.606,SIGDS,"MISC1"),"^"),1:$G(PSOFX("VERB",SSS)))
17 .I $G(PSOFX("NOUN",SSS))]"" D NON
18 .S RTC=+$G(PSOFX("ROUTE",SSS)) I RTC S:'RTCNT RTCA=RTC S RTCNT=RTCNT+1
19 .I RTCNT>1,$G(RTC),$G(RTC)'=$G(RTCA) S RTCF=1
20 .S PSOROUTE(SSS)=$S($P($G(^PS(51.2,+$G(PSOFX("ROUTE",SSS)),0)),"^",7)]"":$P(^(0),"^",7),$P($G(^(0)),"^",2)]"":$P(^(0),"^",2),$P($G(^(0)),"^",3)]"":$P(^(0),"^",3),1:$P($G(^(0)),"^"))
21 .S MEDEXP(SSS)=$S($P($G(^PS(51.2,+$G(PSOFX("ROUTE",SSS)),0)),"^",2)="":0,1:1)
22 .S PDAYS(SSS)=$G(PSOFX("DURATION",SSS))
23 .I $G(PSOFX("DURATION",SSS))]"",($E(PSOFX("DURATION",SSS),$L(PSOFX("DURATION",SSS)))'?1A) S PDAYS(SSS)=PDAYS(SSS)_"D"
24 .S FOR=$O(^PS(59.7,"AOTH","FOR","")) S FOR=$S(FOR]"":FOR,1:"FOR")
25 .S PSDUR(SSS)=$S($G(PDAYS(SSS))']"":"NULL",1:FOR_" "_$E($G(PDAYS(SSS)),1,($L($G(PDAYS(SSS)))-1))) D I PSDUR(SSS)'="NULL" S PSDUR(SSS)=PSDUR(SSS)_" "_INTERVAL
26 ..I PSDUR(SSS)'="NULL" S INTERVAL=$E(PDAYS(SSS),$L(PDAYS(SSS))),INTERVAL=$S(INTERVAL="D":"DAYS",INTERVAL="W":"WEEKS",INTERVAL="H":"HOURS",INTERVAL="L":"MONTHS",INTERVAL="M":"MINUTES",INTERVAL="S":"SECONDS",1:"") D
27 ...Q:$G(INTERVAL)']"" S INTERVAL=$O(^PS(59.7,"AOTH",INTERVAL,""))
28 ...I $G(PSOFX("DURATION",SSS)),$G(PSOFX("DURATION",SSS))'>1 S INTERVAL=$E(INTERVAL,1,($L(INTERVAL)-1))
29 F GGG=1:1:TODOSE S ZSCHED(GGG)=$G(PSOFX("SCHEDULE",GGG)) D
30 .I $G(ZSCHED(GGG))="" S SCHED(GGG)="" Q
31 .S SGLFLAG=0 F WW=0:0 S WW=$O(^PS(51.1,"B",ZSCHED(GGG),WW)) Q:'WW!($G(SGLFLAG)) D
32 ..I $G(^PS(51.1,WW,3))]"" S SCHED(GGG)=^(3),SGLFLAG=1 Q
33 ..I $P($G(^PS(51.1,WW,0)),"^",8)'="" S SCHED(GGG)=$P($G(^(0)),"^",8),SGLFLAG=1
34 .Q:$G(SGLFLAG)
35 .I $O(^PS(51,"B",ZSCHED(GGG),0)) S IN=$O(^PS(51,"B",ZSCHED(GGG),0)) I $P($G(^PS(51,IN,4)),"^")]"" S SCHED(GGG)=$P(^PS(51,IN,4),"^") K IN Q
36 .I $G(^PS(51,"A",ZSCHED(GGG)))'="" S SCHED(GGG)=$P(^(ZSCHED(GGG)),"^") Q
37 .K IN S ZZSB=0 F ZZS=1:1:$L(ZSCHED(GGG)) S SZZ=$E(ZSCHED(GGG),ZZS) I SZZ=" " S ZZSB=ZZSB+1
38 .S ZZSB=ZZSB+1
39 .K SCHHOLD F GGGZ=1:1:ZZSB S (SDL,SCHHOLD(GGGZ))=$P(ZSCHED(GGG)," ",GGGZ) D
40 ..Q:$G(SDL)=""
41 ..S SGLFLAG=0 F WW=0:0 S WW=$O(^PS(51.1,"B",SDL,WW)) Q:'WW!($G(SGLFLAG)) D
42 ...I $G(^PS(51.1,WW,3))]"" S SCHED(GGG)=^(3),SCHHOLD(GGGZ)=^(3),SGLFLAG=1 Q
43 ...I $P($G(^PS(51.1,WW,0)),"^",8)]"" S SCHHOLD(GGGZ)=$P($G(^(0)),"^",8),SGLFLAG=1
44 ..Q:$G(SGLFLAG)
45 ..I $G(^PS(51,"A",SDL))]"" S IN=$O(^PS(51,"B",SDL,0)) D:IN Q
46 ...S SCHHOLD(GGGZ)=$S($G(^PS(51,IN,4))]"":^PS(51,IN,4),1:$P(^PS(51,"A",SDL),"^"))
47 .S SCHED(GGG)="",SGLFLAG=0 F WW=1:1:ZZSB S SCHED(GGG)=SCHED(GGG)_$S($G(SGLFLAG):" ",1:"")_$G(SCHHOLD(WW)),SGLFLAG=1
48 S (RTC,RTCA,PSOBDCT)=0 F FFF=0:0 S FFF=$O(SIG0(FFF)) Q:'FFF D
49 .K PSOSG1,PSOSG2 S VERB=$G(VERBX(FFF)) D VERB D:$G(PSNOUN(FFF))'=""&('$G(PSOSG1)) SSS
50 .D FRAC
51 .S SIG2(FFF)=$S($G(VERB)'=""&('$G(PSOSG1)):$G(VERB)_" ",1:"")_$S($G(PSOFX("DOSE ORDERED",FFF))'="":$S($G(PSOFRAC)'="":$G(PSOFRAC),1:$G(PSOFX("DOSE ORDERED",FFF)))_" ",1:$G(PSOFX("DOSE",FFF))_" ")
52 .S PSOBDCT=PSOBDCT+1
53 .K PSOFRAC,PSOFRACX
54 .I RTC>0,$G(PSOROUTE(FFF))'="",'$G(RTCF) S RTCA=1
55 .I $G(PSOROUTE(FFF))'="" S RTC=RTC+1
56 .S SIG2(FFF)=SIG2(FFF)_$S($G(PSNOUN(FFF))'=""&('$G(PSOSG2)):$G(PSNOUN(FFF))_" ",1:"")_$S(PREP'=""&($G(MEDEXP(FFF)))&('RTCA):PREP_" ",1:"")
57 .S SIG2(FFF)=SIG2(FFF)_$S(PSOROUTE(FFF)'=""&('RTCA):PSOROUTE(FFF)_" ",1:"")
58 .S SIG2(FFF)=SIG2(FFF)_$S(SCHED(FFF)'="":SCHED(FFF)_$S($G(PSDUR(FFF))="NULL"&($G(PSOFX("CONJUNCTION",FFF))="")&('$O(SIG0(FFF))):"",1:" "),1:"")
59 .S PSOCJ=$E($G(PSOFX("CONJUNCTION",FFF)))
60 .S CON=$S($G(PSOCJ)="A":"AND",$G(PSOCJ)="T":"THEN",$G(PSOCJ)="S":"THEN",$G(PSOCJ)="X":"EXCEPT",1:"") I CON]"" S CON=$O(^PS(59.7,"AOTH",CON,""))
61 .S SIG2(FFF)=SIG2(FFF)_$S(PSDUR(FFF)'="NULL":PSDUR(FFF)_$S($G(PSOFX("CONJUNCTION",FFF))=""&('$O(SIG0(FFF))):"",1:", "),1:"")_CON
62 .K PSOSG1,PSOSG2
63 .K PSOUCS S SIG2(FFF)=$$UPPER(SIG2(FFF)) K PSOUCS
64 S PSODCT="" F S PSODCT=$O(PSOFX("SIG",PSODCT)) Q:PSODCT="" S PSOBDCT=PSOBDCT+1 S SIG2(PSOBDCT)=$G(PSOFX("SIG",PSODCT)) K PSOUCS S SIG2(PSOBDCT)=$$UPPER(SIG2(PSOBDCT)) K PSOUCS
65STUFF ;
66 S DCOUNT=0
67 I '$D(SIG2(1)) G QUIT
68 I '$O(SIG2(1)),$L(SIG2(1))<71 S SIG9(1)=SIG2(1)
69 S (VAR,VAR1)="",II=1
70 F FF=0:0 S FF=$O(SIG2(FF)) Q:'FF S CT=0 F NN=1:1:$L(SIG2(FF)) I $E(SIG2(FF),NN)=" "!($L(SIG2(FF))=NN) S CT=CT+1 D I $L(VAR)>70 S SIG9(II)=LIM_" ",II=II+1,VAR=VAR1
71 .S VAR1=$P(SIG2(FF)," ",(CT))
72 .S LIM=VAR
73 .S VAR=$S(VAR="":VAR1,1:VAR_" "_VAR1)
74 I $G(VAR)'="" S SIG9(II)=VAR
75QUIT K SSS,TT,DCOUNT,PREP,VERB,FFF,GGG,SIGDS,SIGRT,PSOROUTE,PSOSG1,PSOSG2 Q
76SIG1 ;
77 F FFF=0:0 S FFF=$O(SIG0(FFF)) Q:'FFF S SIG2(FFF)=SIG0(FFF)
78 Q
79DAYS I +$E($P(SIG1(TT),"^",2))!($E($P(SIG1(TT),"^",2))=0) S $P(SIG1(TT),"^",2)="D"_$P(SIG1(TT),"^",2)
80 Q
81NON ;
82 S NN=PSOFX("NOUN",SSS)
83 S NOUN=$O(^PS(50.606,SIGDS,"NOUN","B",NN,0)) I NOUN S PSNOUN(SSS)=$S($G(^PS(50.606,SIGDS,"NOUN",NOUN,1))]"":^PS(50.606,SIGDS,"NOUN",NOUN,1),1:NN) K NN Q
84 K NN,NOUN D DOSE^PSSORPH(.XDOSE,$P(^PSRX(RX,0),"^",6),"O") Q:$P(XDOSE("DD",$P(^PSRX(RX,0),"^",6)),"^",9)=""
85 S NN=$P(XDOSE("DD",$P(^PSRX(RX,0),"^",6)),"^",9),NOUN=$O(^PS(50.606,SIGDS,"NOUN","B",NN,0))
86 I NOUN S PSNOUN(SSS)=$S($G(^PS(50.606,SIGDS,"NOUN",NOUN,1))]"":^PS(50.606,SIGDS,"NOUN",NOUN,1),1:NN)
87 K XDOSE,NN Q
88VERB ;Check if verb and noun need to be added to SIG
89 K PSOLCS,PSOUCS,PSOISL,PSOVL
90 I $G(VERB)'="" S PSOVL=$L(VERB),PSOISL=$E($G(SIG0(FFF)),1,$G(PSOVL)) I $G(PSOISL)'="" D
91 .S PSOUCS=VERB
92 .S PSOUCS=$$UPPER(PSOUCS) I PSOUCS=PSOISL S PSOSG1=1 Q
93 .S PSOUCS=$$LOWER(PSOUCS) I PSOUCS=PSOISL S PSOSG1=1 Q
94 .S PSOUCS=$$UPPER($E(PSOUCS,1))_$$LOWER($E(PSOUCS,2,99)) I PSOUCS=PSOISL S PSOSG1=1 Q
95 I $G(PSNOUN(FFF))="" G VERBEX
96 S PSOISL=$G(SIG0(FFF)) I $G(PSOISL)="" G VERBEX
97 S PSOVL=$F(PSNOUN(FFF),"(")
98 I $G(PSOVL)>2 S PSOUCS=$E(PSNOUN(FFF),1,(PSOVL-2))
99 I $G(PSOVL)'>2 S PSOUCS=PSNOUN(FFF)
100 I $G(PSOISL)'="" D
101 .S PSOUCS=$$UPPER(PSOUCS) I PSOISL[PSOUCS S PSOSG2=1 Q
102 .S PSOUCS=$$LOWER(PSOUCS) I PSOISL[PSOUCS S PSOSG2=1 Q
103 .S PSOUCS=$$UPPER($E(PSOUCS,1))_$$LOWER($E(PSOUCS,2,99)) I PSOISL[PSOUCS S PSOSG2=1
104VERBEX K PSOLCS,PSOUCS,PSOISL,PSOVL Q
105 ;
106UPPER(PSOUCS) ;
107 Q $TR(PSOUCS,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
108 ;
109LOWER(PSOLCS) ;
110 Q $TR(PSOLCS,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
111 Q
112 ;
113SSS ;
114 K PSOFNL,PSOFNLF,PSOFNLX
115 Q:$G(PSNOUN(FFF))=""
116 Q:$L(PSNOUN(FFF))'>3
117 Q:'$G(PSOFX("DOSE ORDERED",FFF))
118 S PSOFNL=$E(PSNOUN(FFF),($L(PSNOUN(FFF))-2),$L(PSNOUN(FFF)))
119 I $G(PSOFNL)="(S)"!($G(PSOFNL)="(s)") D
120 .I $G(PSOFX("DOSE ORDERED",FFF))'>1 S PSNOUN(FFF)=$E(PSNOUN(FFF),1,($L(PSNOUN(FFF))-3))
121 .I $G(PSOFX("DOSE ORDERED",FFF))>1 S PSNOUN(FFF)=$E(PSNOUN(FFF),1,($L(PSNOUN(FFF))-3))_$E(PSOFNL,2)
122 Q
123FRAC ;
124 K PSOFRAC,PSOFRACX,PSOFRAC1,PSOFRAC2
125 I $G(PSOFX("DOSE ORDERED",FFF))="" Q
126 I $G(PSOFX("DOSE ORDERED",FFF))'["." S (PSOFRAC1,PSOFRAC)=$G(PSOFX("DOSE ORDERED",FFF)) D NUM D G FRACQ
127 .I $G(PSOFRAC1)=$G(PSOFRAC) K PSOFRAC,PSOFRAC1 Q
128 .S PSOFRAC=$G(PSOFRAC1)
129 S PSOFRAC1=$P(PSOFX("DOSE ORDERED",FFF),"."),PSOFRAC2=$P(PSOFX("DOSE ORDERED",FFF),".",2)
130 S PSOFRACX="."_$G(PSOFRAC2)
131 S PSOFRAC=$S(PSOFRACX=".5":"ONE-HALF",PSOFRACX=".25":"ONE-FOURTH",PSOFRACX=".33":"ONE-THIRD",PSOFRACX=".34":"ONE-THIRD",PSOFRACX=".50":"ONE-HALF",PSOFRACX=".66":"TWO-THIRDS",PSOFRACX=".67":"TWO-THIRDS",PSOFRACX=".75":"THREE-FOURTHS",1:PSOFRACX)
132 S PSOFRAC9=$O(^PS(59.7,"AOTH",PSOFRAC,"")) I PSOFRAC9]"" S PSOFRAC=PSOFRAC9
133 K PSOFRAC9
134 I $G(PSOFRAC)="" K PSOFRAC G FRACQ
135 I $G(PSOFRAC1)'="",+$G(PSOFRAC1) D
136 .D NUM S AND=$O(^PS(59.7,"AOTH","AND",""))
137 .S PSOFRAC=$G(PSOFRAC1)_" "_$S(AND]"":AND,1:"AND")_" "_$S($E($G(PSOFRAC),1)=".":"0",1:"")_$G(PSOFRAC)
138 I $E($G(PSOFRAC),1)="." S PSOFRAC="0"_$G(PSOFRAC)
139FRACQ K PSOFRAC1,PSOFRAC2,AND
140 Q
141NUM ;
142 Q:$G(PSOFRAC1)=""
143 S PSOFRAC1=$S(PSOFRAC1="1":"ONE",PSOFRAC1="2":"TWO",PSOFRAC1="3":"THREE",PSOFRAC1="4":"FOUR",PSOFRAC1="5":"FIVE",PSOFRAC1="6":"SIX",PSOFRAC1="7":"SEVEN",PSOFRAC1="8":"EIGHT",PSOFRAC1="9":"NINE",PSOFRAC1="10":"TEN",1:PSOFRAC1)
144 S PSOFRAC9=$O(^PS(59.7,"AOTH",PSOFRAC1,"")) I PSOFRAC9]"" S PSOFRAC1=PSOFRAC9
145 K PSOFRAC9
146 Q
Note: See TracBrowser for help on using the repository browser.