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

BDMVRL41.m

Go to the documentation of this file.
BDMVRL41 ; IHS/CMI/LAB - VIEW PT RECORD CON'T ; 09 Feb 2010  7:42 AM
 ;;2.0;DIABETES MANAGEMENT SYSTEM;**2,3,4,5,6,7,8,9,10,11,12**;JUN 14, 2007;Build 51
 ;
 ;MOVED VARIOUS SUBROUTINES TO BDMVRL42 TO CONTROL ROUTINE SIZE
 ;
IEN ;EP;DETERMINE IEN ARRAY DEPENDING ON TYPE OF FOLLOW-UP BEING DONE
 K BDM("IEN")
 D @BDMFU
 Q
RADIEN ;RADIOLOGY IEN
MAM S BDM("FOLLOW-UP TYPE")="MAMMOGRAM"
 F Z="BILA","DIAGNOSTI","SCREENIN","UNILA" D
 .S XX="MAMMOGRAM "_Z
 .S X=XX
 .F  S X=$O(^RAMIS(71,"B",X)) Q:X=""!(X'[XX)  D
 ..S Y=0
 ..F  S Y=$O(^RAMIS(71,"B",X,Y)) Q:'Y  S BDM("IEN",Y)=""
 Q
LABIEN ;LAB IENS
 N X,Y,Z,XX
PAP S Z="PAP SMEAR"
 S BDM("FOLLOW-UP TYPE")="PAP SMEAR"
 S (X,XX)="PAP SMEA"
 F  S X=$O(^LAB(60,"B",X)) Q:X=""!(X'[XX)  D
 .S Y=$O(^LAB(60,"B",X,0))
 .S:Y BDM("IEN",Y)=""
 Q
CHOL S BDM("FOLLOW-UP TYPE")="CHOLESTEROL"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT CHOLESTEROL TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
LDL S BDM("FOLLOW-UP TYPE")="LDL"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT LDL CHOLESTEROL TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
HDL S BDM("FOLLOW-UP TYPE")="HDL"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT HDL TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
TRIG S BDM("FOLLOW-UP TYPE")="TRIGLYCERIDE"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT TRIGLYCERIDE TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
CREA S BDM("FOLLOW-UP TYPE")="CREATININE"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT CREATININE TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
HGB S BDM("FOLLOW-UP TYPE")="HGB A1C"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT HGB A1C TAX",0))
 S X2=-150
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
LIVR S BDM("FOLLOW-UP TYPE")="SGOT/SGPT"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT LIVER FUNCTION TAX",0))
 S BDM("LIVER MEDS TAX")=$O(^ATXAX("B","DM AUDIT LIVER MEDS",0))
 S X2=-90
 F XX="SGO","SGP" D
 .S X=XX
 .F  S X=$O(^LAB(60,"B",X)) Q:X=""!(X'[XX)  D
 ..S Y=$O(^LAB(60,"B",X,0))
 ..S:Y BDM("IEN",Y)=""
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
UPRO S BDM("FOLLOW-UP TYPE")="MICROALBUMIN"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT URINE PROTEIN TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
URIN S BDM("FOLLOW-UP TYPE")="UA/Urine Protein"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT URINALYSIS TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT URINE PROTEIN TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
GFR S BDM("FOLLOW-UP TYPE")="ESTIMATED GFR"
 S BDMTAX=$O(^ATXLAB("B","BGP GPRA ESTIMATED GFR TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
UACR S BDM("FOLLOW-UP TYPE")="A/C RATIO"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT QUANT UACR",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
UPT S BDM("FOLLOW-UP TYPE")="URINE PROTEIN TESTING"
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT QUANT UACR",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  D
 .S BDM("IEN",X)=""
 Q
EKG S BDM("FOLLOW-UP TYPE")="EKG"
 Q
EXAMIEN ;EXAM IENS
 N X,Y,Z
DENT ;EP;USE V EXAM INSTEAD OF V DENTAL
 S BDM("FOLLOW-UP TYPE")="DENTAL EXAM"
 S X=$O(^AUTTEXAM("C","30",0))
 S:X BDM("IEN",X)=""
 Q
RECT S Z="RECTAL EXAM"
 D EXAM
 Q
BRST F Z="BREAST EXAM","CLINICAL BREAST EXAM" D
 .D EXAM
 Q
FTEX S Z="FOOT EXAM"
 D EXAM
 Q
EYE S Z="EYE EXAM"
 D EXAM
 Q
DEP ;
 S Z="DEPRESSION SCR"
 D EXAM
 Q
EXAM S X=""
 F  S X=$O(^AUTTEXAM("B",X)) Q:X=""  D:X[Z
 .S Y=$O(^AUTTEXAM("B",X,0))
 .S:Y BDM("IEN",Y)=""
 S BDM("FOLLOW-UP TYPE")=Z
 Q
IMMIEN ;IMMUNIZATIONS IENS
 N X,Y
FLU S (Z,BDM("FOLLOW-UP TYPE"))="INFLUENZA"
 D IMM
 Q
PNEU S (Z,BDM("FOLLOW-UP TYPE"))="PNEUMO"
 S X2=-2160
 D IMM
 Q
HEPC S (Z,BDM("FOLLOW-UP TYPE"))="HEP C SCREEN"
 S X2=-2160
 Q
HEPB S (Z,BDM("FOLLOW-UP TYPE"))="HEPB"
 Q
TD S BDM("FOLLOW-UP TYPE")="TD",Z="TETANUS"
 S X2=-3620
 D IMM
 Q
IMM S X=""
 F  S X=$O(^AUTTIMM("B",X)) Q:X=""  D:X[Z
 .S Y=0
 .F  S Y=$O(^AUTTIMM("B",X,Y)) Q:'Y  S BDM("IEN",Y)=""
 Q
HEPA ;EP
 S BDM("FOLLOW-UP TYPE")="HEPB",Z="HEPB"
 D IMM
 Q
SKINIEN ;SKIN TESTS IENS
 N X,Y
PPD S (Z,BDM("FOLLOW-UP TYPE"))="PPD"
 S X=""
 F  S X=$O(^AUTTSK("B",X)) Q:X=""  D:X[Z
 .S Y=0
 .F  S Y=$O(^AUTTSK("B",X,Y)) Q:'Y  S BDM("IEN",Y)=""
 Q
EDIEN ;FIND EDUCATION TOPIC IENS
NTED S (Z,BDM("FOLLOW-UP TYPE"))="NUTRITION"
 D ED
 Q
COMP S (Z,BDM("FOLLOW-UP TYPE"))="COMPLICATIONS"
 D ED
 Q
DIET S (Z,BDM("FOLLOW-UP TYPE"))="DIET"
 D ED
 Q
DISE S (Z,BDM("FOLLOW-UP TYPE"))="DISEASE PROCESS"
 D ED
 Q
EXER S (Z,BDM("FOLLOW-UP TYPE"))="PHYSICAL ACTIVITY"
 D ED
 Q
GENI S (Z,BDM("FOLLOW-UP TYPE"))="GENERAL INFORMATION"
 D ED
 Q
LIFE S (Z,BDM("FOLLOW-UP TYPE"))="LIFESYLE CHANGES"
 D ED
 Q
MEDS S (Z,BDM("FOLLOW-UP TYPE"))="MEDICATIONS"
 D ED
 Q
FUP S (Z,BDM("FOLLOW-UP TYPE"))="FOLLOW-UP PROCEDURES"
 D ED
 Q
FTED S (Z,BDM("FOLLOW-UP TYPE"))="FOOT CARE"
 D ED
 Q
ED S X=$O(^AUTTEDT("B",("DM-"_Z),0))
 Q:'X
 S BDM("IEN",X)=""
 I BDMFU'="NTED",BDMFU'="EXER" F X=1:1:9 S:X'=4 BDM("IEN",X)=""
 Q
HTN ;EP;HYPERTENSION FU
 K BDMHTN,BDM("IEN")
 D HTN1
 Q:'$D(BDMHTN)
 K BDMMEDS
 D HTNMEDS
 I $D(BDMMEDS) K BDMMEDS Q
 S BDM("FOLLOW-UP TYPE")="HYPERTENSION"
 S X="Possible HTN, NO ACE-I or ARB"
 D FUOUT^BDMVRL4
 Q
HTN1 S BDMTAX=$O(^ATXLAB("B","DM AUDIT URINE PROTEIN TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  S BDM("IEN",X)=""
 S BDMTAX=$O(^ATXLAB("B","DM AUDIT URINALYSIS TAX",0))
 S X=0
 F  S X=$O(^ATXLAB(+BDMTAX,21,"B",X)) Q:X=""  S BDM("IEN",X)=""
 F X=1665044,9999382,9999383,9999570 S BDM("IEN",X)=""
 S X=0
 F  S X=$O(BDM("IEN",X)) Q:'X  D
 .S Y=0
 .F  S Y=$O(^AUPNVLAB("AA",DFN,X,Y)) Q:'Y  D
 ..S Z=0
 ..F  S Z=$O(^AUPNVLAB("AA",DFN,X,Y,Z)) Q:'Z  D
 ...I $P($G(^AUPNVLAB(Z,0)),U,4)>$P($G(^AUPNVLAB(Z,11)),U,5) S BDMHTN=""
 Q:$D(BDMHTN)
HTNMEDS ;CHECK FOR HTN MEDS
 K BDM("IEN")
 S BDMTAX=$O(^ATXAX("B","DM AUDIT ACE INHIBITORS",0))
 Q:'BDMTAX
 S X=0
 F  S X=$O(^ATXAX(+BDMTAX,21,"B",X)) Q:X=""  S BDM("IEN",X)=""
 S Y=$O(^PS(50.605,"B","CV805",0))
 Q:'Y
 S X=0
 F  S X=$O(^PSDRUG("VAC",Y,X)) Q:'X  S BDM("IEN",X)=""
 S X=0
 F  S X=$O(^AUPNVMED("AA",DFN,X)) Q:'X  D
 .S Y=0
 .F  S Y=$O(^AUPNVMED("AA",DFN,X,Y)) Q:'Y!$D(BDMMEDS)  S:$D(BDM("IEN",+$G(^AUPNVMED(Y,0)))) BDMMEDS=""
 Q
LPAP ;EP;LAST PAP
 S BDM("FOLLOW-UP TYPE")="PAP SMEAR"
 S Z=9999999-$$LASTPAP^BDMLPM(DFN)
 I $$HYSTER^BDMLPM(DFN) S Z=9999999-DT
 D X2
 Q
LMAM ;EP;LAST MAMM
 S BDM("FOLLOW-UP TYPE")="MAMMOGRAM"
 S Z=9999999-$$LASTMAM^BDMLPM(DFN)
 I $$MAS^BDMLPM(DFN) S Z=9999999-DT
 D X2
 Q
APCLEXAM ;EP;LAST EXAM
 ; FOR EACH OF THESE Z WILL BE RETURNED AS THE DATE OF THE LAST OR NULL IF NONE
 I BDMFU="FTEX" D
 .S BDM("FOLLOW-UP TYPE")="FOOT EXAM"
 .S Z=$$DFE^BDMDG17(DFN,"","","D",1)
 I BDMFU="EYE" D
 .S BDM("FOLLOW-UP TYPE")="EYE EXAM"
 .S Z=$P($$EYE^BDMDG17(DFN,"","","D",1),U,1)
 I BDMFU="DENT" D
 .S BDM("FOLLOW-UP TYPE")="DENTAL EXAM"
 .S Z=$$DENTAL^BDMDG17(DFN,"","","D",1)
 I BDMFU="DEP" D
 .S BDM("FOLLOW-UP TYPE")="DEPRESSION SCR"
 .S Z=$$DEPSCR^BDMDG12(DFN,"","","D",1)
 ;I BDMFU="EKG" D
 ;.S BDM("FOLLOW-UP TYPE")="EKG"
 ;.S Z=$$EKG^BDMDG12(DFN,DT,"D")
 I Z="" D FUNO^BDMVRL4 Q  ;no test ever
 S Z=9999999-Z
X2 ;
 I Z=9999999 D FUNO^BDMVRL4 Q
 ;I $$FMDIFF^XLFDT(DT,Z)<330 D EDONE^BDMVRL4 Q  ;no need, is current
 K X2
 I BDMFU="EKG" S X2=-1795
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q
APCLED ;EP;LAST MAMM
 I BDMFU="NTED" D
 .S BDM("FOLLOW-UP TYPE")="NUTRITION ED"
 .S Z=$$DIETEDUC^BDMLPM(DFN,$$FMADD^XLFDT(DT,-(5*365)),DT)
 I BDMFU="EXER" D
 .S BDM("FOLLOW-UP TYPE")="PHYSICAL ACTIVITY ED"
 .S Z=$$EXEDUC^BDMLPM(DFN,$$FMADD^XLFDT(DT,-(5*365)),DT)
 I BDMFU="GENI" D
 .S BDM("FOLLOW-UP TYPE")="OTHER ED"
 .S Z=$$OTHEDUC^BDMLPM(DFN,$$FMADD^XLFDT(DT,-(5*365)),DT)
 I Z="" D FUNO^BDMVRL4 Q
 S Z=$P(Z,".")
 K X2
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q
FLUC ;EP
 S (Z,BDM("FOLLOW-UP TYPE"))="INFLUENZA"
 S Z=$$FLU^BDMDG13(DFN,$$DOB^AUPNPAT(DFN),DT,1,"D")
 I Z="" D FUNO^BDMVRL4 Q
 S Z=9999999-Z
 K X2
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q
HEPBC ;EP
 S (Z,BDM("FOLLOW-UP TYPE"))="HEP B"
 S Z=$$HEP^BDMDG13(DFN,DT,1,"D")
 I Z="" D FUNO^BDMVRL4 Q
 ;S Z=9999999-Z
 I $E(Z)=1 Q
 I $E(Z)=3 Q  ;IMMUNE
 S Z=9999999-Z
 S X2=20
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q
PNEUMOC ;EP
 S (Z,BDM("FOLLOW-UP TYPE"))="PNEUMO"
 S Z=$$PNEU^BDMDG13(DFN,DT,1,"D")
 I Z="" D FUNO^BDMVRL4 Q
 S Z=9999999-Z
 K X2
 S X2=$$FMDIFF^XLFDT($$DOB^AUPNPAT(DFN),DT)
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q
HEPCC ;EP
 S (Z,BDM("FOLLOW-UP TYPE"))="HEP C SCREENING"
 S Z=$$HEPSCR^BDMDG1D(DFN,DT)
 I $E(Z,1)=3!($E(Z)=1)!(Z="") S Z="" D EDONE^BDMVRL4 Q
 I $E(Z)=2 D FUNO^BDMVRL4 Q
 Q
TDC ;EP
 S BDM("FOLLOW-UP TYPE")="TD",Z="TETANUS"
 S Z=$$TD^BDMVRL7(DFN,DT)
 I Z="" D FUNO^BDMVRL4 Q
 S Z=9999999-Z
 K X2
 S X2=-(10*365)
 D FULAST^BDMVRL4
 D ENTRY^BDMVRL4
 Q