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

BQICMUT2.m

Go to the documentation of this file.
BQICMUT2 ;GDHD/HCS/ALA-Care Mgmt Utility ; 02 Nov 2016  9:53 AM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;;
 ;
MEAS(DFN,MEAS) ;EP - Last Measurement
 NEW VALUE,RES
 S VALUE=$$MEAS^BQITUTL(DFN,MEAS)
 I 'VALUE Q ""
 S RES=$P(VALUE,"^",3) I MEAS="BMI" S RES=$J(RES,3,2)
 S VALUE=$$FMTMDY^BQIUL1($P(VALUE,"^",2))_" ("_RES_")"
 Q VALUE
 ;
LEAD(DFN) ;EP - Lead test
 NEW VALUE
 S VALUE=$$LAB^BQITRUTL("",0,DFN,"BQI BLOOD LEAD TESTS","","'=","","","")
 I 'VALUE Q ""
 Q $P(VALUE,U,2)_" ("_$P(VALUE,U,3)_")"
 ;
INF(DFN,AGE,FFLG) ;EP - Infant Feeding record
 NEW VALUE,FIEN,DOB,BD1,BD2,STRT,DATE
 S VALUE="",FFLG=$G(FFLG,0)
 I $G(AGE)="" D  Q VALUE
 . S FIEN=$O(^AUPNVIF("AC",DFN,""),-1) I FIEN="" Q
 . D INV
 ;
 S VALUE="NO"
 S DOB=$P(^DPT(DFN,0),"^",3)
 I AGE="2 MOS" S B1=45,B2=89
 I AGE="6 MOS" S B1=165,B2=209
 I AGE="9 MOS" S B1=255,B2=299
 I AGE="12 MOS" S B1=350,B2=394
 S BD1=$$FMADD^XLFDT(DOB,B1),BD2=$$FMADD^XLFDT(DOB,B2)
 S STRT=""
 F  S STRT=$O(^AUPNVIF("AA",DFN,STRT)) Q:STRT=""  D
 . S DATE=9999999-STRT
 . I DATE'<BD1,DATE'>BD2 S FIEN=$O(^AUPNVIF("AA",DFN,STRT,"")) D INV
 Q VALUE
 ;
DENT(DFN) ;EP - Last Dental Visit
 NEW VALUE,BDATE,EDATE,P,ORD,N,BGPG,BQIXX,BGPC,DATE
 S VALUE=""
 S BDATE=$$DATE^BQIUL1("T-60M"),EDATE=DT,P=DFN
 ; Search by Exam
 D
 . S %=P_"^LAST EXAM DENTAL;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 . S ORD=$P(^BTPW(90621.1,2,0),U,5)
 . S N="" F  S N=$O(BGPG(N)) Q:N=""  S DATE=$P(BGPG(N),U,1),BQIXX(DATE,ORD,N)=BGPG(N)
 K BGPG
 ; Search by ADA
 D
 . S BGPC="",%=P_"^LAST ADA [BGP DENTAL EXAM ADA CODES;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 . S ORD=1
 . S N="" F  S N=$O(BGPG(N)) Q:N=""  S DATE=$P(BGPG(N),U,1),BQIXX(DATE,ORD,N)=BGPG(N)
 K BGPG
 ; Search by CPT
 D
 . S BGPC=$$CPT^BGP7DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP DENTAL EXAM CPTS",0)),6)
 . I BGPC="" Q
 . S DATE=$P(BGPC,U,2),ORD=$P(^BTPW(90621.1,5,0),"^",5)
 . S BQIXX(DATE,ORD,1)=BGPC
 ; Search by DX
 D
 . S BGPG=$$LASTDX^BGP7UTL1(P,"BGP DENTAL EXAM DXS",BDATE,EDATE)
 . I BGPG="" Q
 . S DATE=$P(BGPG,U,3),ORD=$P(^BTPW(90621.1,7,0),"^",5)
 . S BQIXX(DATE,ORD,1)=BGPG
 ;
 I $D(BQIXX) D
 . S DATE=$O(BQIXX(""),-1),ORD=$O(BQIXX(DATE,"")),N=$O(BQIXX(DATE,ORD,""))
 . S VALUE=DATE
 ;
 Q $$FMTMDY^BQIUL1(VALUE)
 ;
