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

BQIRGDMS.m

Go to the documentation of this file.
BQIRGDMS ;GDIT/HS/ALA-Diabetes Care Summary fields ; 19 Oct 2012  9:17 AM
 ;;2.4;ICARE MANAGEMENT SYSTEM;**3**;Apr 01, 2015;Build 5
 ;
DOO(DFN) ;EP
 NEW X,DOO,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S X=$$CMSFDX^BDMS9B4(DFN,"I")
 I X]"",'$D(DOO(X)) S DOO(X)="Diabetes Register"
 S DOO="" S X=$$PLDMDOO(DFN,"I")
 I X]"" S DOO(X)="Problem List"
 I $O(DOO(0))="" Q ""
 S X=$O(DOO(0)) Q $$FMTMDY^BQIUL1(X)_" ("_DOO(X)_")"
 ;
PLDMDOO(P,F) ;EP get first dm dx from case management
 I '$G(P) Q ""
 I $G(F)="" S F="E"
 NEW T S T=$O(^ATXAX("B","SURVEILLANCE DIABETES",0))
 I 'T Q ""
 NEW D,X,I S D="",X=0 F  S X=$O(^AUPNPROB("AC",P,X)) Q:X'=+X  D
 .Q:$P(^AUPNPROB(X,0),U,12)="D"
 .S I=$P(^AUPNPROB(X,0),U)
 .I $$ICD^ATXCHK(I,T,9) D
 ..I $P(^AUPNPROB(X,0),U,13)]"" S D($P(^AUPNPROB(X,0),U,13))=""
 ..Q
 .Q
 S D=$O(D(0))
 I D="" Q D
 Q $S(F="E":$$FMTE^XLFDT(D),1:D)
 ;
MSR(DFN,TYP) ;EP
 NEW BDMX,RESULT,DATE,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 D GETHWB^BDMS9B1(DFN)
 I TYP="BMI" Q $G(BDMX("BMI"))
 I TYP="HT" D  Q RESULT
 . I $G(BDMX("HT"))="" S RESULT="" Q
 . S DATE=$$DATE^BQIUL1($G(BDMX("HTD")))
 . S RESULT=BDMX("HT")_" inches ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 I TYP="WT" D  Q RESULT
 . I $G(BDMX("WT"))="" S RESULT="" Q
 . S DATE=$$DATE^BQIUL1($G(BDMX("WTD")))
 . S RESULT=BDMX("WT")_" lbs ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 I TYP="WC" D  Q RESULT
 . I $G(BDMX("WC"))="" S RESULT="" Q
 . S DATE=$$DATE^BQIUL1($G(BDMX("WCD")))
 . S RESULT=BDMX("WC")_" ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 Q ""
 ;
TOB(DFN) ;EP
 NEW BDMTOBS
 S BDMTOBS=$$TOBACCO^BDMDA1T(DFN,$$DOB^AUPNPAT(DFN),DT)
 S VAL=0
 I $P(BDMTOBS,U,1)=2 S VAL="1^YES"
 I $P(BDMTOBS,U,1)=1 S VAL="1^NO"
 Q VAL
 ;NEW GPYR,MEAS,PIEN,DEN,NUM,VAL
 ;S VAL=0
 ;S GPYR=$P($G(^BQI(90508,1,"GPRA")),U,1)
 ;S MEAS=GPYR_"_269"
 ;S PIEN=$O(^BQIPAT(DFN,30,"B",MEAS,"")) I PIEN="" Q VAL
 ;S DEN=$P($G(^BQIPAT(DFN,30,PIEN,0)),U,4)
 ;S NUM=+$P($G(^BQIPAT(DFN,30,PIEN,0)),U,3)
 ;
 ;I DEN="" Q VAL
 ;I DEN D
 ;. I 'NUM S VAL="1^NO" Q
 ;. S VAL="1^YES"
 ;Q VAL
 ;
