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

BQICAEP2.m

Go to the documentation of this file.
BQICAEP2 ;GDIT/HS/ALA-Dept of EPI Comm Alert Logic ; 03 Oct 2011  12:26 PM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
 ;
MEAS(BQDFN,RESULT) ;EP - Measles
 NEW UID,TREF,TAX,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BQI MEASLES ALERT LOINCS" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI MEASLES ALERT TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 S SEARCH(1)="POS"_U_"=",SEARCH(2)="1.09"_U_">"
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 I X D LB^BQICAEP1(X,CT)
 K SEARCH,@TREF
 Q
 ;
MEN(BQDFN,RESULT) ;EP - Meningitis
 NEW UID,TREF,TAX,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BQI MENINGITIS QUAL TEST LOINC","BQI MENINGITIS ID SPEC LOINC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI MENINGITIS GRAM STAIN LNC","BQI MENINGITIS QUAN LOINC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI MENINGITIS QUAL TEST TAX","BQI MENINGITIS GRAM STAIN TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 F TAX="BQI MENINGITIS ID SPEC TAX","BQI MENINGITIS QUAN TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">"
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 I X D LB^BQICAEP1(X,CT)
 K SEARCH,@TREF
 Q
 ;
FLU(BQDFN,RESULT) ;EP - Influenza
 NEW UID,TREF,TAX,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S SEARCH(1)="POS"_U_"="
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 S TAX="SURVEILLANCE RAPID FLU TESTS" D BLD^BQITUTL(TAX,.TREF,"L")
 S TAX="SURVEILLANCE RAPID FLU LOINC" D BLD^BQITUTL(TAX,.TREF)
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 I X D LB^BQICAEP1(X,CT)
 K SEARCH,@TREF
 Q
 ;
FLUD(BQDFN,RESULT) ;EP - Flu Diagnosis
 NEW UID,TREF,TAX,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 ;S TIME="T-14M"
 S X=$$TAX^BQITRUTL(TMFRAME,"BQI ILI NO TMP NEEDED DXS",1,BQDFN,9000010.07,"","",.TREF)
 I X D DXF(X) K @TREF Q
 ;
 S X=$$TAX^BQITRUTL(TMFRAME,"SURVEILLANCE ILI",1,BQDFN,9000010.07,"","",.TREF)
 I 'X Q
 S VISIT=$P(X,U,4)
 S X1=$$MEAS^BQICAUTL(BQDFN,"TMP",VISIT,"100",">") I 'X1 Q
 D DXF(X),MSF(X1)
 K @TREF
 Q
 ;
TUB(BQDFN,RESULT) ; EP - Tuberculosis
 NEW UID,TREF,TAX,X,BDX,BX
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 S BDXX=$$TAX^BQITRUTL(TMFRAME,"BQI TUBERCULOSIS DXS",1,BQDFN,9000010.07,"","",.TREF)
 I BDXX D DXF(BDXX)
 K @TREF
 ;
 ; Check for positive skin test
 S BSXX=$$SKTST(BQDFN,"T-60")
 I BSXX D
 . NEW VSDTM,TIEN,VISIT,IEN
 . S VSDTM=$P(BSXX,U,2),VISIT=$P(BSXX,U,4),IEN=$P(BSXX,U,5),TIEN=$P(^AUPNVSK(IEN,0),U,1)
 . S @DATA@(COMM,ALRT,BQDFN,"SK",VSDTM,TIEN)=VISIT_U_IEN_U_"9000010.12"
 ;
 ; Check for BCG or other immunization
 S BX=$$BCG(BQDFN,"")
 ;
 F TAX="BKM PPD LOINC CODES","BQI PPD DIAMETER LOINC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BKM PPD TAX","BQI PPD DIAMETER TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 F TAX="BQI TB GAMMA REL QUAL TEST TAX","BQI TB GAMMA REL QUANT TEST TX" D BLD^BQITUTL(TAX,.TREF,"L")
 F TAX="BQI TB GAMMA REL QUAL TEST LNC","BQI TB GAMMA REL QUANT TEST LC" D BLD^BQITUTL(TAX,.TREF)
 S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">"
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 K SEARCH,@TREF
 I X!(BSXX),'BX,BDXX D LB^BQICAEP1(X,CT) Q
 ;
 K @TREF
 F TAX="BQI TB RNA DNA QUAL TEST LOINC","BQI TB RNA DNA QUANT TEST LNC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI TB RNA DNA QUAL TEST TAX","BQI TB RNA DNA QUANT TEST TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 F TAX="BQI TB SPECIFIC AFB TEST LOINC","BQI TB NONSPEC AFB TEST LOINC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI TB SPECIFIC AFB TEST TAX","BQI TB NONSPEC AFB TEST TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">"
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 I X,'BX,BDXX D LB^BQICAEP1(X,CT)
 K SEARCH,@TREF
 Q
 ;
