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

BQIIPUT1.m

Go to the documentation of this file.
BQIIPUT1 ;GDIT/HCSD/ALA-IPC utilities ; 05 Apr 2018  7:44 AM
 ;;2.7;ICARE MANAGEMENT SYSTEM;**1**;Dec 19, 2017;Build 12
 ;
OFV(DFN) ;EP - Office Visit in past year
 NEW BDATE,EDATE,TREF,TAX,RVBDT,RVEDT,VISIT,VAL,RVDATE,BQQN,SNO
 ; has the patient had an office visit in the past year
 S BDATE=$$DATE^BQIUL1("T-12M"),EDATE=DT
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BGP IPC OFFICE VISIT CPTS","BGP IPC PREVCARE EOV >=18 CPTS","BGP IPC PREVCARE IOV >=18 CPTS","BGP IPC HOMEHEALTH VISIT CPTS","BGP IPC ANNUAL WELLNESS CPTS" D
 . D BLD^BQITUTL(TAX,.TREF)
 S RVBDT=9999999-BDATE,RVEDT=9999999-EDATE
 F  S RVEDT=$O(^AUPNVSIT("AA",DFN,RVEDT)) Q:RVEDT=""!((RVEDT\1)>RVBDT)  D
 . S VISIT="" F  S VISIT=$O(^AUPNVSIT("AA",DFN,RVEDT,VISIT)) Q:VISIT=""  D
 .. ;no dependent entries
 .. I '$P(^AUPNVSIT(VISIT,0),"^",9) Q
 .. ;deleted
 .. I $P(^AUPNVSIT(VISIT,0),"^",11) Q
 .. I $$FTOF(VISIT,"PXRM BGP IPC FACE2FACE") S VAL((RVEDT\1),VISIT)="" Q
 .. I $P(^AUPNVSIT(VISIT,0),"^",17)="" D CPT Q
 .. S CP=$P(^AUPNVSIT(VISIT,0),"^",17) I $D(@TREF@(CP)) S VAL((RVEDT\1),VISIT)=""
 ;
 S RVDATE=$O(VAL("")) I RVDATE'="" S RVDATE=9999999-RVDATE
 Q $$FMTMDY^BQIUL1(RVDATE)
 ;
CPT ;EP
 NEW CP,CDT,IEN,VISIT
 S CP="" F  S CP=$O(@TREF@(CP)) Q:CP=""  D
 . S CDT="" F  S CDT=$O(^AUPNVCPT("AA",DFN,CP,CDT)) Q:CDT=""  D
 .. I CDT=(RVEDT\1) D
 ... S IEN="" F  S IEN=$O(^AUPNVCPT("AA",DFN,CP,CDT,IEN)) Q:IEN=""  S VISIT=$P(^AUPNVCPT(IEN,0),"^",3),VAL(CDT,VISIT)=""
 Q
 ;
FLV(DFN) ;EP - Flu Visit
 NEW BDATE,EDATE,TREF,TAX,RVBDT,RVEDT,VISIT,VAL,RVDATE,BQQN
 ; has the patient had an office visit in the past year
 S BDATE=$$DATE^BQIUL1("T-12M"),EDATE=BDATE
 S BDATE=$$FMADD^XLFDT(BDATE,-92),EDATE=$$FMADD^XLFDT(EDATE,89)
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BGP IPC FLU ENCOUNTER CPTS","BGP IPC PERI DIALYSIS CPTS","BGP IPC HEMO DIALYSIS CPTS" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BGP IPC OFFICE VISIT CPTS","BGP IPC OUTPT CONSULT CPTS","BGP IPC LT RES FACILITY CPTS","BGP IPC HOMEHEALTH VISIT CPTS" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BGP IPC PREVCARE IOV 0-17 CPTS","BGP IPC PREVCARE IOV >=18 CPTS","BGP IPC PREVCARE IND COUN CPTS","BGP IPC PREVCARE GRP COUN CPTS" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BGP IPC PREVCARE OTHER CPTS","BGP IPC DSCH SRV NURS FAC CPTS","BGP IPC NURS FAC VISIT CPTS","BGP IPC ANNUAL WELLNESS CPTS" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BGP IPC PERI DIALYSIS CPTS","BGP IPC HEMO DIALYSIS CPTS","BGP IPC PREVCARE EOV 0-17 CPTS","BGP IPC PREVCARE EOV >=18 CPTS" D BLD^BQITUTL(TAX,.TREF)
 S RVBDT=9999999-BDATE,RVEDT=9999999-EDATE
 F  S RVEDT=$O(^AUPNVSIT("AA",DFN,RVEDT)) Q:RVEDT=""!((RVEDT\1)>RVBDT)  D
 . S VISIT="" F  S VISIT=$O(^AUPNVSIT("AA",DFN,RVEDT,VISIT)) Q:VISIT=""  D
 .. ;no dependent entries
 .. I '$P(^AUPNVSIT(VISIT,0),"^",9) Q
 .. ;deleted
 .. I $P(^AUPNVSIT(VISIT,0),"^",11) Q
 .. I $$FTOF(VISIT,"PXRM BGP IPC FLU ENCOUNTER") S VAL((RVEDT\1),VISIT)="" Q
 .. I $$FTOF(VISIT,"PXRM BGP IPC PAT PROV INT") S VAL((RVEDT\1),VISIT)="" Q
 .. I $P(^AUPNVSIT(VISIT,0),"^",17)="" D CPT Q
 .. S CP=$P(^AUPNVSIT(VISIT,0),"^",17) I $D(@TREF@(CP)) S VAL((RVEDT\1),VISIT)=""
 ;
 S RVDATE=$O(VAL("")) I RVDATE'="" S RVDATE=9999999-RVDATE
 Q $$FMTMDY^BQIUL1(RVDATE)_" ("_$$FMTMDY^BQIUL1(BDATE)_"-"_$$FMTMDY^BQIUL1(EDATE)_")"
 ;
