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

BPCSC2.m

Go to the documentation of this file.
BPCSC2 ; IHS/OIT/MJL - SPECIAL X-REF ROUTINES - ; [ 12/06/2007  11:53 AM ]
 ;;1.5;BPC;**1,4**;OCT 04, 2005
 ;
 ; BPCGREF  - Primary Global Reference
 ; BPCSBJGR - Subject Global Reference - Used if all of the entries are to be used under this node -- don't need to check a date
 ; BPCRVCRO - Reverse chronological date subscripted
 ;
SETUP ;
 S BGUCRFS=""
 S BPCVWNO=$P(BGUEND,"`",2),BPCLBONL=$P(BGUEND,"`",3),BPCRVCRO=1
 S BPCVWOPT=$P(BGUEND,"`",4),BGUMAX=$S('BPCVWOPT:BPCVWNO,1:999999999)
 S (BGUBEGIN,BGUEND,BPCXLEVL)="",BPCC=0
 Q
 ;
VISIT ;
 I BPCSBJGR="" S BPCC=BPCC+1,BGUSUB(1)=BPCVIEN,BGUV(BGUFILE,88888)=$$PRIMPROV^APCLV(BPCVIEN,"N") D FIELDS^BGULIST Q
 S BPCSIEN=0 F  S BPCSIEN=$O(@BPCSBJGR@(BPCSIEN)) Q:'BPCSIEN  S BPCC=BPCC+1,BGUSUB(1)=BPCSIEN,BGUV(BGUFILE,88888)=$$PRIMPROV^APCLV(BPCSIEN,"N") D FIELDS^BGULIST
 Q
 ;
VSDTRNG ; Get visits for a patient for a date range
 S BPCGREF=$G(BPCGREF,"^AUPNVSIT(""AA"",BPCPIEN)")
 S BPCPIEN=$P(BGUBEGIN,"`"),BGUBEGIN=$P(BGUBEGIN,"`",2)
 D VSDTDR
 Q
VSDTDR ;
 I '$D(BGUDRIVR) D  Q
 .S BGUDRIVR="VSDTDR^BPCSC2",BPCSDATE=BGUBEGIN,BPCEDATE=$P(BGUEND,"`",1)
 .S BPCSDATE=$P(BGUEND,"`",1),BPCEDATE=$P(BGUEND,"`",2)
 .S BPCVWNO=$P(BGUEND,"`",3),BPCLBONL=$P(BGUEND,"`",4)
 .S BPCVWOPT=$P(BGUEND,"`",5),BGUMAX=$S('BPCVWOPT:BPCVWNO,1:999999)
 .D SETUP
 S BPCVWOPT="2",BPCSBJGR=$G(BPCSBJGR)
 D VSDTDR1,KILL
 Q
VSDTDR1 ;
 S:'(+BPCVWNO) BPCVWNO=10 S:BPCSDATE="" BPCSDATE="1/1/1980"
 S:BPCEDATE="" BPCEDATE="T" S:BPCVWOPT="" BPCVWOPT="0"
 S:BPCLBONL="" BPCLBONL="1"
 D DT^DILF("",BPCSDATE,.BPCSDAT)
 I BPCSDAT=-1 S BPCSDATE="1/1/1980" D DT^DILF("",BPCSDATE,.BPCSDAT)
 D DT^DILF("",BPCEDATE,.BPCEDAT)
 I BPCEDAT=-1 S BPCEDATE="T" D DT^DILF("",BPCEDATE,.BPCEDAT)
 S BPCC=0,BPCX=0,BPCLIM=$S(BPCVWOPT="0":BPCVWNO,1:999999)
 I BPCRVCRO S BPCSDAT=9999999-BPCSDAT,BPCEDAT=9999999-BPCEDAT
 I BPCXLEVL'="" D @BPCXLEVL Q
VSDTDR2 ;
 I BPCRVCRO D  Q
 .S BPCX=$O(@BPCGREF@(BPCEDAT),-1) F  S BPCX=$O(@BPCGREF@(BPCX)) Q:'BPCX  Q:BPCX\1>BPCSDAT  D  Q:BPCC=BPCLIM
 ..S BPCVIEN=0 F  S BPCVIEN=$O(@BPCGREF@(BPCX,BPCVIEN)) Q:'BPCVIEN  Q:BPCC=BPCLIM  D VISIT
 S BPCX=$O(@BPCGREF@(BPCSDAT),-1) F  S BPCX=$O(@BPCGREF@(BPCX)) Q:'BPCX  Q:BPCX\1>BPCEDAT  D  Q:BPCC=BPCLIM
 .S BPCVIEN=0 F  S BPCVIEN=$O(@BPCGREF@(BPCX,BPCVIEN)) Q:'BPCVIEN  Q:BPCC=BPCLIM  D VISIT
 Q
 ;
VED ; Get V PATIENT ED
 ;
 S BPCGREF="^AUPNVPED(""AA"",BPCPIEN)"
 D VSDTRNG
 Q
 ;
VHF ; Get V HEALTH FACTORS
 S BPCGREF="^AUPNVHF(""AA"",BPCPIEN)",BPCXLEVL="VHF1"
 D VSDTRNG
 Q
 ;
VHF1 ; V HEALTH FACTORS XTRA level
 S BPCGREF="^AUPNVHF(""AA"",BPCPIEN,BPCXL)"
 S BPCXL=0 F  S BPCXL=$O(@BPCGREF) Q:'BPCXL  D VSDTDR2
 Q
 ;
VEXAM ; Get V EXAMS
 S BPCGREF="^AUPNVXAM(""AA"",BPCPIEN)",BPCXLEVL="VEXAM1"
 D VSDTRNG
 Q
 ;
VEXAM1 ; V EXAMS XTRA level
 S BPCGREF="^AUPNVXAM(""AA"",BPCPIEN,BPCXL)"
 S BPCXL=0 F  S BPCXL=$O(@BPCGREF) Q:'BPCXL  D VSDTDR2
 Q
 ;
ACTVCN ; Get Active Chart number -- only necessary for BPCDIVALL - Set BPCDUZ2=Loc of first active Chart.
 ;
 S BPCDZ2=0,BPCDUZ2=0 F  S BPCDZ2=$O(^AUPNPAT(BGUSVSB1(1),41,BPCDZ2)) Q:'BPCDZ2  D  Q:'BPCDZ2
 .S BPCX=^AUPNPAT(BGUSVSB1(1),41,BPCDZ2,0) I $P(BPCX,U,5)="" D
 ..I $G(BGUSVSUB(1))="D",BGUBEGIN'=$P(BPCX,U,2) Q
 ..S BPCDUZ2=BPCDZ2,BPCDZ2=0 Q
 S BGUV(BGUFILE,414141)=BPCDUZ2 K BPCDZ2,BPCX
 Q
 ;
ACTVCNG ;
 S BPCDZ2=0,BPCDUZ2=0 F  S BPCDZ2=$O(^AUPNPAT(BGUSUB(1),41,BPCDZ2)) Q:'BPCDZ2  D  Q:'BPCDZ2
 .S BPCX=^AUPNPAT(BGUSUB(1),41,BPCDZ2,0) I $P(BPCX,U,5)="" S BPCDUZ2=BPCDZ2,BPCDZ2=0 Q
 S BGUV(BGUFILE,414141)=BPCDUZ2 K BPCDZ2,BPCX
 Q
 ;
CSV(BPCCD,BPCDATE) ;
 S BPCCSVR=$S(BGUGBL="^ICPT(":"CPT^ICPTCOD",1:"") Q:BPCCSVR=""
 S @("BPCCSV="_"(""$$""_BPCCSVR_""(""_BPCCD_"",""_BPCDATE_"")"")")
 S @("BPCCSV="_BPCCSV),BPCCSV=$P(BPCCSV,U,3)
 S BGUV(BGUFILE,123123)=BPCCSV
 Q
 ;
KILL ;
 K BGUDRIVR,BPCC,BPCEDATE,BPCGREF,BPCGROUP,BPCLBONL,BPCLIM,BPCPIEN,BPCSBJGR,BPCSDATE,BPCSIEN,BPCRVCRO,BPCVIEN,BPCVWNO,BPCVWOPT,BPCX,BPCXL,BPCXLEVL
 Q