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

BQIRGASU.m

Go to the documentation of this file.
BQIRGASU ;VNGT/HS/ALA-Asthma Utilities ; 09 Jan 2009  5:01 PM
 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
 ;
 ;
AQC(BQDFN) ;EP - Asthma Quality of Care
 NEW RESULT,DATE
 ;
 S RESULT="N/A",DATE=$$DATE^BQIUL1("T-12M")
 ; Active Asthma Tag
 I '$$ATAG^BQITDUTL(BQDFN,"Asthma") Q RESULT
 S RESULT="NO"
 ;
 ; Severity value ever
 I $$LASTSEV^APCHSAST(BQDFN,1)="" Q RESULT_U_"No severity"
 ; Control document in past year
 I $$VERSION^XPDUTL("BJPC")>1.0,$$LASTACON^APCHSMAS(BQDFN,2)<DATE Q RESULT_U_"No control documented"
 ; Peak Flow or FEV1 or FEV1/FVC documented in past year
 S QFL=0 D  I QFL Q RESULT_U_"No peak flow"
 . I $P($$MEAS^BQIDCUTL(BQDFN,"PF"),U,6)<DATE S QFL=1 Q
 . I $P($$MEAS^BQIDCUTL(BQDFN,"FVFC"),U,6)<DATE S QFL=1 Q
 ; Asthma Action Plan in the past year
 S Y=$$LASTITEM^APCHSMU(BQDFN,"ASM-SMP","EDUCATION") I Y<DATE Q RESULT_U_"No Asthma Action Plan"
 ; Flu Shot document in past year (Health Maintenance Reminder)
 ;S HIEN=$$FIND1^DIC(9001018,"","Q","ASTHMA PATIENT-FLU SHOT","B","","ERROR")
 ;I 'HIEN Q RESULT
 ;S X=$$GVHMR^APCHSMU(BQDFN,HIEN)
 ;I X'="" Q RESULT
 I $$LASTFLU^APCLAPI4(BQDFN)<DATE Q RESULT_U_"No flu shot in past year"
 ; Severity 2,3, or 4 AND any current controllers prescription
 I $$LASTSEV^APCHSAST(BQDFN,1)<2 Q RESULT_U_"Severity less than 2"
 I '$$CNTRL(BQDFN) Q RESULT_U_"No controller meds"
 Q "YES"
 ;
CNTRL(BQDFN) ; EP - Controller Medications
 NEW TAX,TREF,DESC,MEET,X,RESULT,OTHER,VISIT
 I $G(UID)="" S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DESC=""
 S TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 F TAX="BAT ASTHMA CONTROLLER MEDS","BAT ASTHMA CONTROLLER NDC","BAT ASTHMA INHALED STEROIDS","BAT ASTHMA INHLD STEROIDS NDC","BAT ASTHMA LEUKOTRIENE MEDS","BAT ASTHMA LEUKOTRIENE NDC" D BLD^BQITUTL(TAX,TREF)
 S X=$$TAX^BQITRUTL("","",1,BQDFN,9000010.14,"","",.TREF)
 ; if returns a found medication, check if it is an active medication
 I $P(X,U,1)=1 D
 . I $$ACTMED^BKMQQCR4($P(X,U,5)) Q
 . S $P(X,U,1)=0
 I $P(X,U,1)=1 S MEET=1,DESC=DESC_"On Asthma Controller Meds ("_$$FMTE^BQIUL1($P(X,U,2))_" "_$$GET1^DIQ(9000010.14,$P(X,U,5)_",",.01,"E")_")"
 I $P(X,U,1)=0 S MEET=0,DESC=DESC_"Not on Asthma Controller Meds"
 K @TREF
 S RESULT="N/A",OTHER="",VISIT=""
 I $$ATAG^BQITDUTL(BQDFN,"Asthma") D
 . I 'MEET S RESULT="NO" Q
 . S RESULT="YES",OTHER=$$FMTE^BQIUL1($P(X,U,2)),VISIT="9000010:"_$P(X,U,4)
 Q RESULT_U_OTHER_U_VISIT
 ;