FTOF(V,SNO) ;EP
 NEW A,B,C
 S A=0,B=""
 F  S A=$O(^AUPNVSIT(V,28,"B",A)) Q:A=""!(B]"")  D
 .I $D(^XTMP("BGPSNOMEDSUBSET",$J,SNO,A)) S B=A
 Q B
 ;
PSV(DFN) ;EP - Psych Office Visit
 ; for Depression Remission
 NEW BDATE,EDATE,TREF,TAX,RVBDT,RVEDT,VISIT,VAL,RVDATE,BQQN
 ; has the patient had an office visit in the past year
 S BDATE=$$DATE^BQIUL1("T-12M"),EDATE=BDATE
 S BDATE=$$FMADD^XLFDT(BDATE,-(13*30)),EDATE=$$FMADD^XLFDT(EDATE,-1)
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BGP IPC OFFICE VISIT CPTS","BGP IPC PSYCH VISIT CPTS" D BLD^BQITUTL(TAX,.TREF)
 S RVBDT=9999999-BDATE,RVEDT=9999999-EDATE
 F  S RVEDT=$O(^AUPNVSIT("AA",DFN,RVEDT)) Q:RVEDT=""!((RVEDT\1)>RVBDT)  D
 . S VISIT="" F  S VISIT=$O(^AUPNVSIT("AA",DFN,RVEDT,VISIT)) Q:VISIT=""  D
 .. ;no dependent entries
 .. I '$P(^AUPNVSIT(VISIT,0),"^",9) Q
 .. ;deleted
 .. I $P(^AUPNVSIT(VISIT,0),"^",11) Q
 .. S Q=$$PHQ9^BGP8PC13(VISIT)
 .. I Q="" Q
 .. I $P(^AUPNVSIT(VISIT,0),"^",17)="" D CPT Q
 .. S CP=$P(^AUPNVSIT(VISIT,0),"^",17) I $D(@TREF@(CP)) S VAL((RVEDT\1),VISIT)=""
 ;
 S RVDATE=$O(VAL("")) I RVDATE'="" S RVDATE=9999999-RVDATE
 Q $$FMTMDY^BQIUL1(RVDATE)_" ("_$$FMTMDY^BQIUL1(BDATE)_"-"_$$FMTMDY^BQIUL1(EDATE)_")"
 ;
ADZ(DFN) ;EP - Adolescent Immunization requirement
 NEW BDATE,EDATE,A11,A13,A
 S BDATE=$$DATE^BQIUL1("T-12M"),EDATE=DT
 S A=$$YBD^BGP8PC7(DFN,13)
 I A>EDATE!(A<BDATE) Q "N/A"
 S A11=$$YBD^BGP8PC7(DFN,11)
 S A13=$$YBD^BGP8PC7(DFN,13)
 Q $$FMTMDY^BQIUL1(A11)_"-"_$$FMTMDY^BQIUL1(A13)