INV ;EP
 I 'FFLG S VALUE=$$FMTMDY^BQIUL1($$VISD^BQICMUTL(9000010.44,FIEN)\1)_" ("_$$GET1^DIQ(9000010.44,FIEN_",",.01,"E")_")"
 I FFLG S VALUE="YES"
 Q
 ;
GPR(CODE) ;EP
 NEW BGPHOME,BQIH,BQIINDF,BQIINDG,BQIMEASF,BQIMEASG,BQIROU,BQIY,BQIYR,ERR,LIST
 NEW IEN,N,VAL
 D INP^BQINIGHT
 D FIND^DIC(90506.1,"","","X",CODE,"","E","","","LIST","ERR")
 S VAL=""
 S N=0 F  S N=$O(LIST("DILIST",1,N)) Q:N=""  D
 . I LIST("DILIST",1,N)'[BQIYR_"_" K LIST("DILIST",1,N),LIST("DILIST",2,N)
 S N=0 F  S N=$O(LIST("DILIST",2,N)) Q:N=""  D
 . S IEN=LIST("DILIST",2,N) I $P(^BQI(90506.1,IEN,0),U,3)=CODE S VAL=IEN_U_$P(^(0),U,1)
 Q VAL
 ;
COLO(DFN) ;EP
 NEW REC,CODE,IEN,NUM,DEN
 S REC=$$GPR("Colorectal Cancer Screen 50-75") I REC="" Q ""
 S CODE=$P(REC,U,2)
 S IEN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IEN="" Q "NDA"
 S NUM=$P(^BQIPAT(DFN,30,IEN,0),U,3),DEN=$P(^(0),U,4)
 I DEN'=1 Q "N/A"
 I DEN=1,+NUM=0 Q "NO"
 Q "YES"
 ;
DEP(DFN) ;EP
 NEW REC,CODE,IEN,NUM,DEN
 S REC=$$GPR("Depression: Screening Only 18+") I REC="" Q ""
 S CODE=$P(REC,U,2)
 S IEN=$O(^BQIPAT(DFN,30,"B",CODE,"")) I IEN="" Q "NDA"
 S NUM=$P(^BQIPAT(DFN,30,IEN,0),U,3),DEN=$P(^(0),U,4)
 I DEN'=1 Q "N/A"
 I DEN=1,+NUM=0 Q "NO"
 Q "YES"
 ;
ADHD(DFN) ;EP
 NEW VALUE
 S VALUE=$$TAX^BQITRUTL("","BQI ADD/ADHD DXS",1,DFN,9000010.07,1,"","","","")
 I 'VALUE Q "NO"
 Q "YES ("_$$FMTMDY^BQIUL1($P(VALUE,U,2))_")"
 ;
HEAR(DFN) ;EP
 NEW MS,ARRAY,CT,DATE,NBRN,NEWB,AUD,IEN,VALUE,RES
 S MS=$$MEAS^BQITUTL(DFN,"HE"),CT=1
 I MS S DATE=$P(MS,"^",2),ARRAY(DATE,CT)=MS_"^HEARING"
 F NBRN="NEWBORN HEARING SCREEN (LEFT)","NEWBORN HEARING SCREEN (RIGHT)" D
 . S NEWB=$$EXAM^BQITUTL(DFN,NBRN)
 . I 'NEWB Q
 . S CT=CT+1,DATE=$P(NEWB,"^",2),ARRAY(DATE,CT)=NEWB_"^"_NBRN
 S AUD=$$EXAM^BQITUTL(DFN,"AUDITORY EVOKED POTENTIAL")
 I AUD S CT=CT+1,DATE=$P(AUD,"^",2),ARRAY(DATE,CT)=AUD_"^"_"AUDITORY EVOKED POTENTIAL"
 S DATE=$O(ARRAY(""),-1)
 I DATE="" Q "NO"
 S CT=$O(ARRAY(DATE,""),-1)
 S IEN=$P(ARRAY(DATE,CT),"^",5),RES=$P(ARRAY(DATE,CT),"^",6)
 S VALUE="YES  "_$$FMTMDY^BQIUL1(DATE)_" ("_RES_")"
 Q VALUE
 ;
