source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJMEDS.m@ 1240

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

initial load of WorldVistAEHR

File size: 4.0 KB
Line 
1PSJMEDS ;BIR/MV-FIND PATIENT INFO FOR SPECIFIC WARD ;07 Jul 98 / 4:05 PM
2 ;;5.0; INPATIENT MEDICATIONS ;**34,111**;16 DEC 97
3 ;
4 ; Reference to ^PS(51.2 is supported by DBIA #2178
5 ; Reference to ^PS(55 is supported by DBIA# 2191
6 ;
7WARDGP ;*** Find wards within a ward group
8 S PSGWD="",TM="ZZ" F S PSGWD=$O(^PS(57.5,"AC",PSGWG,PSGWD)) Q:'PSGWD I $D(^DIC(42,+PSGWD,0)) S PSGWN=$P(^(0),U) D WARD
9 Q:PSGWG'="^OTHER"
10 N STDTE
11 S PSGSS="G",PSJACNWP=""
12 S STDTE=0 F S STDTE=$O(^PS(55,"AUDC",STDTE)) Q:'STDTE S CLINIC=0 F S CLINIC=$O(^PS(55,"AUDC",STDTE,CLINIC)) Q:'CLINIC D
13 . S JDFN=0 F S JDFN=$O(^PS(55,"AUDC",STDTE,CLINIC,JDFN)) Q:'JDFN S PSGP=JDFN D ^PSJAC S PPN=PSGP(0) D MEDTYPE
14 S STDTE=0 F S STDTE=$O(^PS(55,"AIVC",STDTE)) Q:'STDTE S CLINIC=0 F S CLINIC=$O(^PS(55,"AIVC",STDTE,CLINIC)) Q:'CLINIC D
15 . S JDFN=0 F S JDFN=$O(^PS(55,"AIVC",STDTE,CLINIC,JDFN)) Q:'JDFN S PSGP=JDFN D ^PSJAC S PPN=PSGP(0) D MEDTYPE
16 Q
17 ;
18WARD ;*** Go through each patient within a given WARD
19 ;*** Var used in PSJAC. Set to null to skip WP^PSJAC
20 ;
21 S PSJACNWP=""
22 F PSGP=0:0 S PSGP=$O(^DPT("CN",PSGWN,PSGP)) Q:'PSGP D ^PSJAC S PPN=PSGP(0) D:PSGSS="W" TEAM D:PSGSS="G" MEDTYPE
23 Q
24 ;
25TEAM ;*** Look up selected team. PSGTMALL= All teams were selected.
26 ;
27 S TM="ZZ"
28 I PSGTMALL D ALLTM,MEDTYPE Q
29 I 'PSGTM D MEDTYPE Q
30 I PSGTM,'PSGTMALL S TM="",RBNO=0 F S TM=$O(PSGTM(TM)) Q:TM="" S TMNO=PSGTM(TM) S:$G(PSJPRB) RBNO=$O(^PS(57.7,"AWRT",PSGWD,PSJPRB,TMNO,0)) D:RBNO MEDTYPE
31 Q
32 ;
33ALLTM ;*** Get UNIT DOSE information from ^PS(55
34 ;
35 S TM=$S(PSJPRB="":0,1:+$O(^PS(57.7,"AWRT",PSGWD,PSJPRB,0))),TM=$S('$G(TM):"ZZ",'$D(^PS(57.7,PSGWD,1,TM,0)):TM,$P(^(0),U)]"":$P(^(0),U),1:TM)
36 Q
37 ;
38MEDTYPE ;
39 S:PSJPRB="" PSJPRB="NOT FOUND"
40 I PSGMTYPE[1 F XTYPE=2:1:6 D LOOP(XTYPE)
41 I PSGMTYPE'[1 F XTYPE=2:1:6 D:PSGMTYPE[XTYPE LOOP(XTYPE)
42 D ^PSJMPEND
43 Q
44 ;
45LOOP(XTYPE) ;*** Loop through stop date cross ref. to find unit dose nodes
46 I XTYPE=2 F PST="C","O","OC","P","R" F PSGEXPDT=PSGPLS-.0001:0 S PSGEXPDT=$O(^PS(55,PSGP,5,"AU",PST,PSGEXPDT)) Q:'PSGEXPDT D
47 . F ON=0:0 S ON=$O(^PS(55,PSGP,5,"AU",PST,PSGEXPDT,ON)) Q:'ON D UDOSE
48 I XTYPE=2 S PST="S" D ^PSJMIV
49 I XTYPE>2 S PST=$S(XTYPE=3:"P",XTYPE=4:"A",XTYPE=5:"H",XTYPE=6:"C") D ^PSJMIV
50 I XTYPE=3 S PST="S" D ^PSJMIV
51 Q
52 ;
53UDOSE ;
54 ;*** Check on status for Hold,Discontinue,Expired,DE(discontinue Edit)
55 S UD0=$G(^PS(55,PSGP,5,ON,0)) Q:"DE"[$P(UD0,U,9)
56 S UD2=$G(^PS(55,PSGP,5,ON,2)) Q:$P(UD2,U,2)>PSGPLF
57 ;
58 ;*** Setup drug info
59 S DRG=$E($$ENPDN^PSGMI(+$G(^PS(55,PSGP,5,ON,.2))),1,20)_U_ON,PSJDOS=$P($G(^PS(55,PSGP,5,ON,.2)),U,2)
60 I $P($G(^PS(51.2,+$P(UD0,U,3),0)),U)]"" S PSJMR=$E($S($P(^(0),U,3)]"":$P(^(0),U,3),1:$P(^(0),U)),1,5)
61 S PSJSCHE=$P(UD2,U),QST=$S(PSJSCHE["PRN":"P",1:PST)
62 S PSGLOD=$P(UD0,U,14),PSGLSD=$P(UD2,U,2),PSGLFD=$P(UD2,U,4)
63 Q:('PSJMPRN&(QST="P"))
64 S PSJSI=$S($P(UD0,U,22):"*** NOT TO BE GIVEN ***",1:$P($G(^PS(55,PSGP,5,ON,6)),U))
65 S PSJHOLD=$S($P(UD0,U,9)["H":1,1:0)
66 D:QST'="P" ADMIN
67 I QST="P" S PSJATME=9999,PSJADT=9999999 D @PSGSS
68 Q
69 ;
70ADMIN ;
71 S PSGPLO=ON,PSGMFOR="" D ^PSJPL0
72 I PSJPLC=1 S PSJATME=8888,PSJADT=8888888 D @PSGSS
73 F ADMIN=0:0 S ADMIN=$O(PSGMAR(ADMIN)) Q:'ADMIN S PSJADT=$P(ADMIN,"."),PSJATME=+$E($P(ADMIN,".",2)_"0000",1,4) D @PSGSS
74 Q
75 ;
76P ;*** Set up ^TMP for sort by patients
77 NEW QST S QST=$S("CO"[PST:PST,PST="OC":"OA",1:"CR")
78 S ^TMP($J,PSJADT,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSJPWDN_U_PSJPRB
79 S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD_U_PSGLSD_U_PSGLFD
80 S ^TMP($J,QST,PSGP,ON,1)=PSJSI
81 Q
82 ;
83G ;*** Goto W to set up ^TMP when print by WARD/WARD GROUP
84 ;
85W ;*** Set up ^TMP when listing by ward
86 S:PSGRBADM="A" ^TMP($J,PSJADT,TM,PSJATME,PSJPRB,PPN,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB
87 S:PSGRBADM="R" ^TMP($J,PSJADT,TM,PSJPRB,PPN,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB
88 S:PSGRBADM="P" ^TMP($J,PSJADT,TM,PPN_U_PSGP,PSJATME,QST,DRG)=PSGP_U_ON_U_PSJPPID_U_PSGWN_U_PSJPRB
89 S ^TMP($J,QST,PSGP,ON)=PSJDOS_U_PSJMR_U_PSJSCHE_U_PSJHOLD_U_PSGLOD_U_PSGLSD_U_PSGLFD
90 S ^TMP($J,QST,PSGP,ON,1)=PSJSI
91 Q
Note: See TracBrowser for help on using the repository browser.