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

APCLAL1A.m

Go to the documentation of this file.
APCLAL1A ; IHS/CMI/LAB - list refusals ;
 ;;2.0;IHS PCC SUITE;**2,4,11**;MAY 14, 2009;Build 58
 ;
PROC ;EP
 S APCLCNT=0
 S APCLH=$H,APCLJ=$J
 K ^XTMP("APCLAL1",APCLJ,APCLH)
 D XTMP^APCLOSUT("APCLAL1","ALCOHOL SCREENING REPORT")
 ;go through exam ALCOHOL, then through AUPNPREF for refusals
 S DFN=0 F  S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN  D
 .I '$G(APCLRPT4) Q:$$DEMO^APCLUTL(DFN,$G(APCLDEMO))
 .I $G(APCLRPT4) Q:'$D(^DIBT(APCLSEAT,1,DFN))
 .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
 .D PROC1
 .Q
 Q
PROC1 ;
 K APCLG S %=DFN_"^ALL VISITS;DURING "_APCLBD_"-"_APCLED,E=$$START1^APCLDF(%,"APCLG(")
 S APCLE=0 F  S APCLE=$O(APCLG(APCLE)) Q:APCLE'=+APCLE  D
 .S APCLVIEN=$P(APCLG(APCLE),U,5)
 .Q:'APCLVIEN
 .S APCLDATE=$P(APCLG(APCLE),U,1)
 .I 'APCLEXBH S C=$$CLINIC^APCLV(APCLVIEN,"C") I C=14!(C=45)!(C=48) Q
 .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
