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

AMHSC2.m

Go to the documentation of this file.
AMHSC2 ; IHS/CMI/LAB - SPECIAL X-REF ROUTINES - ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ; AMHGREF  - Primary Global Reference
 ; AMHSBJGR - Subject Global Reference - Used if all of the entries are to be used under this node -- don't need to check a date
 ; AMHRVCRO - Reverse chronological date subscripted
 ;
SETUP ;
 S BGUCRFS=""
 S AMHVWNO=$P(BGUEND,"`",2),AMHLBONL=$P(BGUEND,"`",3),AMHRVCRO=1
 S AMHVWOPT=$P(BGUEND,"`",4),BGUMAX=$S('AMHVWOPT:AMHVWNO,1:999999999)
 S (BGUBEGIN,BGUEND,AMHXLEVL)="",AMHC=0
 Q
 ;
VISIT ;
 I AMHSBJGR="" S AMHC=AMHC+1,BGUSUB(1)=AMHVIEN,BGUV(BGUFILE,88888)=$$PRIMPROV^APCLV(AMHVIEN,"N") D FIELDS^BGULIST Q
 S AMHSIEN=0 F  S AMHSIEN=$O(@AMHSBJGR@(AMHSIEN)) Q:'AMHSIEN  S AMHC=AMHC+1,BGUSUB(1)=AMHSIEN,BGUV(BGUFILE,88888)=$$PRIMPROV^APCLV(AMHSIEN,"N") D FIELDS^BGULIST
 Q
 ;
VSDTRNG ; Get visits for a patient for a date range
 S AMHGREF=$G(AMHGREF,"^AUPNVSIT(""AA"",AMHPIEN)")
 S AMHPIEN=$P(BGUBEGIN,"`"),BGUBEGIN=$P(BGUBEGIN,"`",2)
 D VSDTDR
 Q
VSDTDR ;
 I '$D(BGUDRIVR) D  Q
 .S BGUDRIVR="VSDTDR^AMHSC2",AMHSDATE=BGUBEGIN,AMHEDATE=$P(BGUEND,"`",1)
 .S AMHSDATE=$P(BGUEND,"`",1),AMHEDATE=$P(BGUEND,"`",2)
 .S AMHVWNO=$P(BGUEND,"`",3),AMHLBONL=$P(BGUEND,"`",4)
 .S AMHVWOPT=$P(BGUEND,"`",5),BGUMAX=$S('AMHVWOPT:AMHVWNO,1:999999)
 .D SETUP
 S AMHVWOPT="2",AMHSBJGR=$G(AMHSBJGR)
 D VSDTDR1,KILL
 Q
VSDTDR1 ;
 S:'(+AMHVWNO) AMHVWNO=10 S:AMHSDATE="" AMHSDATE="1/1/1980"
 S:AMHEDATE="" AMHEDATE="T" S:AMHVWOPT="" AMHVWOPT="0"
 S:AMHLBONL="" AMHLBONL="1"
 D DT^DILF("",AMHSDATE,.AMHSDAT)
 I AMHSDAT=-1 S AMHSDATE="1/1/1980" D DT^DILF("",AMHSDATE,.AMHSDAT)
 D DT^DILF("",AMHEDATE,.AMHEDAT)
 I AMHEDAT=-1 S AMHEDATE="T" D DT^DILF("",AMHEDATE,.AMHEDAT)
 S AMHC=0,AMHX=0,AMHLIM=$S(AMHVWOPT="0":AMHVWNO,1:999999)
 I AMHRVCRO S AMHSDAT=9999999-AMHSDAT,AMHEDAT=9999999-AMHEDAT
 I AMHXLEVL'="" D @AMHXLEVL Q
VSDTDR2 ;
 I AMHRVCRO D  Q
 .S AMHX=$O(@AMHGREF@(AMHEDAT),-1) F  S AMHX=$O(@AMHGREF@(AMHX)) Q:'AMHX  Q:AMHX\1>AMHSDAT  D  Q:AMHC=AMHLIM
 ..S AMHVIEN=0 F  S AMHVIEN=$O(@AMHGREF@(AMHX,AMHVIEN)) Q:'AMHVIEN  Q:AMHC=AMHLIM  D VISIT
 S AMHX=$O(@AMHGREF@(AMHSDAT),-1) F  S AMHX=$O(@AMHGREF@(AMHX)) Q:'AMHX  Q:AMHX\1>AMHEDAT  D  Q:AMHC=AMHLIM
 .S AMHVIEN=0 F  S AMHVIEN=$O(@AMHGREF@(AMHX,AMHVIEN)) Q:'AMHVIEN  Q:AMHC=AMHLIM  D VISIT
 Q
 ;
VED ; Get V PATIENT ED
 ;
 S AMHGREF="^AUPNVPED(""AA"",AMHPIEN)"
 D VSDTRNG
 Q
 ;
VHF ; Get V HEALTH FACTORS
 S AMHGREF="^AUPNVHF(""AA"",AMHPIEN)",AMHXLEVL="VHF1"
 D VSDTRNG
 Q
 ;
VHF1 ; V HEALTH FACTORS XTRA level
 S AMHGREF="^AUPNVHF(""AA"",AMHPIEN,AMHXL)"
 S AMHXL=0 F  S AMHXL=$O(@AMHGREF) Q:'AMHXL  D VSDTDR2
 Q
 ;
VEXAM ; Get V EXAMS
 S AMHGREF="^AUPNVXAM(""AA"",AMHPIEN)",AMHXLEVL="VEXAM1"
 D VSDTRNG
 Q
 ;
VEXAM1 ; V EXAMS XTRA level
 S AMHGREF="^AUPNVXAM(""AA"",AMHPIEN,AMHXL)"
 S AMHXL=0 F  S AMHXL=$O(@AMHGREF) Q:'AMHXL  D VSDTDR2
 Q
 ;
KILL ;
 K BGUDRIVR,AMHC,AMHEDATE,AMHGREF,AMHGROUP,AMHLBONL,AMHLIM,AMHPIEN,AMHSBJGR,AMHSDATE,AMHSIEN,AMHRVCRO,AMHVIEN,AMHVWNO,AMHVWOPT,AMHX,AMHXL,AMHXLEVL
 Q