source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJORRE1.m@ 862

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

revised back to 6/30/08 version

File size: 6.7 KB
RevLine 
[623]1PSJORRE1 ;BIR/MV-RETURN INPATIENT ACTIVE MEDS (EXPANDED) ;29 Jan 99 / 8:49 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**22,51,50,58,81,91,110,111**;16 DEC 97
3 ;
4 ; Reference to ^PS(51.2 is supported by DBIA 2178.
5 ; Reference to ^PS(52.6 is supported by DBIA 1231.
6 ; Reference to ^PS(52.7 is supported by DBIA 2173.
7 ; Reference to ^PS(55 is supported by DBIA 2191.
8 ; Reference to ^PSDRUG is supported by DBIA 2192.
9 ; Reference to OTF^OR3CONV is supported by DBIA 2412.
10 ; Reference to ^TMP("PS" is documented in DBIA #2384.
11 ;
12OEL(DFN,ON) ; return list of expanded inpat meds
13 K ^TMP("PS",$J)
14 N ADM,CNT,DN,DO,F,INFUS,INST,MR,ND,ND0,ND2,ND2P5,ND6,NDOI,SCH,SIO,START,STAT,STOP,TYP,UNITS,X,Y
15 ;Check if 5.0 order conversion should be run for the selected patient.
16 ;I '$P($G(^PS(55,DFN,5.1)),U,11) D CONVERT^PSJUTL1(DFN,0)
17 F S X=$$OTF^OR3CONV(DFN,$S($E(IOST,1)="C":0,1:1)) Q:+X'<0 D
18 .I +X=-1 H 3
19 S F=$S(ON["P":"^PS(53.1,",ON["U":"^PS(55,DFN,5,",1:"^PS(55,"_DFN_",""IV"",")
20 I ON'["P",'$D(@(F_+ON_")")) Q
21 I ON["P" S X=$G(^PS(53.1,+ON,0)) Q:$P(X,U,15)'=DFN S TYP=$P(X,U,4) D @$S(TYP="U":"UDTMP",1:"IVTMP")
22 D:ON'["P" @$S(ON["U":"UDTMP",1:"IVTMP")
23 S Y=$S(ON["V":5,1:12),CNT=0
24 I $O(@(F_+ON_","_Y_",0)")) D
25 . F X=0:0 S X=$O(@(F_+ON_","_Y_","_X_")")) Q:'X D
26 ..S CNT=CNT+1,ND=$G(@(F_+ON_","_Y_","_X_",0)")),^TMP("PS",$J,"PC",CNT,0)=ND
27 S ^TMP("PS",$J,"PC",0)=CNT
28 Q
29 ;
30UDTMP ;*** Set ^TMP for Unit dose orders.
31 N DO,DN,INST,X,Y,PROVIDER,NOTGIVEN,RNWDT
32 S (MR,SCH,INST)=""
33 S ND2=$G(@(F_+ON_",2)")),ND0=$G(@(F_+ON_",0)"))
34 S ND6=$P($G(@(F_+ON_",6)")),"^")
35 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT
36 S STAT=$$CODES^PSIVUTL($P(ND0,U,9),$S(ON["P":53.1,1:55.06),28)
37 D DRGDISP^PSJLMUT1(DFN,ON,40,0,.DN,1)
38 S NDOI=$G(@(F_+ON_",.2)")),DO=$P(NDOI,U,2)
39 ;S UNITS="" I '$O(@(F_+ON_",1,1)")),DO="" S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2)
40 S UNITS="" I '$O(@(F_+ON_",1,1)")) S UNITS=$P($G(@(F_+ON_",1,1,0)")),U,2) S:(ON["U")&(UNITS="") UNITS=1
41 S MR=$$MR(+$P(ND0,U,3)),INST=$G(@(F_+ON_",.3)"))
42 S NOTGIVEN=$S(ON["U":$P($G(^PS(55,DFN,5,+ON,0)),"^",22),1:"")
43 S ^TMP("PS",$J,0)=DN(1)_"^^"_$P(ND2,U,4)_"^^"_$P(ND2,U,2)_U_STAT_"^^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_U_NOTGIVEN_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT)
44 ;S ^TMP("PS",$J,0)=DN(1)_"^^"_$P(ND2,U,4)_"^^"_$P(ND2,U,2)_U_STAT_"^^^"_DO_U_UNITS_U_$P(ND0,U,21)_U_U_$P($G(^PS(55,DFN,5,+ON,0)),"^",22)_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))
45 S PROVIDER=$P($G(@(F_+ON_",0)")),"^",2)
46 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
47 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR
48 S ^TMP("PS",$J,"SCH",0)=$P(ND2,U)]"" S:$P(ND2,U)]"" ^TMP("PS",$J,"SCH",1,0)=$P(ND2,U)
49 S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7)
50 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST
51 S ^TMP("PS",$J,"ADM",0)=$P(ND2,U,5)]"" S:$P(ND2,U,5)]"" ^TMP("PS",$J,"ADM",1,0)=$P(ND2,U,5)
52 S ^TMP("PS",$J,"SIO",0)=ND6]"" S:ND6]"" ^TMP("PS",$J,"SIO",1,0)=ND6
53 NEW VERPHARM S:ON["U" VERPHARM=$P($G(@(F_+ON_",4)")),U,3)
54 S:+$G(VERPHARM) $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM
55 NEW PSJDD,INACTDT,NDDD,OUTOI,PSJOUT S CNT=0
56 F PSJDD=0:0 S PSJDD=$O(@(F_+ON_",1,PSJDD)")) Q:'PSJDD D
57 . S NDDD=@(F_+ON_",1,PSJDD,0)")
58 . I $P(NDDD,U,3)]"",($P(NDDD,U,3)'>DT) Q
59 . S PSJOUT=$P($G(^PSDRUG(+NDDD,8)),U,5)
60 . I +PSJOUT D
61 .. S INACTDT=$G(^PSDRUG(+PSJOUT,"I")),OUTOI=+$G(^PSDRUG(+PSJOUT,2))
62 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)=""
63 . I '+PSJOUT,($P($G(^PSDRUG(+NDDD,2)),U,3)["O") D
64 .. S PSJOUT=+NDDD,OUTOI=+NDOI
65 .. S INACTDT=$G(^PSDRUG(+NDDD,"I"))
66 .. I INACTDT]"",(INACTDT'>DT) S (PSJOUT,OUTOI)=""
67 . ;* S UNITS=$S('+$P(NDDD,U,2):1,1:$P(NDDD,U,2))
68 . S UNITS=$P(NDDD,U,2) S:(ON["U")&(UNITS="") UNITS=1
69 . S CNT=CNT+1,^TMP("PS",$J,"DD",CNT,0)=+NDDD_U_UNITS_U_PSJOUT_U_$G(OUTOI)
70 S ^TMP("PS",$J,"DD",0)=CNT
71 Q
72 ;
73IVTMP ;*** Set ^TMP for IV orders.
74 N PROVIDER,RNWDT,IVLIM S ND0=$G(@(F_+ON_",0)")),CNT=0
75 F X=0:0 S X=$O(@(F_+ON_",""AD"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""AD"","_X_",0)")),DN=$P($G(^PS(52.6,+ND,0)),U),Y=DN_U_$P(ND,U,2) S:$P(ND,U,3) Y=Y_U_$P(ND,U,3) S CNT=CNT+1,^TMP("PS",$J,"A",CNT,0)=Y
76 S RNWDT=$$LASTREN^PSJLMPRI(DFN,ON) I RNWDT S RNWDT=+RNWDT
77 S ^TMP("PS",$J,"A",0)=CNT,CNT=0
78 F X=0:0 S X=$O(@(F_+ON_",""SOL"","_X_")")) Q:'X S ND=$G(@(F_+ON_",""SOL"","_X_",0)")),DN=$G(^PS(52.7,+ND,0)),CNT=CNT+1,^TMP("PS",$J,"B",CNT,0)=$P(DN,U)_U_$P(ND,U,2)_U_$P(DN,U,4)
79 S ^TMP("PS",$J,"B",0)=CNT
80 S INST=$G(@(F_+ON_",.3)"))
81 I ON["P" D
82 . S SCH=$P($G(^PS(53.1,+ON,2)),U)
83 . S PROVIDER=$P(ND0,U,2)
84 . S MR=$$MR(+$P(ND0,U,3)),STAT=$$CODES^PSIVUTL($P(ND0,U,9),53.1,28)
85 . S INFUS=$P($G(^PS(53.1,+ON,8)),U,5)
86 . S ND2=$G(@(F_+ON_",2)")),START=$P(ND2,U,2),STOP=$P(ND2,U,4)
87 . S ADM=$P(ND2,U,5),SIO=$P($G(@(F_+ON_",6)")),"^")
88 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM=""
89 I ON'["P" D
90 . S PROVIDER=$P(ND0,U,6)
91 . S SCH=$P(ND0,U,9),INFUS=$P(ND0,U,8),STAT=$$CODES^PSIVUTL($P(ND0,U,17),55.01,100)
92 . S MR=$$MR(+$P($G(^PS(55,DFN,"IV",+ON,.2)),U,3))
93 . S START=$P(ND0,U,2),STOP=$P(ND0,U,3)
94 . S ADM=$P(ND0,U,11),SIO=$P($G(@(F_+ON_",3)")),"^")
95 . NEW VERPHARM S VERPHARM=$P($G(^PS(55,DFN,"IV",+ON,4)),U,4)
96 . S:+VERPHARM $P(^TMP("PS",$J,"RXN",0),U,5)=VERPHARM
97 . S ND2P5=$G(@(F_+ON_",2.5)")) S IVLIM=$P(ND2P5,U,4) I IVLIM="" S IVLIM=$P(ND2P5,U,2) S:(IVLIM'["d")&(IVLIM'["h") IVLIM=""
98 S DN=$G(@(F_+ON_",.2)")),DO=$P(DN,U,2)
99 S DN=$S(+$P(DN,U):$$OIDF^PSJLMUT1($P(DN,U)),1:"")
100 S ^TMP("PS",$J,0)=DN_U_INFUS_U_STOP_"^^"_START_U_STAT_"^^^"_DO_"^^"_$P(ND0,U,21)_U_U_U_($P(ND0,U,9)="P"&($P(ND0,U,24)="R"))_U_U_$G(RNWDT)
101 ;*S PROVIDER=$P($G(@(F_+ON_",0)")),"^",6)
102 I PROVIDER S ^TMP("PS",$J,"P",0)=PROVIDER_"^"_$P($G(^VA(200,PROVIDER,0)),"^")
103 S ^TMP("PS",$J,"MDR",0)=MR]"" S:MR]"" ^TMP("PS",$J,"MDR",1,0)=MR
104 S ^TMP("PS",$J,"SCH",0)=SCH]"" S:SCH]"" ^TMP("PS",$J,"SCH",1,0)=SCH
105 I ON["P" S:$P(ND0,U,7)]"" ^TMP("PS",$J,"SCH",0)=1,$P(^TMP("PS",$J,"SCH",1,0),U,2)=$$GTSCHT($P(ND0,U,7))_"^"_$P(ND0,U,7)
106 S ^TMP("PS",$J,"SIG",0)=INST]"" S:INST]"" ^TMP("PS",$J,"SIG",1,0)=INST
107 S ^TMP("PS",$J,"ADM",0)=ADM]"" S:ADM]"" ^TMP("PS",$J,"ADM",1,0)=ADM
108 S ^TMP("PS",$J,"SIO",0)=SIO]"" S:SIO]"" ^TMP("PS",$J,"SIO",1,0)=SIO
109 I $G(IVLIM)]"" S ^TMP("PS",$J,"IVLIM",0)=$G(IVLIM)
110 Q
111 ;
112MR(X) ;RETURN MED ROUTE ABBR. IF THE ABBR="" RETURN MED ROUTE'S NAME.
113 S X=$G(^PS(51.2,X,0))
114 Q $S($P(X,U,3)]"":$P(X,U,3),1:$P(X,U))
115 ;
116GTSTAT(X) ;
117 Q $S(X="A":"ACTIVE",X="D":"DISCONTINUED",X="I":"INCOMPLETE",X="N":"NON-VERFIED",X="U":"UNRELEASED",X="P":"PENDING",X="DE":"DISCONTINUED (EDIT)",X="O":"ON CALL",1:"NOT FOUND")
118 ;
119VA200(X) ;Return the IEN for the user.
120 ; X = User name
121 NEW DIC,Y S DIC="^VA(200,",DIC(0)="NZ" D ^DIC
122 I +Y=-1 Q ""
123 Q $P(Y,U)
124GTSCHT(X) ;
125 Q $S(X="C":"CONTINUOUS",X="O":"ONE TIME",X="P":"PRN",X="R":"FILL ON REQUEST",X="OC":"ON CALL",1:"NOT FOUND")
Note: See TracBrowser for help on using the repository browser.