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

APCLDV31.m

Go to the documentation of this file.
APCLDV31 ; IHS/CMI/LAB - list IPV/DV screenings ;
 ;;2.0;IHS PCC SUITE;**8,10**;MAY 14, 2009;Build 88
 ;
 ;
PROC ;
 S APCLCNT=0
 S APCLH=$H,APCLJ=$J
 K ^XTMP("APCLDV3",APCLJ,APCLH)
 D XTMP^APCLOSUT("APCLDV3","IPV SCREENING REPORT")
 ;go through exam IPV, then through AUPNPREF for refusals
 S DFN=0 F  S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN  D
 .Q:'$D(^DPT(DFN,0))
 .Q:$P(^DPT(DFN,0),U,19)  ;merged away
 .Q:$$DEMO^APCLUTL(DFN,$G(APCLDEMO))
 .I APCLCOMT="O",$$COMMRES^AUPNPAT(DFN,"I")'=APCLCOMT("ONE") Q  ;not in community
 .I APCLCOMT="S" S X=$$COMMRES^AUPNPAT(DFN,"E") I '$D(APCLTAX(X)) Q  ;not in comm taxonomy
 .I APCLSEX'[$P(^DPT(DFN,0),U,2) Q  ;not right gender
 .I APCLDESP]"",$P(^AUPNPAT(DFN,0),U,14)'=APCLDESP Q  ;not correct designated provider
 .D GATHER
 .Q
 D GETSCR
 Q
GATHER ;gather up all exams, refusals and bh in time period for patient in DFN
 ;if at least one match criteria then set ^xtmp($j,$h,"pts",dfn)=""
 S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVXAM("AC",DFN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 .Q:'$D(^AUPNVXAM(APCLEIEN,0))
 .Q:$P(^AUPNVXAM(APCLEIEN,0),U)'=APCLEXC  ;not ipv/dv
 .S APCLVIEN=$P(^AUPNVXAM(APCLEIEN,0),U,3)
 .Q:'APCLVIEN
 .S APCLDATE=$P($P($G(^AUPNVSIT(APCLVIEN,0)),U),".")
 .Q:APCLDATE=""
 .Q:APCLDATE>APCLED
 .Q:APCLDATE<APCLBD
 .I APCLLOCT="O",$P(^AUPNVSIT(APCLVIEN,0),U,6)'=APCLLOCT("ONE") Q
 .I APCLLOCT="S",$$VALI^XBDIQ1(9999999.06,$P(^AUPNVSIT(APCLVIEN,0),U,6),.05)'=APCLLOCT("SU") Q
 .S X=$$AGE^AUPNPAT(DFN,APCLDATE)
 .I $D(APCLAGET),X>$P(APCLAGET,"-",2) Q
 .I $D(APCLAGET),X<$P(APCLAGET,"-",1) Q
 .;clinic check
 .I $D(APCLCLNT) S X=$P(^AUPNVSIT(APCLVIEN,0),U,8) Q:X=""  Q:'$D(APCLCLNT(X))
 .;bh exclude/include check
 .I 'APCLEXBH S C=$$CLINIC^APCLV(APCLVIEN,"C") I C=14!(C=43)!(C=48)!(C="C4")!(C="C9") Q
 .;result check
 .S APCLRES=$$VAL^XBDIQ1(9000010.13,APCLEIEN,.04) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 .I APCLRES="NEGATIVE",'$D(APCLREST(1)) Q
 .I APCLRES="PRESENT",'$D(APCLREST(2)) Q
 .I APCLRES="PAST",'$D(APCLREST(3)) Q
 .I APCLRES="",'$D(APCLREST(6)) Q
 .;PRIMARY PROVIDER CHECK
 .S X=$$PRIMPROV^APCLV(APCLVIEN,"I")
 .I $D(APCLPROV),X="" Q  ;want only certain primary providers on visit
 .I $D(APCLPROV),APCLPROV'=X Q  ;want one provider and it's not this one
 .I APCLPPUN,X'="" Q  ;want only unknown and this one has a primary provider
 .S X=$P($G(^AUPNVXAM(APCLEIEN,12)),U,4)
 .I $D(APCLSPRV),X="" Q  ;want only certain SCR providers on visit
 .I $D(APCLSPRV),APCLSPRV'=X Q  ;want one provider and it's not this one
 .I APCLSPUN,X'="" Q  ;want only unknown and this one has a SCR provider
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN)=""
REF ;now go through refusals in pcc
 ;Q:$D(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN))  ;already got one so no need to go on
 S APCLRIEN=0 F  S APCLRIEN=$O(^AUPNPREF("AC",DFN,APCLRIEN)) Q:APCLRIEN'=+APCLRIEN  D
 .Q:'$D(^AUPNPREF(APCLRIEN,0))
 .Q:$P(^AUPNPREF(APCLRIEN,0),U,5)'=9999999.15
 .Q:$P(^AUPNPREF(APCLRIEN,0),U,6)'=APCLEXC
 .S APCLDATE=$P(^AUPNPREF(APCLRIEN,0),U,3)
 .Q:APCLDATE=""
 .Q:APCLDATE>APCLED
 .Q:APCLDATE<APCLBD
 .S X=$$AGE^AUPNPAT(DFN,APCLDATE)
 .I $D(APCLAGET),X>$P(APCLAGET,"-",2) Q
 .I $D(APCLAGET),X<$P(APCLAGET,"-",1) Q
 .S APCLRES=$$VAL^XBDIQ1(9000022,APCLRIEN,.07) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING"
 .I APCLRES["REFUSED",'$D(APCLREST(4)) Q  ;do not want refusals
 .I APCLRES["UNABLE",'$D(APCLREST(5)) Q  ;do not want unables
 .S X=$P($G(^AUPNPREF(APCLRIEN,12)),U,4)
 .I $D(APCLSPRV),X="" Q  ;want only certain SCR providers on visit
 .I $D(APCLSPRV),APCLSPRV'=X Q  ;want one provider and it's not this one
 .I APCLSPUN,X'="" Q  ;want only unknown and this one has a SCR provider
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN)=""
 ;Q:$D(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN))   ;already got this patient so no need to go on