VIS(DFN) ;EP - Vision
 NEW VALUE,IEN,RES,DATE
 S VALUE=$$EXAM^BQITUTL(DFN,"EYE EXAM - GENERAL")
 I 'VALUE Q "NO"
 S IEN=$P(VALUE,"^",5),RES=$$GET1^DIQ(9000010.13,IEN_",",.04,"E"),DATE=$P(VALUE,"^",2)
 Q "YES  "_$$FMTMDY^BQIUL1(DATE)
 ;Q "YES  "_$$FMTMDY^BQIUL1(DATE)_" ("_RES_")"
 ;
WELL(DFN,NUM) ;EP - Last Number of Well Child Visits
 NEW BQISBST,OK,BQSN,CNT,CDATA,CID,TXT,LIEN,VIS,CT,QTL,DATE,VALUE,ARRAY
 S NUM=$G(NUM,3)
 S BQISBST=$NA(^TMP("BQIWELLC",$J)) K @BQISBST
 S OK=$$SUBLST^BSTSAPI(BQISBST,"PXRM BQI WELL CHILD VISIT^36^1")
 S BQSN=0,CNT=0
 F  S BQSN=$O(@BQISBST@(BQSN)) Q:BQSN=""  D
 . S CDATA=@BQISBST@(BQSN)
 . S CID=$P(CDATA,"^",1),TXT=$P(CDATA,"^",3)
 . S BDT="",CT=0
 . F  S BDT=$O(^AUPNVPOV("ASNC",DFN,CID,BDT)) Q:BDT=""  D
 .. S LIEN=""
 .. F  S LIEN=$O(^AUPNVPOV("ASNC",DFN,CID,BDT,LIEN)) Q:LIEN=""  D
 ... I $P($G(^AUPNVPOV(LIEN,11)),U,1)'=CID Q
 ... S VIS=$P($G(^AUPNVPOV(LIEN,0)),U,3) I VIS="" Q
 ... I $G(^AUPNVSIT(VIS,0))="" Q
 ... S CT=CT+1,DATE=9999999-BDT,ARRAY(DATE,CID,CT)=LIEN_"^"_VIS_"^"_TXT
 I '$D(ARRAY) Q ""
 S CT=0,QTL=0,DATE="",VALUE=""
 F  S DATE=$O(ARRAY(DATE),-1) Q:DATE=""!(QTL)  D  Q:QTL
 . S CID=""
 . F  S CID=$O(ARRAY(DATE,CID)) Q:CID=""  D
 .. S VL=$O(ARRAY(DATE,CID,"")),TXT=$P(ARRAY(DATE,CID,VL),"^",3)
 .. S VALUE=VALUE_$$FMTMDY^BQIUL1(DATE)_" ("_TXT_")"_$C(10)_$C(13)
 .. S CT=CT+1 I CT>NUM S QTL=1
 S VALUE=$$TKO^BQIUL1(VALUE,$C(10)_$C(13))
 Q VALUE
 ;
ASQ(DFN) ;EP - Last ASQ measurement
 NEW MEAS,MS,VALUE,RES,RESU,NAME
 S MS="ASQ",MEAS=MS,RESU=""
 F  S MEAS=$O(^AUTTMSR("B",MEAS)) Q:MEAS=""!($E(MEAS,1,3)'=MS)  D
 . S IEN=$O(^AUTTMSR("B",MEAS,"")) I IEN="" Q
 . S NAME=$P(^AUTTMSR(IEN,0),"^",2),NAME=$P(NAME,"ASQ - ",2)
 . I MEAS="ASQM" S NAME="ASQ QUESTIONNAIRE (MOS)"
 . S VALUE=$$MEAS^BQITUTL(DFN,MEAS)
 . S RES=$P(VALUE,"^",3)
 . S RESU=RESU_NAME_" "_$$FMTMDY^BQIUL1($P(VALUE,"^",2))_" ("_RES_")"_$C(10)_$C(13)
 S RESU=$$TKO^BQIUL1(RESU,$C(10)_$C(13))
 Q RESU