source: WorldVistAEHR/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOPST68.m@ 1144

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

initial load of WorldVistAEHR

File size: 2.3 KB
Line 
1PSOPST68 ;BIR/RTR-Find Pending orders with no priority ;06/12/01
2 ;;7.0;OUTPATIENT PHARMACY;**68**;DEC 1997
3 ;External reference to ^PSDRUG supported by DBIA 221
4 ;External reference to ^PS(50.7 supported by DBIA 2223
5 ;External reference ^PS(50.606 supported by DBIA 2174
6 ;
7 N PSOLOGD,PSOPNPAT,PSOPLOC,PSOPNIN,PSOPNPRI,PSOCOUNT,PSOAORL,PSOAORIN,PSOPNAME,PSOPDIN,PSONOW,X
8 K ^TMP("PSOCHECK",$J),^TMP("PSOMAILX",$J)
9 S PSOCOUNT=4,^TMP("PSOMAILX",$J,4)=" "
10 D NOW^%DTC S PSONOW=%
11 ;loop on AD x-ref, to find oldest orders first
12 S PSOLOGD=0 F S PSOLOGD=$O(^PS(52.41,"AD",PSOLOGD)) Q:'PSOLOGD!(PSOLOGD>PSONOW) F PSOPLOC=0:0 S PSOPLOC=$O(^PS(52.41,"AD",PSOLOGD,PSOPLOC)) Q:'PSOPLOC F PSOPNIN=0:0 S PSOPNIN=$O(^PS(52.41,"AD",PSOLOGD,PSOPLOC,PSOPNIN)) Q:'PSOPNIN D
13 .S PSOPNPAT=$P($G(^PS(52.41,PSOPNIN,0)),"^",2) Q:'PSOPNPAT
14 .I $D(^TMP("PSOCHECK",$J,PSOPNPAT)) Q
15 .S ^TMP("PSOCHECK",$J,PSOPNPAT)=""
16 .;loop on AOR x-ref, see if patient has an order without a priority
17 .F PSOAORL=0:0 S PSOAORL=$O(^PS(52.41,"AOR",PSOPNPAT,PSOAORL)) Q:'PSOAORL F PSOAORIN=0:0 S PSOAORIN=$O(^PS(52.41,"AOR",PSOPNPAT,PSOAORL,PSOAORIN)) Q:'PSOAORIN D
18 ..S PSOPNPRI=$P($G(^PS(52.41,PSOAORIN,0)),"^",3)
19 ..I $P($G(^PS(52.41,PSOAORIN,0)),"^",14)'="" Q
20 ..I PSOPNPRI'="NW",PSOPNPRI'="RNW",PSOPNPRI'="RF" Q
21 ..S PSOPDIN=+$P($G(^PS(52.41,PSOAORIN,0)),"^",2)
22 ..I PSOPDIN'=PSOPNPAT Q
23 ..S PSOPNAME=$P($G(^DPT(PSOPDIN,0)),"^")
24 ..;set mail message with pat.name, drug/ord. item
25 ..S X="" I +$P($G(^PS(52.41,PSOPNIN,0)),"^",9) S X=$P($G(^PSDRUG(+$P($G(^PS(52.41,PSOPNIN,0)),"^",9),0)),"^")
26 ..I X]"" S X="; DRUG: "_X I $O(^PS(52.41,PSOPNIN,1,0))
27 ..E S X="; ORD.ITEM: "_$P($G(^PS(50.7,+$P($G(^PS(52.41,PSOPNIN,0)),"^",8),0)),"^")_" "_$P(^PS(50.606,$P(^(0),"^",2),0),"^")
28 ..S PSOCOUNT=PSOCOUNT+1,^TMP("PSOMAILX",$J,PSOCOUNT)="PATIENT NAME: "_$G(PSOPNAME)_X
29END ;
30 ;send mail message
31 S ^TMP("PSOMAILX",$J,1)="A search was done for Pending Outpatient orders",^TMP("PSOMAILX",$J,2)="with no priority assigned. Please review Pending",^TMP("PSOMAILX",$J,3)="orders for the following patients."
32 I PSOCOUNT=4 S ^TMP("PSOMAILX",$J,5)="None were found in the search."
33 K XMY
34 S XMDUZ="PSO*7*68 OUTPATIENT PENDING ORDERS",XMSUB="ORDERS WITHOUT PRIORITY SEARCH"
35 S XMY(DUZ)=""
36 S XMTEXT="^TMP(""PSOMAILX"",$J," N DIFROM D ^XMD K XMSUB,XMTEXT,XMY,XMDUZ
37 K ^TMP("PSOCHECK",$J)
38 K ^TMP("PSOMAILX",$J)
39 Q
Note: See TracBrowser for help on using the repository browser.