ACE(DFN) ;EP
 NEW APCHSBEG,%,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S APCHSBEG=$$FMADD^XLFDT(DT,-(6*30.5))
 S %=$$ACE^BDMS9B4(DFN,APCHSBEG)
 I %["No" Q "1^NO"
 I %["Discontinued" Q 0
 I %["Yes" Q "1^YES"
 Q ""
 ;
ASP(DFN) ;EP
 NEW APCHSBEG,%,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S BDMSBEG=$$FMADD^XLFDT(DT,-365)
 S %=$$ASPIRIN^BDMS9B1(DFN,BDMSBEG)
 I %["No" Q "1^NO"
 I %["Discontinued" Q 0
 I %["Yes" Q "1^YES"
 Q ""
 ;
BP(DFN) ;EP
 NEW LST3,N,BDMX,VALL,BDMSDFN,BDMSPAT,DATE
 S (BDMSDFN,BDMSPAT)=DFN
 D BP^BDMS9B1(DFN)
 S LST3="",N=""
 F  S N=$O(BDMX(N)) Q:N=""  D
 . S DATE=$P(BDMX(N),U,1),VALL=$P(BDMX(N),U,2)
 . S LST3=LST3_VALL_" ("_$$FMTMDY^BQIUL1(DATE)_")"_$C(13)_$C(10)
 Q LST3
 ;
DEP(DFN) ; EP
 NEW APCHDEPP,APCHDEPS,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S APCHDEPP=$$UP^XLFSTR($$DEPPL^BDMS9B1(DFN,$$FMADD^XLFDT(DT,-(6*30.5)),DT))
 I APCHDEPP["YES" Q "1^YES (Problem List)"
 S APCHDEPS=$$UP^XLFSTR($$DEPSCR^BDMDA12(DFN,$$FMADD^XLFDT(DT,-(6*30.5)),DT))
 I APCHDEPS'["YES" Q "1^NO Screening"
 Q ""
 ;
EXM(DFN,TYP) ; EP
 NEW BDMSBEG,RES,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S BDMSBEG=$$FMADD^XLFDT(DT,-365)
 I TYP="FT" D
 . S RES=$$UP^XLFSTR($P($$DFE^BDMDA17(DFN,BDMSBEG,DT,"H"),"  ",2,99))
 I TYP="EYE" D
 . S RES=$$UP^XLFSTR($P($$EYE^BDMDA17(DFN,BDMSBEG,DT,"H"),"  ",2,99))
 I TYP="DEN" D
 . S RES=$$UP^XLFSTR($P($$DENTAL^BDMDA17(DFN,BDMSBEG,DT,"H"),"  ",2,99))
 I TYP="SMB" D
 . S RES=$$UP^XLFSTR($$SELF^APCHS9B3(DFN,BDMSBEG))
 . I RES["NO" S RES="1^NO"
 I RES="NO" Q "1^"_RES
 I RES["YES" Q "1^YES"
 Q "1^NO"
 ;
SEX(DFN,TYP) ; EP
 NEW RES,BDMSPAT,BDMSDFN,APCHSDAT
 S (BDMSDFN,BDMSPAT)=DFN
 I $P(^DPT(DFN,0),U,2)'="F" Q "N/A"
 I TYP="PAP" D
 . S RES=$$FMTMDY^BQIUL1($P($$PAP^BDMS9B4(DFN),U,1))
 I TYP="MAM" D
 . S RES=$$FMTMDY^BQIUL1($P($$LASTMAM^APCLAPI1(DFN,,,"A"),U,1))
 ;. S APCHSDAT=DT
 ;. S APCHSDAT=$P($$LASTMAM^APCLAPI1(DFN,,,"A"),U,1)
 ;. S RES=$$FMTMDY^BQIUL1(APCHSDAT)
 Q RES
 ;
DIET(DFN) ;EP
 NEW RES,BDMSDFN,BDMSPAT,DATE
 S (BDMSDFN,BDMSPAT)=DFN
 S RES=$$DIETV^BDMS9B3(DFN)
 I RES="" Q RES
 S DATE=$E(RES,1,12),DATE=$$DATE^BQIUL1(DATE)
 Q $$FMTMDY^BQIUL1(DATE)
 ;
FLU(DFN) ;EP
 NEW RES,BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 S RES=$$UP^XLFSTR($$FLU^BDMS9B3(DFN))
 I RES["NO" Q "1^NO"
 I RES["YES" Q "1^YES"
 Q "1^NO"
 ;
VAX(DFN) ;EP
 NEW BDMSPAT,RES,BX,BDMSDFN
 S (BDMSDFN,BDMSPAT)=DFN
 S RES=$$UP^XLFSTR($$PNEU^BDMS9B4(DFN))
 I RES="NO" Q RES
 I RES["YES" D  Q RES
 . S DAT1=$E(RES,6,17),DAT2=$E(RES,21,32)
 . S DAT1=$$DATE^BQIUL1(DAT1),DAT2=$$DATE^BQIUL1(DAT2)
 . S RES=$$FMTMDY^BQIUL1(DAT1)_$C(13)_$C(10)_$$FMTMDY^BQIUL1(DAT2)
 Q "NO"
 ;
TD(DFN) ;EP
 NEW RES,BDMSDFN,BDMSPAT,DATE
 S (BDMSDFN,BDMSPAT)=DFN
 S RES=$$UP^XLFSTR($$TD^BDMS9B3(DFN,(DT-100000)))
 I RES["YES" S DATE=$E(RES,6,17),DATE=$$DATE^BQIUL1(DATE),RES=$$FMTMDY^BQIUL1(DATE) Q RES
 I RES'["YES" S RES=""
 Q RES
 ;
RAD(DFN,TYP) ;EP
 NEW RES,BDMSDFN,BDMSPAT,DATE
 S (BDMSDFN,BDMSPAT)=DFN
 I TYP="EKG" D
 . S RES=$$EKG^APCHS9B7(DFN),DATE=$P(RES,U,1)
 I TYP="CHEST" D
 . S DATE=$$CHEST^BDMS9B3(DFN)
 I DATE="" Q DATE
 S DATE=$$DATE^BQIUL1(DATE)
 Q $$FMTMDY^BQIUL1(DATE)
 ;
PPDS(DFN) ;EP
 NEW BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 Q $$PPDS^BDMS9B4(DFN)
 ;
PPD(DFN) ;EP
 NEW BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 Q $$PPD^BDMS9B4(DFN)
 ;
TB(DFN) ;EP
 NEW BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 Q $$TB^BDMS9B2(BQDFN)
 ;
TBHF(DFN) ;EP
 NEW BDMSDFN,BDMSPAT
 S (BDMSDFN,BDMSPAT)=DFN
 Q $$TB^BDMS9B2(DFN)
 ;
A1C(DFN) ;EP
 NEW RES,DATE,RIEN,VISIT,RESULT
 S RES=$$HBA1C^BDMS9B2(DFN)
 I RES="||||||" Q ""
 S DATE=$P(RES,"|",4),DATE=$$DATE^BQIUL1(DATE)
 S RESULT=$P(RES,"|",1)_" ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 S RIEN=$P(RES,"|",10) I RIEN'="" S VISIT=$P($G(^AUPNVLAB(RIEN,0)),U,3),$P(RESULT,U,2)=VISIT
 Q RESULT
 ;
NA1C(DFN) ;EP
 NEW RES,DATE,RESULT
 S RES=$$NLHGB^BDMS9B2(DFN)
 I RES="" Q ""
 S DATE=$P(RES,"|",4),DATE=$$DATE^BQIUL1(DATE)
 S RESULT=$P(RES,"|",1)_" ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 Q RESULT
 ;
NEP(DFN,TYP) ;EP
 NEW RES,DATE,RESULT
 I TYP="UR" D
 . S RES=$$URIN^APCHS9B2(DFN)
 I TYP="MIC" D
 . S RES=$$MICRO^APCHS9B2(DFN)
 I TYP="RATIO" D
 . S RES=$$ACRATIO^BDMS9B2(DFN)
 I TYP="CREAT" D
 . S RES=$$CREAT^BDMS9B2(DFN)
 I TYP="GFR" D
 . S RES=$$GFR^BDMS9B2(DFN)
 I TYP="TCHOL" D
 . S RES=$$TCHOL^BDMS9B2(DFN)
 I TYP="CHOL" D
 . S RES=$$CHOL^BDMS9B2(DFN)
 I TYP="NHDL" D
 . S RES=$$NONHDL^BDMS9B2(DFN)
 I TYP="HDL" D
 . S RES=$$HDL^BDMS9B2(DFN)
 I TYP="TRIG" D
 . S RES=$$TRIG^BDMS9B2(DFN)
 I RES=""!(RES="||||||") Q ""
 S DATE=$P(RES,"|",4),DATE=$$DATE^BQIUL1(DATE)
 S RESULT=$P(RES,"|",1)_" ("_$$FMTMDY^BQIUL1(DATE)_")",$P(RESULT,U,4)=DATE
 S RIEN=$P(RES,"|",10) I RIEN'="" S VISIT=$P($G(^AUPNVLAB(RIEN,0)),U,3),$P(RESULT,U,2)=VISIT
 Q RESULT
 ;
HEPB(DFN) ;EP
 NEW RES
 S RES=$$HEP^BDMD413(DFN,DT,"","")
 I RES["No" Q "NO"
 I RES["Yes" Q "YES"
 Q ""
 ;
DIETV(P) ;EP
 ;go through all visits in AA and get last to Prov 29 or 
 NEW D,V,G,X S (D,V,G)="" F  S D=$O(^AUPNVSIT("AA",P,D)) Q:D'=+D!(G)  D
 .S V=0 F  S V=$O(^AUPNVSIT("AA",P,D,V)) Q:V'=+V!(G)  D
 ..Q:'$D(^AUPNVSIT(V,0))
 ..Q:$P(^AUPNVSIT(V,0),U,11)
 ..Q:'$P(^AUPNVSIT(V,0),U,9)
 ..Q:'$D(^AUPNVPOV("AD",V))
 ..Q:'$D(^AUPNVPRV("AD",V))
 ..Q:$$DNKA^APCHS9B4(V)
 ..Q:$$CLINIC^APCLV(V,"C")=52  ;chart review
 ..I $P(^AUPNVSIT(V,0),U,7)="C" Q  ;chart review
 ..I $$CLINIC^APCLV(V,"C")=67 S G=V Q
 ..S X=$$DIETP(V) ; is there a prov 07 or 29
 ..I X S G=V Q
 ..Q
 .Q
 I 'G Q ""
 Q $$FMTE^XLFDT($P($P(^AUPNVSIT(G,0),U),"."))_"  "_$E($$PRIMPOV^APCLV(G,"N"),1,39)
 ;
DIETP(V) ;are any providers an 07 or 29
 I '$G(V) Q ""
 NEW X,Y,Z,H
 S H="",Z=0 F  S Z=$O(^AUPNVPRV("AD",V,Z)) Q:Z'=+Z!(H)  D
 .S Y=$P(^AUPNVPRV(Z,0),U) ;provider ien
 .I Y=0 Q
 .I $P(^DD(9000010.06,.01,0),U,2)[200 S Y=$$PROVCLSC^XBFUNC1(Y) I Y=29!(Y="07") S H=1 Q
 .I $P(^DD(9000010.06,.01,0),U,2)[6 S Y=$P($G(^DIC(6,Y,0)),U,4) I Y S Y=$P($G(^DIC(7,Y,9999999)),U,1) I Y="07"!(Y=29) S H=1
 .Q
 Q H
 ;
GLS(DATA,FAKE) ;EP - BQI GET DIABETES GLOSSARY
 NEW UID,II,TRIEN,CAT,TIT,SORT,RMK,REMARK,CT,NXT,GLIEN,IEN
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIRGDMGLS",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRGDMS D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T32767REPORT_TEXT"_$C(30)
 S GLIEN=$O(^BQI(90508.2,"B","Diabetes","")) I GLIEN="" S BMXSEC="Problem with Diabetes glossary in file 90508.2" G DONE
 S IEN=0 F  S IEN=$O(^BQI(90508.2,GLIEN,1,IEN)) Q:'IEN  D
 . S II=II+1,@DATA@(II)=$G(^BQI(90508.2,GLIEN,1,IEN,0))
 I II>0 S @DATA@(II)=@DATA@(II)_$C(30)
 ;
DONE S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q