RLVR(BQDFN) ; EP - Reliever Medications
 NEW TAX,TREF,DESC,MEET,X,RESULT,OTHER,VISIT
 I $G(UID)="" S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DESC=""
 S TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 F TAX="BAT ASTHMA SHRT ACT RELV MEDS","BAT ASTHMA SHRT ACT RELV NDC","BAT ASTHMA SHRT ACT INHLR MEDS","BAT ASTHMA SHRT ACT INHLR NDC" D BLD^BQITUTL(TAX,TREF)
 S X=$$TAX^BQITRUTL("","",1,BQDFN,9000010.14,"","",.TREF)
 ; if returns a found medication, check if it is an active medication
 I $P(X,U,1)=1 D
 . I $$ACTMED^BKMQQCR4($P(X,U,5)) Q
 . S $P(X,U,1)=0
 I $P(X,U,1)=1 S MEET=1,DESC=DESC_"On Asthma Reliever Meds ("_$$FMTE^BQIUL1($P(X,U,2))_" "_$$GET1^DIQ(9000010.14,$P(X,U,5)_",",.01,"E")_")"
 I $P(X,U,1)=0 S MEET=0,DESC=DESC_"Not on Asthma Reliever Meds"
 K @TREF
 S RESULT="N/A",OTHER="",VISIT=""
 I $$ATAG^BQITDUTL(BQDFN,"Asthma") D
 . I 'MEET S RESULT="NO" Q
 . S RESULT="YES",OTHER=$$FMTE^BQIUL1($P(X,U,2)),VISIT="9000010:"_$P(X,U,4)
 Q RESULT_U_OTHER_U_VISIT
 ;
INHST(BQDFN) ; EP - Inhaled Steroids
 NEW TAX,TREF,DESC,MEET,X,RESULT,OTHER,VISIT
 I $G(UID)="" S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DESC=""
 S TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 F TAX="BAT ASTHMA INHALED STEROIDS","BAT ASTHMA INHALED STEROIDS NDC" D BLD^BQITUTL(TAX,TREF)
 S X=$$TAX^BQITRUTL("","",1,BQDFN,9000010.14,"","",.TREF)
 ; if returns a found medication, check if it is an active medication
 I $P(X,U,1)=1 D
 . I $$ACTMED^BKMQQCR4($P(X,U,5)) Q
 . S $P(X,U,1)=0
 I $P(X,U,1)=1 S MEET=1,DESC=DESC_"On Asthma Inhaled Steroid Meds ("_$$FMTE^BQIUL1($P(X,U,2))_" "_$$GET1^DIQ(9000010.14,$P(X,U,5)_",",.01,"E")_")"
 I $P(X,U,1)=0 S MEET=0,DESC=DESC_"Not on Asthma Inhaled Steroid Meds"
 K @TREF
 S RESULT="N/A",OTHER="",VISIT=""
 I $$ATAG^BQITDUTL(BQDFN,"Asthma") D
 . I 'MEET S RESULT="NO" Q
 . S RESULT="YES",OTHER=$$FMTE^BQIUL1($P(X,U,2)),VISIT="9000010:"_$P(X,U,4)
 Q RESULT_U_OTHER_U_VISIT
 ;
ASFHX(BQDFN) ; EP - Family History of Asthma
 NEW APCHTFH,I,TLTIP
 I $$VERSION^XPDUTL("BJPC")>1.0 D FMH^APCHSAS1(BQDFN,.APCHTFH)
 I '$D(APCHTFH) Q ""
 S TLTIP="",I=0 F  S I=$O(APCHTFH(I)) Q:I=""  S TLTIP=TLTIP_$C(10)_APCHTFH(I)
 Q "YES"_U_U_TLTIP
 ;
LHOSV(BQDFN) ; EP - Last Hospital Visit
 ; TXNMY - List of taxonomies applicable to the visit
 NEW TEMP,TXNMY,IEN,VSDTM,VISIT
 S TXNMY("BGP ASTHMA DXS")=""
 D VISIT^BQIDCUTL(BQDFN,9000010.07,.TXNMY,"H","",1,.TEMP)
 S VSDTM=$O(TEMP(""),-1) I VSDTM="" Q ""
 S IEN=$O(TEMP(VSDTM,""),-1) I IEN="" Q ""
 S VISIT=TEMP(VSDTM,IEN)
 Q $$FMTE^BQIUL1(VSDTM)_U_"9000010:"_VISIT
 ;