SYP(BQDFN,RESULT) ;EP - Syphilis
 NEW UID,TREF,TAX,XTP,XSC,DATE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 ;
 D
 . S TAX="BQI SYPHILIS TP-AB LOINC" D BLD^BQITUTL(TAX,.TREF)
 . S TAX="BQI SYPHILIS TP-AB TEST TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 . S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">"
 . S XTP=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 . K @TREF
 . S TAX="BQI SYPHILIS REAGIN LOINC" D BLD^BQITUTL(TAX,.TREF)
 . S TAX="BQI SYPHILIS REAGIN TEST TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 . S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">",DATE=$P(XTP,U,2)
 . S XSC=$$LBB^BQICAUTL(30,0,DATE,BQDFN,"",.SEARCH,.TREF)
 . K @TREF
 . I 'XTP,'XSC Q
 . I XSC D
 .. NEW XBGS,XBES
 .. S XBGS=$P(XSC,U,2),XBES=DT
 .. S XFPS=$$TAX^BQITRUTL("","BQI SYPHILIS FALSE POS DXS",1,BQDFN,9000010.07,"","",.TREF,XBGS,XBES)
 .. I XFPS S XSC=0
 . I XTP D
 .. S XBGT=$P(XTP,U,2),XBET=DT
 .. S XFPT=$$TAX^BQITRUTL("","BQI SYPHILIS FALSE POS DXS",1,BQDFN,9000010.07,"","",.TREF,XBGT,XBET)
 .. I XFPT S XTP=0
 ;
 I XTP,XSC D
 . D LB^BQICAEP1(XTP,CT) S CT=CT+1
 . D LB^BQICAEP1(XSC,CT)
 K SEARCH,@TREF
 Q
 ;
HIB(BQDFN,RESULT) ;EP - HIB Flu
 NEW UID,TREF,TAX,X
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 K RESULT
 S RESULT(1)=0,CT=1
 S TREF=$NA(^TMP("BQITAX",$J)) K @TREF
 F TAX="BQI HIB QUAL TEST LOINC","BQI HIB CULTURE TEST LOINC","BQI HIB QUANT TEST LOINC" D BLD^BQITUTL(TAX,.TREF)
 F TAX="BQI HIB QUAL TEST TAX","BQI HIB CULTURE TEST TAX","BQI HIB QUANT TEST TAX" D BLD^BQITUTL(TAX,.TREF,"L")
 S SEARCH(1)="POS"_U_"=",SEARCH(2)="0"_U_">"
 S X=$$LAB^BQICAUTL(TMFRAME,0,BQDFN,"",.SEARCH,.TREF)
 I X D LB^BQICAEP1(X,CT)
 K SEARCH,@TREF
 Q
 ;
DXF(BQX) ;EP - Diagnosis
 NEW VSDTM,TIEN,VISIT,IEN
 S VSDTM=$P(BQX,U,2),VISIT=$P(BQX,U,4),IEN=$P(BQX,U,5),TIEN=$P(^AUPNVPOV(IEN,0),U,1)
 S @DATA@(COMM,ALRT,BQDFN,"DX",VSDTM,TIEN)=VISIT_U_IEN_U_"9000010.07"
 Q
 ;
MSF(BQX) ;EP - Measurement
 NEW VSDTM,TIEN,VISIT,IEN
 S VSDTM=$P(BQX,U,2),VISIT=$P(BQX,U,4),IEN=$P(BQX,U,5),TIEN=$P(^AUPNVMSR(IEN,0),U,1)
 S @DATA@(COMM,ALRT,BQDFN,"MS",VSDTM,TIEN)=VISIT_U_IEN_U_"9000010.01"
 Q
 ;