PEXS .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVXAM("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVXAM(APCLEIEN,0))
 ..S R=$P(^AUPNVXAM(APCLEIEN,0),U,1)
 ..Q:$P($G(^AUTTEXAM(+R,0)),U,2)'=35
 ..S APCLRES=$$VAL^XBDIQ1(9000010.13,APCLEIEN,.04) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="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
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$SPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="EXAM"
PMSRS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVMSR("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVMSR(APCLEIEN,0))
 ..Q:$P($G(^AUPNVMSR(APCLEIEN,2)),U,1)  ;ENTERED IN ERROR
 ..S R=$P(^AUPNVMSR(APCLEIEN,0),U,1)
 ..S R=$P($G(^AUTTMSR(+R,0)),U,1)
 ..I R'="AUDC",R'="AUDT",R'="CRFT" Q
 ..S APCLRES=R_" "_$$VAL^XBDIQ1(9000010.01,APCLEIEN,.04)
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$MPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="MSR"
PHF .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVHF("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVHF(APCLEIEN,0))
 ..S R=$P(^AUPNVHF(APCLEIEN,0),U,1)
 ..S R=$$VAL^XBDIQ1(9999999.64,R,.01)
 ..I R'["CAGE " Q
 ..S APCLRES=R
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$HFPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="HF"
PPVS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVPOV("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVPOV(APCLEIEN,0))
 ..S R=$$VAL^XBDIQ1(9000010.07,APCLEIEN,.01)
 ..I R'="V79.1" Q
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$PVPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="DX"
PPEDS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVPED("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVPED(APCLEIEN,0))
 ..S R=$P(^AUPNVPED(APCLEIEN,0),U,1)
 ..S R=$P($G(^AUTTEDT(+R,0)),U,2)
 ..I R'="AOD-SCR",R'="CD-SCR" Q
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$PEDPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="PED"
PCPTS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AUPNVCPT("AD",APCLVIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AUPNVCPT(APCLEIEN,0))
 ..S R=$P(^AUPNVCPT(APCLEIEN,0),U)
 ..Q:'$$ICD^ATXAPI(R,$O(^ATXAX("B","BGP ALCOHOL SCREENING CPTS",0)),1)
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$PPV(APCLVIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9000010,APCLVIEN,.08)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLVIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$CPTPRV(APCLEIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="CPT"
PREF ;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
 .Q:$D(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE))  ;already got one from v exam on this date
 .;S X=$O(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,0))
 .;I X]"",X<APCLDATE K ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,X)
 .S APCLRES=$$VAL^XBDIQ1(9000022,APCLRIEN,.07) S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 .S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="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
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$PRVREF(APCLRIEN)
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="EXAM"
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 BH1
 Q
BH1 ;
 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))
 .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
 .Q:$D(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE))  ;already got one from PCC on this date
 .;S X=$O(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,0))
 .;I X]"",X<APCLDATE K ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,X)
 .S APCLRES=$$VAL^XBDIQ1(9002011,APCLBIEN,1403)
 .I APCLRES="" G BMSR
 .S:APCLRES["REFUSED" APCLRES="REFUSED SCREENING" S:APCLRES["NEGATIVE" APCLRES="NEGATIVE"
 .S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="BH"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_$$VAL^XBDIQ1(9002011,APCLBIEN,1601)_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLBIEN
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$S($P($G(^AMHREC(APCLBIEN,14)),U,2):$$VAL^XBDIQ1(9002011,APCLBIEN,1404),1:"UNKNOWN")
 .S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
BMSR .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AMHRMSR("AD",APCLBIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AMHRMSR(APCLEIEN,0))
 ..S R=$P(^AMHRMSR(APCLEIEN,0),U,1)
 ..S R=$P($G(^AUTTMSR(+R,0)),U,1)
 ..I R'="AUDC",R'="AUDT",R'="CRFT" Q
 ..S APCLRES=R_" "_$$VAL^XBDIQ1(9002011.12,APCLEIEN,.04)
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="BH"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$BHPPNAME(APCLBIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="MSR"
BHF .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AMHRHF("AD",APCLBIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AMHRHF(APCLEIEN,0))
 ..S R=$P(^AMHRHF(APCLEIEN,0),U,1)
 ..S R=$$VAL^XBDIQ1(9999999.64,R,.01)
 ..I R'["CAGE " Q
 ..S APCLRES=R
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$BHPPNAME(APCLBIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="HF"
BPVS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AMHRPRO("AD",APCLBIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AMHRPRO(APCLEIEN,0))
 ..S R=$$VAL^XBDIQ1(9002011.01,APCLEIEN,.01)
 ..I R'="29.1" Q
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$BHPPNAME(APCLBIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="DX"
BPEDS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AMHREDU("AD",APCLBIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AMHREDU(APCLEIEN,0))
 ..S R=$P(^AMHREDU(APCLEIEN,0),U,1)
 ..S R=$P($G(^AUTTEDT(+R,0)),U,2)
 ..I R'="AOD-SCR",R'="CD-SCR" Q
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$BHPPNAME(APCLBIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="PED"
BCPTS .;
 .S APCLEIEN=0 F  S APCLEIEN=$O(^AMHRPROC("AD",APCLBIEN,APCLEIEN)) Q:APCLEIEN'=+APCLEIEN  D
 ..Q:'$D(^AMHRPROC(APCLEIEN,0))
 ..S R=$P(^AMHRPROC(APCLEIEN,0),U)
 ..Q:'$$ICD^ATXAPI(R,$O(^ATXAX("B","BGP ALCOHOL SCREENING CPTS",0)),1)
 ..S APCLRES=""
 ..S ^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE)="EX"_U_$$BHPPNAME(APCLBIEN)_U_APCLRES_U_""_U_$$AGE^AUPNPAT(DFN,APCLDATE)_U_$$VAL^XBDIQ1(2,DFN,.02)_U_APCLDATE_U_APCLEIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,9)=$$VAL^XBDIQ1(9002011,APCLBIEN,.25)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,15)=APCLBIEN
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,16)=$$BHPPNAME(APCLBIEN)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,17)=$$VAL^XBDIQ1(9000001,DFN,.14)
 ..S $P(^XTMP("APCLAL1",APCLJ,APCLH,"PTS",DFN,APCLDATE),U,18)="CPT"
 Q
 ;
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) ;
 I $P($G(^AUPNVXAM(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.13,E,1204)
 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)
 I %=-1 Q "UNKNOWN"
 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")
 ;----------
 ;
MPRV(E) ;
 I $P($G(^AUPNVMSR(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.01,E,1204)
 Q "UNKNOWN"
HFPRV(E) ;
 I $P($G(^AUPNVHF(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.22,E,1204)
 Q "UNKNOWN"
PVPRV(E) ;
 I $P($G(^AUPNVPOV(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.07,E,1204)
 Q "UNKNOWN"
PEDPRV(E) ;
 I $P($G(^AUPNVPED(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.16,E,1204)
 Q "UNKNOWN"
CPTPRV(E) ;
 I $P($G(^AUPNVCPT(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.18,E,1204)
 Q "UNKNOWN"