Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BWBRNOT

BWBRNOT.m

Go to the documentation of this file.
BWBRNOT ;IHS/ANMC/MWR - BROWSE NOTIFICATIONS;03-Sep-2003 20:59;PLS
 ;;2.0;WOMEN'S HEALTH;**8,9**;MAY 16, 1996
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  CALLED BY OPTION: "BW BROWSE NOTIFICATIONS" TO BROWSE AND EDIT
 ;;  NOTIFICATIONS.
 ;
 ;---> VARIABLES:
 ;---> BWA:   1=ALL PATIENTS, 0=ONE PATIENT
 ;---> BWDFN: DFN OF SELECTED PATIENT
 ;---> DATES: BWBEGDT=BEGINNING DATE, BWENDDT=ENDING DATE
 ;---> BWB:   d=DELINQUENT, o=OPEN, q=queued,
 ;--->        e=ERROR, a=ALL (includes CLOSED).
 ;---> SORT SEQUENCE IN BWC:  1=DATE, PATIENT, PRIORITY
 ;--->                        2=PATIENT, DATE, PRIORITY
 ;--->                        3=PRIORITY, DATE, PATIENT
 ;---> USE NODES 3 & 4 IN ^TMP GLOBAL.
 ;
 D SETVARS^BWUTL5
 D ^BWBRNOT2 G:BWPOP EXIT
 D SORT
 D COPYGBL
 D ^BWBRNOT1
 ;
EXIT ;EP
 D KILLALL^BWUTL8
 Q
 ;
 ;
SORT ;EP
 ;---> SORT AND STORE ARRAY IN ^TMP("BW",$J
 K ^TMP("BW",$J)
 ;---> BWBEGDT1=ONE SECOND BEFORE BEGIN DATE.
 ;---> BWENDDT1=THE LAST SECOND OF END DATE.
 S BWBEGDT1=BWBEGDT-.0001,BWENDDT1=BWENDDT+.9999
 ;
 ;**************************
 ;---> BWA=1: ALL PATIENTS
 I BWA D  Q
 .;---> BY DATE GET EITHER ALL OR OPEN ONLY.
 .N BWDFN,BWIEN,Y
 .S BWXREF=$S("ae"[BWB:"D",BWB="q":"APRT",1:"AOPEN")
 .S BWDATE=BWBEGDT1
 .F  S BWDATE=$O(^BWNOT(BWXREF,BWDATE)) Q:'BWDATE!(BWDATE>BWENDDT1)  D
 ..S BWIEN=0
 ..F  S BWIEN=$O(^BWNOT(BWXREF,BWDATE,BWIEN)) Q:'BWIEN  D
 ...Q:'$D(^BWNOT(BWIEN,0))
 ...S Y=^BWNOT(BWIEN,0),BWDFN=$P(Y,U)
 ...;---> QUIT IF SELECTING FOR ONE CASE MANAGER AND THIS DOESN'T MATCH.
 ...I 'BWE Q:$P(^BWP(BWDFN,0),U,10)'=BWCMGR
 ...;---> QUIT IF LISTING "DELINQUENT" AND THIS PROCDURE IS NOT DELINQ.
 ...I BWB="d" Q:$P(Y,U,13)'<DT!($P(Y,U,13)="")
 ...I BWB="e" Q:$P(Y,U,14)'="e"
 ...D STORE
 ;
 ;**************************
 ;---> BWA=0: ONE PATIENT
 N BWIEN,Y S BWIEN=0
 F  S BWIEN=$O(^BWNOT("B",BWDFN,BWIEN)) Q:'BWIEN  D
 .S Y=^BWNOT(BWIEN,0)
 .;---> QUIT IF NOT WITHIN DATE RANGE.
 .S BWDATE=$P(Y,U,2)
 .Q:BWDATE'>BWBEGDT1!(BWDATE>BWENDDT1)
 .;---> QUIT IF "QUEUED" AND THIS NOTIFICATION IS NOT QUEUED.
 .I BWB="q" Q:'$P(Y,U,11)  Q:'$D(^BWNOT("APRT",$P(Y,U,11),BWIEN))
 .;---> QUIT IF "DELINQUENT" OR OPEN ONLY AND THIS ENTRY IS CLOSED.
 .Q:"do"[BWB&($P(Y,U,14)="c")
 .I BWB="d" Q:$P(Y,U,13)'<DT!($P(Y,U,13)="")
 .I BWB="e" Q:$P(Y,U,14)'="e"
 .D STORE
 Q
 ;
STORE ;EP
 ;--->BWDATE IS ALREADY SET FROM LL SORT ABOVE.      ;---> DATE
 S BWCHRT=$$HRCN^BWUTL1(BWDFN)                       ;---> CHART#
 S BWNAME=$$NAME^BWUTL1(BWDFN)                       ;---> NAME
 S BWACC=$P(Y,U,6)                                   ;---> ACCESSION#
 I BWACC]"" S BWACC=$P(^BWPCD(BWACC,0),U)
 S BWSTAT=$$STATUS^BWUTL4                            ;---> STATUS
 S BWPRIO=9
 S:$P(Y,U,4)]"" BWPRIO=$P(^BWNOTP($P(Y,U,4),0),U,2)  ;---> PRIORITY
 ;
 S X=BWCHRT_U_BWNAME_U_BWDATE_U_BWACC_U_BWSTAT_U_BWPRIO_U_BWIEN
 I BWC=1 S ^TMP("BW",$J,3,BWDATE,BWNAME,BWPRIO,BWIEN)=X Q
 I BWC=2 S ^TMP("BW",$J,3,BWNAME,BWDATE,BWPRIO,BWIEN)=X Q
 I BWC=3 S ^TMP("BW",$J,3,BWPRIO,BWDATE,BWNAME,BWIEN)=X
 Q
 ;
COPYGBL ;EP
 ;---> COPY ^TMP("BW",$J,3 TO ^TMP("BW",$J,4 TO MAKE IT FLAT.
 N I,M,N,P,Q
 S N=0,I=0
 F  S N=$O(^TMP("BW",$J,3,N)) Q:N=""  D
 .S M=0
 .F  S M=$O(^TMP("BW",$J,3,N,M)) Q:M=""  D
 ..S P=0
 ..F  S P=$O(^TMP("BW",$J,3,N,M,P)) Q:P=""  D
 ...S Q=0
 ...F  S Q=$O(^TMP("BW",$J,3,N,M,P,Q)) Q:Q=""  D
 ....S I=I+1,^TMP("BW",$J,4,I)=^TMP("BW",$J,3,N,M,P,Q)
 Q
 ;
 ;
DEQUEUE ;EP
 ;---> TASKMAN QUEUE OF PRINTOUT.
 D SETVARS^BWUTL5,SORT,COPYGBL,^BWBRNOT1,EXIT
 Q
 ;
FOLLOW(BWDFN) ;EP
 ;---> CALLED FROM PROCEDURE FOLLOWUP MENU.
 N (BWDFN,DT,DTIME,DUZ,M,N,U,X,Z) D SETVARS^BWUTL5
 S BWA=0,BWB="o",BWBEGDT=(DT-50000),BWC=1,BWE=1,BWENDDT=DT
 D DEVICE^BWBRNOT2 Q:BWPOP
 S BWLOOP=1
 D SORT,COPYGBL,^BWBRNOT1
 Q