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

AMHRL1.m

Go to the documentation of this file.
AMHRL1 ; IHS/CMI/LAB - TUCSON-OHPRD/LAB - PROCESS BH RECORD LIST ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1**;JUN 18, 2010;Build 8
 ;
 ;
 ;
START ;
 S (AMHBT,AMHBTH)=$H,AMHJOB=$J,AMHRCNT=0
 D XTMP^AMHUTIL("AMHRL","BH - GENERAL RETRIEVAL")
 S AMHPROC=AMHPTVS_AMHTYPE
 I $D(AMHRDTR),AMHPTVS="P"!(AMHPTVS="S") S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 D @AMHPROC,END
 Q
 ;
SSU ;suicide
 S AMHR=0 F  S AMHR=$O(^AMHPSUIC(AMHR)) Q:AMHR'=+AMHR  D
 .S AMHR0=^AMHPSUIC(AMHR,0),DFN=$P(AMHR0,U,4)
 .Q:$P(^AMHPSUIC(AMHR,0),U,6)=""
 .Q:$P(^AMHPSUIC(AMHR,0),U,6)<AMHBD
 .Q:$P(^AMHPSUIC(AMHR,0),U,6)>AMHED
 .D PROC
 Q
VS ;run by search template
 S AMHR=0 F  S AMHR=$O(^DIBT(AMHSEAT,1,AMHR)) Q:AMHR'=+AMHR  I $D(^AMHREC(AMHR,0)) S AMHR0=^AMHREC(AMHR,0),DFN=$P(AMHR0,U,8) D PROC
 Q
VD ; Run by visit date
 S X1=AMHBD,X2=-1 D C^%DTC S AMHSD=X
 S AMHODAT=AMHSD_".9999" F  S AMHODAT=$O(^AMHREC("B",AMHODAT)) Q:AMHODAT=""!((AMHODAT\1)>AMHED)  D V1
 Q
 ;
PP ;
 S AMHR=0 F  S AMHR=$O(^DPT(AMHR)) Q:AMHR'=+AMHR  I '$P(^DPT(AMHR,0),U,19) S DFN=AMHR D PROC
 Q
 ;
PS ;
 S AMHR=0 F  S AMHR=$O(^DIBT(AMHSEAT,1,AMHR)) Q:AMHR'=+AMHR  I $D(^DPT(AMHR,0)),'$P(^(0),U,19) S DFN=AMHR D PROC
 Q
 ;
 ;
END ;
 S AMHET=$H
 Q
V1 ;
 S AMHR="" F  S AMHR=$O(^AMHREC("B",AMHODAT,AMHR)) Q:AMHR'=+AMHR  I $D(^AMHREC(AMHR,0)),$P(^(0),U,2)]"",$P(^(0),U,3)]"",$P(^(0),U,4)]"" S AMHR0=^AMHREC(AMHR,0),DFN=$P(AMHR0,U,8) D PROC
 Q
PROC ;
 ;I AMHPTVS="V" S AMHR0=^AMHREC(AMHR,0),DFN=$P(AMHR0,U,8)
 ;I AMHPTVS="P" S DFN=AMHR
 I AMHPTVS="P",DFN="" Q
 Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
 I AMHPTVS="P",'$$ALLOWP^AMHUTIL(DUZ,DFN) Q
 I AMHPTVS="V",'$$ALLOWVI^AMHUTIL(DUZ,AMHR) Q
 D SCREENS
 Q:$D(AMHSKIP)
 K AMHSRT,AMHPRNT S AMHCRIT=AMHSORT,AMHX=0 X:$D(^AMHSORT(AMHSORT,5)) ^AMHSORT(AMHSORT,5) I '$D(AMHPRNT) D
 . I AMHPTVS="S" S AMHPRNT="--"
 . I AMHPTVS="V" S Y=$P($P(AMHR0,U),".") D DD^%DT S AMHPRNT=Y Q
 . S AMHPRNT=$P(^DPT(DFN,0),U)
 . Q
 S AMHSRT=AMHPRNT
 D SUBPAT
 I AMHPTVS="S" S ^XTMP("AMHRL",AMHJOB,AMHBTH,"DATA HITS",AMHSRT,AMHR)="",AMHRCNT=AMHRCNT+1 G P1
 I '$D(AMHRDTR) S ^XTMP("AMHRL",AMHJOB,AMHBTH,"DATA HITS",AMHSRT,AMHR)="",AMHRCNT=AMHRCNT+1
 I $D(AMHRDTR) S ^XTMP("AMHRL",AMHJOB,AMHBTH,"DATA HITS",AMHSRT,DFN)="",AMHRCNT=AMHRCNT+1
P1 Q:'$G(DFN)
 Q:$D(^XTMP("AMHRL",AMHJOB,AMHBTH,"PATIENTS",DFN))
 S ^XTMP("AMHRL",AMHJOB,AMHBTH,"PATIENTS",DFN)="",AMHPTCT=AMHPTCT+1
 Q
SUBPAT ;tally # of patients by sort value on detailed/subtotal
 Q:'$G(DFN)
 Q:AMHCTYP="C"
 Q:AMHCTYP="F"
 Q:AMHCTYP="T"
 S:$G(AMHSRT)="" AMHSRT="???"
 Q:$D(^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PATIENT HIT",AMHSRT,DFN))
 S:'$D(^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PAT COUNT",AMHSRT)) ^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PAT COUNT",AMHSRT)=0
 S ^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PAT COUNT",AMHSRT)=^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PAT COUNT",AMHSRT)+1
 Q:$D(^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PATIENT HIT",AMHSRT,DFN))
 S ^XTMP("AMHRL",AMHJOB,AMHBTH,"SUB PATIENT HIT",AMHSRT,DFN)=""
 Q
SCREENS ;
 K AMHSKIP
 S AMHI=0 F  S AMHI=$O(^AMHTRPT(AMHRPT,11,AMHI)) Q:AMHI'=+AMHI!($D(AMHSKIP))  D
 .I '$P(^AMHSORT(AMHI,0),U,8) D SINGLE Q
 .D MULT
 .Q
 Q
SINGLE ;
 K X,AMHSPEC S X="",AMHX=0
 X:$D(^AMHSORT(AMHI,1)) ^(1)
 I X="" S AMHSKIP="" Q
 I '$D(AMHSPEC),'$D(^AMHTRPT(AMHRPT,11,AMHI,11,"B",X)) S AMHSKIP="" Q
 Q
MULT ;
 K AMHFOUN,AMHSKIP,AMHSPEC,X S AMHX=0,X=""
 X:$D(^AMHSORT(AMHI,1)) ^(1)
 I $O(X(""))="" S AMHSKIP="" Q
 I '$D(AMHSPEC) S Y="" F  S Y=$O(X(Y)) Q:Y=""  I $D(^AMHTRPT(AMHRP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