BH ;now go through BH
 Q:'APCLEXBH  ;not if user doesn't want to
 S APCLSD=$$FMADD^XLFDT(APCLBD,-1),APCLSD=APCLSD_".9999"
 F  S APCLSD=$O(^AMHREC("AF",DFN,APCLSD)) Q:APCLSD'=+APCLSD!($P(APCLSD,".")>APCLED)  D
 .S APCLBIEN=0 F  S APCLBIEN=$O(^AMHREC("AF",DFN,APCLSD,APCLBIEN)) Q:APCLBIEN'=+APCLBIEN  D
 ..S APCLDATE=$P(APCLSD,".")
 ..Q:'$D(^AMHREC(APCLBIEN,0))
 ..Q:$P($G(^AMHREC(APCLBIEN,14)),U)=""
 ..Q:APCLDATE>APCLED
 ..Q:APCLDATE<APCLBD
 ..I APCLLOCT="O",$P(^AMHREC(APCLBIEN,0),U,4)'=APCLLOCT("ONE") Q
 ..I APCLLOCT="S",$$VALI^XBDIQ1(9999999.06,$P(^AMHREC(APCLBIEN,0),U,4),.05)'=APCLLOCT("SU") Q
 ..S X=$$AGE^AUPNPAT(DFN,APCLDATE)
 ..I $D(APCLAGET),X>$P(APCLAGET,"-",2) Q
 ..I $D(APCLAGET),X<$P(APCLAGET,"-",1) Q
 ..;clinic check
 ..I $D(APCLCLNT) S X=$P(^AMHREC(APCLBIEN,0),U,25) Q:X=""  Q:'$D(APCLCLNT(X))
 ..;result check
 ..S APCLRES=$$VAL^XBDIQ1(9002011,APCLBIEN,1401) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 ..I APCLRES="NEGATIVE",'$D(APCLREST(1)) Q
 ..I APCLRES="PRESENT",'$D(APCLREST(2)) Q
 ..I APCLRES="PAST",'$D(APCLREST(3)) Q
 ..I APCLRES["REFUSED",'$D(APCLREST(4)) Q  ;do not want refusals
 ..I APCLRES["UNABLE",'$D(APCLREST(5)) Q  ;do not want unables
 ..I APCLRES="",'$D(APCLREST(6)) Q
 ..;PRIMARY PROVIDER CHECK
 ..S X=$$BHPPIN(APCLBIEN)
 ..I $D(APCLPROV),X="" Q  ;want only certain primary providers on visit
 ..I $D(APCLPROV),APCLPROV'=X Q  ;want one provider and it's not this one
 ..I APCLPPUN,X'="" Q  ;want only unknown and this one has a primary provider
 ..S X=$P($G(^AMHREC(APCLBIEN,14)),U,2)
 ..I $D(APCLSPRV),X="" Q  ;want only certain SCR providers on visit
 ..I $D(APCLSPRV),APCLSPRV'=X Q  ;want one provider and it's not this one
 ..I APCLSPUN,X'="" Q  ;want only unknown and this one has a SCR provider
 ..S ^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN)=""
 Q
 ;
GETSCR ;
 K ^XTMP("APCLDV3",APCLJ,APCLH,"VSTS")
 S DFN=0 F  S DFN=$O(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN)) Q:DFN'=+DFN  D GETSCR1
 Q