LERUC(BQDFN) ; EP - Last ER/UC Visit
 ; TXNMY - List of taxonomies applicable to the visit
 ; CLNY  - List of locations applicable to the visit
 NEW TEMP,TXNMY,IEN,VSDTM,VISIT,CLNY
 S TXNMY("BGP ASTHMA DXS")=""
 S CLNY(30)="",CLNY(80)=""
 D VISIT^BQIDCUTL(BQDFN,9000010.07,.TXNMY,"",.CLNY,1,.TEMP)
 S VSDTM=$O(TEMP(""),-1) I VSDTM="" Q ""
 S IEN=$O(TEMP(VSDTM,""),-1) I IEN="" Q ""
 S VISIT=TEMP(VSDTM,IEN)
 Q $$FMTE^BQIUL1(VSDTM)_U_"9000010:"_VISIT
 ;
ASTRIG(BQDFN) ; EP - Asthma Triggers
 NEW ASTRIG,APCHC,APCHF,ATRDT,HIEN,VISIT,VSDTM,HFNM,VALUE,HOVER,ADATA,RESULT
 K ASTRIG
 S APCHC=$O(^AUTTHF("B","ASTHMA TRIGGERS",0))
 S APCHF="",RESULT=""
 F  S APCHF=$O(^AUTTHF("AC",APCHC,APCHF)) Q:APCHF=""  D
 . Q:'$D(^AUPNVHF("AA",BQDFN,APCHF))
 . S ATRDT=$O(^AUPNVHF("AA",BQDFN,APCHF,""))
 . S HIEN=$O(^AUPNVHF("AA",BQDFN,APCHF,ATRDT,""))
 . S VISIT=$P(^AUPNVHF(HIEN,0),U,3) I VISIT="" Q
 . S VSDTM=$P(^AUPNVSIT(VISIT,0),U,1)\1 I VSDTM=0 Q
 . S HFNM=$P(^AUTTHF(APCHF,0),U,1)
 . I HFNM["-" S HFNM=$P(HFNM,"-",2)
 . S ASTRIG(HFNM)=VSDTM_U_VISIT_U_HIEN
 ;
 S HFNM="",VALUE="",HOVER="",ADATA=""
 F  S HFNM=$O(ASTRIG(HFNM)) Q:HFNM=""  D
 . S VALUE=VALUE_HFNM_"; "
 . S HOVER=HOVER_HFNM_" ("_$$FMTE^BQIUL1($P(ASTRIG(HFNM),U,1))_"); "
 . ;S ADATA=ADATA_$P(ASTRIG(HFNM),U,1)_"|"_$P(ASTRIG(HFNM),U,2)_"; "
 S VALUE=$$TKO^BQIUL1(VALUE,"; ")
 S HOVER=$$TKO^BQIUL1(HOVER,"; ")
 S ADATA=$$TKO^BQIUL1(ADATA,"; ")
 I VALUE'="" S RESULT=VALUE_U_HOVER
 Q RESULT
 ;
TOB(BQDFN) ; EP - Last Tobacco Health Factors
 NEW ASTOB,APCHC,APCHF,ATRDT,HIEN,VISIT,VSDTM,VALUE,HOVER,HVISIT
 S APCHC=$O(^AUTTHF("B","TOBACCO",0))
 S APCHF=""
 F  S APCHF=$O(^AUTTHF("AC",APCHC,APCHF)) Q:APCHF=""  D
 . Q:'$D(^AUPNVHF("AA",BQDFN,APCHF))
 . S ATRDT=$O(^AUPNVHF("AA",BQDFN,APCHF,""))
 . S HIEN=$O(^AUPNVHF("AA",BQDFN,APCHF,ATRDT,""))
 . S VISIT=$P(^AUPNVHF(HIEN,0),U,3) I VISIT="" Q
 . S VSDTM=$P(^AUPNVSIT(VISIT,0),U,1)\1 I VSDTM=0 Q
 . S ASTOB(VSDTM,VISIT,HIEN)=$P(^AUTTHF(APCHF,0),U,1)
 ;
 S VSDTM=$O(ASTOB(""),-1),VALUE="",HOVER=""
 I VSDTM="" Q VALUE
 ;
 S VISIT=""
 F  S VISIT=$O(ASTOB(VSDTM,VISIT)) Q:VISIT=""  D
 . S HIEN=""
 . F  S HIEN=$O(ASTOB(VSDTM,VISIT,HIEN)) Q:HIEN=""  D
 .. S VALUE=VALUE_ASTOB(VSDTM,VISIT,HIEN)_"; "
 .. S HOVER=$$FMTE^BQIUL1(VSDTM),HVISIT="9000010:"_VISIT
 S VALUE=$$TKO^BQIUL1(VALUE,"; ")
 Q VALUE_U_HOVER_U_HVISIT
 ;
ASVIS(BQDFN) ; EP - Last Asthma Visit
 NEW MEAS,VALUE,VTMP,AVALUE,IEN,QFL,VISIT,DTM,CLSN,TXIEN,DATM,BQI,FREF
 NEW GREF,ENDT,RESULT,TEMP,TIEN,TXNMY,TYP,VSDTM
 ; Check for measurements
 F MEAS="ADM","ASFD" D
 . S VALUE=$$MEAS^BQIDCUTL(BQDFN,MEAS)
 . I VALUE S VTMP($P(VALUE,U,6),$P(VALUE,U,4),"V")=""
 ;
 ; Check for Asthma Triggers
 S VALUE=$$ASTRIG(BQDFN)
 I $P(VALUE,U,3)'="" D
 . F BQI=1:1 S AVALUE=$P($P(VALUE,U,3),"; ",BQI) Q:AVALUE=""  D
 .. S VTMP($P(AVALUE,"|",1),$P(AVALUE,"|",2),"V")=""
 ;
 ; Check for Asthma Patient Education
 S VALUE=$$FED^BQITRUTL("",BQDFN,"ASM-")
 I VALUE S VTMP($P(VALUE,U,2),$P(VALUE,U,4),"V")=""
 S VALUE=$$FED^BQITRUTL("",BQDFN,"493")
 I VALUE S VTMP($P(VALUE,U,2),$P(VALUE,U,4),"V")=""
 ;
 ; Check for Asthma Control
 S IEN=""
 F  S IEN=$O(^AUPNVAST("AC",BQDFN,IEN)) Q:IEN=""  D
 . I $P(^AUPNVAST(IEN,0),U,14)="" Q
 . S VISIT=$P(^AUPNVAST(IEN,0),U,3) I VISIT="" Q
 . S DTM=$P($G(^AUPNVSIT(VISIT,0)),U,1)\1 I DTM=0 Q
 . S VTMP(DTM,VISIT,"V")=""
 ;
 ; Check Problem List for addition/modification for Asthma Severity Classification
 S CLSN=$O(^APCDPLCL("B","ASTHMA SEVERITY","")) I CLSN'="" D
 . S TXIEN=$P(^APCDPLCL(CLSN,0),U,2),TXNMY($P(^ATXAX(TXIEN,0),U,1))=""
 . D PROB^BQIDCUTL(BQDFN,.TXNMY,.TEMP)
 . S DTM="",QFL=0
 . F  S DTM=$O(TEMP(DTM),-1) Q:DTM=""  D  Q:QFL
 .. S IEN=""
 .. F  S IEN=$O(TEMP(DTM,IEN),-1) Q:IEN=""  D  Q:QFL
 ... I $P(^AUPNPROB(IEN,0),U,15)="" Q
 ... S QFL=1,VTMP(DTM,IEN,"P")=""
 ;
 S DATM=$O(VTMP(""),-1)
 I DATM="" Q ""
 S IEN=$O(VTMP(DATM,""),-1),TYP=$O(VTMP(DATM,IEN,""))
 S TYP=$S("P":9000011,1:9000010)
 Q DATM_U_TYP_":"_IEN
 ;
DSP(ASDFN,ASIEN) ; EP - Display Care Mgmt field
 NEW CODE,VALUE,RESULT,ASPIEN,CRIEN,CMSN,LINK
 S CODE=$P($G(^BQI(90506.1,ASIEN,0)),U,1) I CODE="" Q ""
 S CMSN=$P($G(^BQI(90506.1,ASIEN,3)),U,1) I CMSN="" Q ""
 S CRIEN=$O(^BQIPAT(ASDFN,60,"B",CMSN,"")) I CRIEN="" Q ""
 S ASPIEN="",VALUE="",HOVER="",LINK="",RESULT=""
 F  S ASPIEN=$O(^BQIPAT(ASDFN,60,CRIEN,1,"B",CODE,ASPIEN)) Q:ASPIEN=""  D
 . S VALUE=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,2)
 . S HOVER=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,5)
 . S LINK=$P($G(^BQIPAT(ASDFN,60,CRIEN,1,ASPIEN,0)),U,4)
 ;I VALUE'="" S RESULT=VALUE_$C(26)_HOVER_$C(26)_LINK
 I VALUE'="",HOVER'="" S RESULT=VALUE_$C(26)_HOVER_$C(26)_LINK
 E  S RESULT=VALUE
 Q RESULT