BCG(BQDFN,TMFRAME) ;EP - BCG Vaccination
 ; immunization BCG or 19
 ; cpt codes 90728 or 90585
 ; icd9 diagnosis V03.2
 ; icd9 procedure 99.33
 ;
 NEW ENDT,STDT,BGDT,BQIM,QFL,IEN,VIEN,TIEN,RES,TREF,BPOV
 S RES=0
 I $G(TMFRAME)'="" S ENDT=(9999999-$$DATE^BQIUL1(TMFRAME)),BGDT=9999999-DT,STDT=ENDT-.0001
 I $G(TMFRAME)="" S STDT="",ENDT=""
 ;
 ; Check BCG immunization
 S BQIM=$O(^AUTTIMM("B","BCG","")) I BQIM'="" D
 . S QFL=0 I ENDT="" S ENDT=$O(^AUPNVIMM("AA",BQDFN,BQIM,STDT),-1)
 . F  S STDT=$O(^AUPNVIMM("AA",BQDFN,BQIM,STDT)) Q:STDT=""!(STDT>ENDT)  D  Q:QFL
 .. S IEN=""
 .. F  S IEN=$O(^AUPNVIMM("AA",BQDFN,BQIM,STDT,IEN)) Q:IEN=""  D  Q:QFL
 ... S VIEN=$P($G(^AUPNVIMM(IEN,0)),U,3)
 ... S RES=1_U_$$FMTE^BQIUL1((9999999-STDT))_U_U_VIEN_U_IEN_U
 ;
 I RES Q RES
 ; check for ICD9 diagnosis
 S TREF="BQILST" K @TREF
 D BLDSV^BQITUTL(80,"V03.2 ",TREF)
 I $G(TMFRAME)'="" S ENDT=(9999999-$$DATE^BQIUL1(TMFRAME)),BGDT=9999999-DT,STDT=ENDT-.0001
 I $G(TMFRAME)="" S STDT="",ENDT=""
 I ENDT="" S ENDT=$O(^AUPNVPOV("AA",BQDFN,""),-1)
 F  S STDT=$O(^AUPNVPOV("AA",BQDFN,STDT)) Q:STDT=""!(STDT>ENDT)  D  Q:QFL
 . S IEN=""
 . F  S IEN=$O(^AUPNVPOV("AA",BQDFN,STDT,IEN)) Q:IEN=""  D  Q:QFL
 .. S BPOV=$P($G(^AUPNVPOV(IEN,0)),U,1) I BPOV="" Q
 .. I '$D(@TREF@(BPOV)) Q
 .. S VIEN=$P(^AUPNVPOV(IEN,0),U,3)
 .. S RES=1_U_$$FMTE^BQIUL1((9999999-STDT))_U_U_VIEN_U_IEN_U
 ;
 I RES Q RES
 ;
 ; Check for CPT codes
 S TREF="BQILST" K @TREF
 D BLDSV^BQITUTL(81,"90585 ",TREF),BLDSV^BQITUTL(81,"90728 ",TREF)
 S TIEN="",QFL=0
 F  S TIEN=$O(@TREF@(TIEN)) Q:TIEN=""  D  Q:QFL
 . I $G(TMFRAME)'="" S ENDT=(9999999-$$DATE^BQIUL1(TMFRAME)),BGDT=9999999-DT,STDT=ENDT-.0001
 . I $G(TMFRAME)="" S STDT="",ENDT=""
 . I ENDT="" S ENDT=$O(^AUPNVCPT("AA",BQDFN,TIEN,""),-1)
 . F  S STDT=$O(^AUPNVCPT("AA",BQDFN,TIEN,STDT)) Q:STDT=""!(STDT>ENDT)  D  Q:QFL
 .. S IEN=""
 .. F  S IEN=$O(^AUPNVCPT("AA",BQDFN,TIEN,STDT,IEN)) Q:IEN=""  D  Q:QFL
 ... S VIEN=$P($G(^AUPNVCPT(IEN,0)),U,3)
 ... S RES=1_U_$$FMTE^BQIUL1((9999999-STDT))_U_U_VIEN_U_IEN_U
 ;
 I RES Q RES
 ;
 ; Check for procedure
 S TREF="BQILST" K @TREF
 D BLDSV^BQITUTL(80.1,"99.33 ",TREF)
 I $G(TMFRAME)'="" S ENDT=(9999999-$$DATE^BQIUL1(TMFRAME)),BGDT=9999999-DT,STDT=ENDT-.0001
 I $G(TMFRAME)="" S STDT="",ENDT=""
 I ENDT="" S ENDT=$O(^AUPNVPRC("AA",BQDFN,""),-1)
 F  S STDT=$O(^AUPNVPRC("AA",BQDFN,STDT)) Q:STDT=""!(STDT>ENDT)  D  Q:QFL
 . S IEN=""
 . F  S IEN=$O(^AUPNVPRC("AA",BQDFN,STDT,IEN)) Q:IEN=""  D  Q:QFL
 .. S BPOV=$P($G(^AUPNVPRC(IEN,0)),U,1) I BPOV="" Q
 .. I '$D(@TREF@(BPOV)) Q
 .. S VIEN=$P(^AUPNVPRC(IEN,0),U,3)
 .. S RES=1_U_$$FMTE^BQIUL1((9999999-STDT))_U_U_VIEN_U_IEN_U
 K @TREF
 Q RES
 ;
SKTST(BQDFN,TMFRAME) ;EP - Skin Test
 NEW SKN,ENDT,STDT,BGDT,IEN,VIEN,RES,VALUE
 S SKN=$$FIND1^DIC(9999999.28,,"X","PPD")
 S RES=0
 I $G(TMFRAME)'="" S ENDT=(9999999-$$DATE^BQIUL1(TMFRAME)),BGDT=9999999-DT,STDT=ENDT-.0001
 I $G(TMFRAME)="" S STDT="",ENDT=""
 I ENDT="" S ENDT=$O(^AUPNVSK("AA",BQDFN,SKN,""),-1)
 F  S STDT=$O(^AUPNVSK("AA",BQDFN,SKN,STDT)) Q:STDT=""!(STDT>ENDT)  D  Q:QFL
 . S IEN=""
 . F  S IEN=$O(^AUPNVSK("AA",BQDFN,SKN,STDT,IEN)) Q:IEN=""  D  Q:QFL
 .. S VIEN=$P($G(^AUPNVSK(IEN,0)),U,3) I VIEN="" Q
 .. ; If the reading is greater than 15 mm, then it is positive
 .. S VALUE=+$P(^AUPNVSK(IEN,0),U,5)'>15 Q
 .. S RES=1_U_$$FMTE^BQIUL1((9999999-STDT))_U_U_VIEN_U_IEN_U_"9000010.12"
 Q RES