GETSCR1 ;
 ;go through exam IPV, then through AUPNPREF for refusals
 S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVXAM("AC",DFN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 .Q:'$D(^AUPNVXAM(APCLEIEN,0))
 .Q:$P(^AUPNVXAM(APCLEIEN,0),U)'=APCLEXC
 .S APCLVIEN=$P(^AUPNVXAM(APCLEIEN,0),U,3)
 .Q:'APCLVIEN
 .S APCLDATE=$P($P($G(^AUPNVSIT(APCLVIEN,0)),U),".")
 .Q:APCLDATE=""
 .Q:APCLDATE>APCLED
 .Q:APCLDATE<APCLBD
 .I 'APCLEXBH S C=$$CLINIC^APCLV(APCLVIEN,"C") I C=14!(C=43)!(C=48)!(C="C4")!(C="C9") Q
 .S APCLCNT=APCLCNT+1
 .S APCLRES=$$VAL^XBDIQ1(9000010.13,APCLEIEN,.04) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_$$VAL^XBDIQ1(9000010.13,APCLEIEN,81101)_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN_U_DFN
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,10)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,15)=APCLVIEN
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,16)=$$SPRV(APCLEIEN)
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN,APCLDATE)=APCLCNT
 ;now go through refusals in pcc
 S APCLRIEN=0 F  S APCLRIEN=$O(^AUPNPREF("AC",DFN,APCLRIEN)) Q:APCLRIEN'=+APCLRIEN  D
 .Q:'$D(^AUPNPREF(APCLRIEN,0))
 .Q:$P(^AUPNPREF(APCLRIEN,0),U,5)'=9999999.15
 .Q:$P(^AUPNPREF(APCLRIEN,0),U,6)'=APCLEXC
 .S APCLDATE=$P(^AUPNPREF(APCLRIEN,0),U,3)
 .Q:APCLDATE=""
 .Q:APCLDATE>APCLED
 .Q:APCLDATE<APCLBD
 .S APCLRES=$$VAL^XBDIQ1(9000022,APCLRIEN,.07) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 .S APCLCNT=APCLCNT+1
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT)="REF"_U_"UNKNOWN"_U_APCLRES_U_$$VAL^XBDIQ1(9000022,APCLRIEN,1101)_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLRIEN_U_DFN_U
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,16)=$$PRVREF(APCLRIEN)
 .S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 .S ^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN,APCLDATE)=APCLCNT
 ;now go through BH
 Q:'APCLEXBH  ;not if user doesn't want to
 S APCLSD=$$FMADD^XLFDT(APCLBD,-1),APCLSD=APCLSD_".9999"
 F  S APCLSD=$O(^AMHREC("AF",DFN,APCLSD)) Q:APCLSD'=+APCLSD!($P(APCLSD,".")>APCLED)  D
 .S APCLBIEN=0 F  S APCLBIEN=$O(^AMHREC("AF",DFN,APCLSD,APCLBIEN)) Q:APCLBIEN'=+APCLBIEN  D
 ..S APCLDATE=$P(APCLSD,".")
 ..Q:'$D(^AMHREC(APCLBIEN,0))
 ..Q:$P($G(^AMHREC(APCLBIEN,14)),U)=""
 ..Q:APCLDATE>APCLED
 ..Q:APCLDATE<APCLBD
 ..I $D(^XTMP("APCLDV3",APCLJ,APCLH,"PTS",DFN,APCLDATE)) Q
 ..S APCLCNT=APCLCNT+1
 ..S APCLRES=$$VAL^XBDIQ1(9002011,APCLBIEN,1401) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 ..S ^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT)="BH"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_$$VAL^XBDIQ1(9002011,APCLBIEN,1501)_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLBIEN_U_DFN
 ..S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,10)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,16)=$$VAL^XBDIQ1(9002011,APCLBIEN,1402)
 ..S $P(^XTMP("APCLDV3",APCLJ,APCLH,"VSTS",APCLCNT),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 Q
BHPPIN(R) ;
 NEW %,%1
 S %=0,%1="" F  S %=$O(^AMHRPROV("AD",R,%)) Q:%'=+%  I $P(^AMHRPROV(%,0),U,4)="P" S %1=$P(^AMHRPROV(%,0),U)
 Q %1
BHPPNAME(R) ;EP primary provider internal # from 200
 NEW %,%1
 S %=0,%1="" F  S %=$O(^AMHRPROV("AD",R,%)) Q:%'=+%  I $P(^AMHRPROV(%,0),U,4)="P" S %1=$P(^AMHRPROV(%,0),U),%1=$P($G(^VA(200,%1,0)),U)
 I %1]"" Q %1
 Q "UNKNOWN"
SPRV(E) ;
 ;get 1204 if it exists, otherwise take 1202
 I $P($G(^AUPNVXAM(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.13,E,1204)
 I $P($G(^AUPNVXAM(E,12)),U,2) Q $$VAL^XBDIQ1(9000010.13,E,1202)
 Q "UNKNOWN"
PRVREF(R) ;
 I $P($G(^AUPNPREF(R,12)),U,4)]"" Q $$VAL^XBDIQ1(9000022,R,1204)
 Q "UNKNOWN"
PPV(V) ;
 NEW %
 S %=$$PRIMPROV^APCLV(V,"N")
 I %]"" Q %
 Q "UNKNOWN"
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
EOP ;EP - End of page.
 Q:$E(IOST)'="C"
 Q:IO'=IO(0)
 Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
 NEW DIR
 K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
 W !
 S DIR("A")="End of Report.  Press Enter",DIR(0)="E" D ^DIR
 Q
 ;----------
USR() ;EP - Return name of current user from ^VA(200.
 Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
 Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
 ;----------