source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJADT2.m@ 701

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1PSJADT2 ;BIR/RSB-UNDO AUTO DC MAIL MESSAGE ;25 Aug 98 / 9:44 AM
2 ;;5.0; INPATIENT MEDICATIONS ;**17,27,93**;16 DEC 97
3 ;
4 ; Reference to ^PS(55 is supported by DBIA# 2191
5 ; Reference to ^PSDRUG supported by DBIA# 2192
6 ;
7SENDMSG ;Send mail message when check is complete.
8 N NF,PSJDISP,WS,SM,CNT,CNT1,ON,LINE
9 K PSJ,PSJOC,PSJLINE,XMY S XMDUZ="Inpatient Medications",XMSUB="Medication Orders Automatically Reinstated",XMTEXT="PSJ(",XMY("G.PSJ-ORDERS REINSTATED@"_$G(^XMB("NETNAME")))=""
10 ;Add additional recipients to mail message i.e. verifying Nurse, Pharmacist, etc.
11 I $D(PSJSENTO) D
12 .S PSJLOOP=""
13 .F S PSJLOOP=$O(PSJSENTO($J,PSJLOOP)) Q:PSJLOOP="" D
14 ..S XMY(PSJLOOP)=""
15 S PSJ(1,0)="PATIENT : "_$P(^TMP("PSJUNDC",$J,DFN),"^")_" ("_$E($P(^DPT(DFN,0),"^",9),6,9)_")"
16 I $P(^TMP("PSJUNDC",$J,DFN),"^",2)'="" D
17 .S PSJ(2,0)="CURRENT WARD LOCATION: "_$P(^TMP("PSJUNDC",$J,DFN),"^",2)
18 E D
19 .S PSJ(2,0)="CURRENT WARD LOCATION: NOT FOUND"
20 S PSJ(3,0)="REINSTATEMENT REASON : "_$S($P(^TMP("PSJUNDC",$J,DFN),U,3)=18550:"TRANSFER DELETED",1:"DISCHARGE DELETED")
21 S PSJ(4,0)="THE FOLLOWING MEDICATION ORDERS WERE AUTOMATICALLY REINSTATED."
22 S PSJLINE=0 S ON="" F S ON=$O(^TMP("PSJUNDC",$J,DFN,ON)) Q:ON="" D
23 .S (SM,WS,NF,PSJDISP)=""
24 .I ON["U" D DSPLORDU^PSJLMUT1(DFN,ON) D
25 ..S SM=$S('$P(^PS(55,DFN,5,+ON,0),"^",5):0,$P(^PS(55,DFN,5,+ON,0),"^",6):1,1:2)
26 ..S PSJPWD=$P($G(^DPT(DFN,.1)),U) S PSJPWD=$O(^DIC(42,"B",PSJPWD,0)) S WS=$$WS^PSJO(PSJPWD,DFN,"^PS(55,"_DFN_",5,",ON)
27 ..F PSJDISP=0:0 S PSJDISP=$O(^PS(55,DFN,5,+ON,1,PSJDISP)) Q:'PSJDISP D
28 ...I $P($G(^PSDRUG(+$P($G(^PS(55,DFN,5,+ON,1,PSJDISP,0)),"^"),0)),"^",9)=1 S NF=1
29 ..I NF!WS!SM S PSJOC(ON,PSJLINE-2)=PSJOC(ON,PSJLINE-2)_" "_$S(NF:"NF ",WS:"WS ",SM:$E("HSM",SM,3),1:"")
30 .I ON["V" D DSPLORDV^PSJLMUT1(DFN,ON)
31 S LINE=5,CNT1=0,ON="" F S ON=$O(PSJOC(ON)) Q:ON="" D
32 .;S PSJ(LINE,0)=" ",LINE=LINE+1,CNT=1,CNT1=CNT1+1
33 .S CNT=1,CNT1=CNT1+1
34 .S ON2="" F S ON2=$O(PSJOC(ON,ON2)) Q:ON2="" D
35 ..S PSJ(LINE,0)=$J($S(CNT=1:CNT1,1:" "),3)_$S(CNT=0:" ",1:"")_PSJOC(ON,ON2)
36 ..S LINE=LINE+1,CNT=0
37 I $D(^TMP("PSJNOTUNDC",$J,DFN)) D
38 .S PSJ(LINE,0)=""
39 .S LINE=LINE+1,PSJ(LINE,0)="********* THE FOLLOWING ORDERS WERE NOT AUTOMATICALLY RE-INSTATED *********"
40 .S LINE=LINE+1,PSJ(LINE,0)="******************* DUPLICATE ORDERABLE ITEMS WERE FOUND ******************"
41 .S PSJLINE=0 S ON="" K PSJOC F S ON=$O(^TMP("PSJNOTUNDC",$J,DFN,ON)) Q:ON="" D
42 ..S (SM,WS,NF,PSJDISP)=""
43 ..I ON["U" D DSPLORDU^PSJLMUT1(DFN,ON) D
44 ...S SM=$S('$P(^PS(55,DFN,5,+ON,0),"^",5):0,$P(^PS(55,DFN,5,+ON,0),"^",6):1,1:2)
45 ...S PSJPWD=$P($G(^DPT(DFN,.1)),U) S PSJPWD=$O(^DIC(42,"B",PSJPWD,0)) S WS=$$WS^PSJO(PSJPWD,DFN,"^PS(55,"_DFN_",5,",ON)
46 ...F PSJDISP=0:0 S PSJDISP=$O(^PS(55,DFN,5,+ON,1,PSJDISP)) Q:'PSJDISP D
47 ....I $P($G(^PSDRUG(+$P($G(^PS(55,DFN,5,+ON,1,PSJDISP,0)),"^"),0)),"^",9)=1 S NF=1
48 ...I NF!WS!SM S PSJOC(ON,PSJLINE-2)=PSJOC(ON,PSJLINE-2)_" "_$S(NF:"NF ",WS:"WS ",SM:$E("HSM",SM,3),1:"")
49 ..I ON["V" D DSPLORDV^PSJLMUT1(DFN,ON)
50 .S LINE=LINE+1,CNT1=0,ON="" F S ON=$O(PSJOC(ON)) Q:ON="" D
51 ..S CNT=1,CNT1=CNT1+1
52 ..S ON2="" F S ON2=$O(PSJOC(ON,ON2)) Q:ON2="" D
53 ...S PSJ(LINE,0)=$J($S(CNT=1:CNT1,1:" "),3)_$S(CNT=0:" ",1:"")_PSJOC(ON,ON2)
54 ...S LINE=LINE+1,CNT=0
55 D ^XMD I $D(XMZ) S DA=XMZ,DIE=3.9,DR="1.7///P;" D ^DIE
56 ;
57DONE ;
58 K PSJ,PSJOC,XMDUZ,XMSUB,XMTEXT,PSJLINE,^TMP("PSJUNDC",$J),^TMP("PSJNOTUNDC",$J),PSJENTO($J)
59 Q
Note: See TracBrowser for help on using the repository browser.