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

BQITD11.m

Go to the documentation of this file.
BQITD11 ;PRXM/HC/ALA-PreDM Metabolic Syndrome ; 10 Apr 2006  6:48 PM
 ;;2.4;ICARE MANAGEMENT SYSTEM;;Apr 01, 2015;Build 41
 Q
 ;
POP(BQARY,TGLOB) ; EP -- By population
 ;
 ;Description
 ;  Finds all patients who meet the criteria for PreDM Metabolic Syndrome
 ;Input
 ;  BQARY - Array of taxonomies and other information
 ;  TGLOB - Global where data is to be stored and passed back
 ;          to calling routine
 ;          Structure:
 ;          TGLOB(DFN,"CRITERIA",criteria or taxonomy,visit or problem ien)=date/time
 ;Variables
 ;  TAX - Taxonomy name
 ;  NIT - Number of iterations
 ;  TMFRAME - Time frame of check
 ;
 ;  Clean up all current entries
 NEW DXNN,TDFN,DA,DIK,CIRCUM
 ;
 ;  Check for 2 diagnoses ever of DX.13 or on Active Problem List
 I $D(@BQARY) D
 . S TMGLB=$NA(^TMP("BQITD11",UID))
 . D POP^BQITDGN(BQARY,TMGLB)
 ;
 ;  Check if any of the defined pre-DM patients have already been identified a diabetic
 S TXDXCN=$$GDXN^BQITUTL("Diabetes")
 S TDFN=""
 F  S TDFN=$O(@TMGLB@(TDFN)) Q:'TDFN  D
 . I '$$ATAG^BQITDUTL(TDFN,"Diabetes") M @TGLOB@(TDFN)=@TMGLB@(TDFN)
 K @TMGLB
 ;
 ;  Any three or more of the following in the past year:
 NEW TMFRAME
 S TMFRAME="T-12M",EXDT="",DTDIF=""
 S TMGLB1=$NA(^TMP("BQITD11A",UID))
 I $G(TMFRAME)'="" D
 . S ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 . S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1)
 ;
 ;  Triglyceride test value
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 S TAX="DM AUDIT TRIGLYCERIDE TAX" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="BGP TRIGLYCERIDE LOINC CODES" D BLD^BQITUTL(TAX,TREF)
 S TIEN=0 F  S TIEN=$O(@TREF@(TIEN)) Q:'TIEN  D
 . S IEN=""
 . F  S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN=""  D
 .. I $G(@GREF@(IEN,0))="" Q
 .. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
 .. I $$ATAG^BQITDUTL(DFN,"Diabetes") Q
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I RESULT'>149 Q
 .. D STOR(DFN,"Triglyceride Test Value",VISIT,IEN)
 ;
 ;  HDL test value
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 S TAX="DM AUDIT HDL TAX" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="BGP HDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
 S TIEN=0 F  S TIEN=$O(@TREF@(TIEN)) Q:'TIEN  D
 . S IEN=""
 . F  S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN=""  D
 .. I $G(@GREF@(IEN,0))="" Q
 .. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
 .. I $$ATAG^BQITDUTL(DFN,"Diabetes") Q
 .. S SEX=$$GET1^DIQ(2,DFN,.02,"I")
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I SEX="M"!(SEX="U"),RESULT<40 D STOR(DFN,"HDL Test Value",VISIT,IEN) Q
 .. I SEX="F",RESULT<50 D STOR(DFN,"HDL Test Value",VISIT,IEN)
 ;
 ;  Fasting Glucose test value
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 S TAX="DM AUDIT FASTING GLUCOSE TESTS" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="DM AUDIT FASTING GLUC LOINC" D BLD^BQITUTL(TAX,TREF)
 S TIEN=0 F  S TIEN=$O(@TREF@(TIEN)) Q:'TIEN  D
 . S IEN=""
 . F  S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN=""  D
 .. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
 .. I $$ATAG^BQITDUTL(DFN,"Diabetes") Q
 .. S SEX=$$GET1^DIQ(2,DFN,.02,"I")
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I RESULT<100!(RESULT'<126) Q
 .. D STOR(DFN,"Fasting Glucose Test Value",VISIT,IEN)
 ;
 S FREF=9000010.07,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 S TAX="BGP IMPAIRED FASTING GLUCOSE" D BLD^BQITUTL(TAX,.TREF)
 ;D BLDSV^BQITUTL(80,790.21,TREF)
 S TIEN=0 F  S TIEN=$O(@TREF@(TIEN)) Q:'TIEN  D
 . S IEN=""
 . F  S IEN=$O(@GREF@("B",TIEN,IEN),-1) Q:IEN=""  D
 .. I $G(@GREF@(IEN,0))="" Q
 .. S DFN=$$GET1^DIQ(FREF,IEN,.02,"I") Q:DFN=""
 .. I $$ATAG^BQITDUTL(DFN,"Diabetes") Q
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. D STOR(DFN,"Fasting Glucose Test Value",VISIT,IEN)
 ;
 ;  Patients diagnosed with hypertension
 S TDXN=$$GDXN^BQITUTL("Hypertension")
 S BQDREF="BQIREF" K @BQDREF
 D ARY^BQITUTL(TDXN,BQDREF)
 S $P(BQIREF(1),U,4)="T-12M",TAX=$P(BQIREF(1),U,1)
 S TMGLB2=$NA(^TMP("BQITD11B",UID)) K @TMGLB2
 D POP^BQITDGN(.BQDREF,.TMGLB2,1)
 S TDFN=""
 F  S TDFN=$O(@TMGLB2@(TDFN)) Q:TDFN=""  D
 . I $$ATAG^BQITDUTL(TDFN,"Diabetes") Q
 . I $G(@TMGLB1@(TDFN))>3 Q
 . I $D(@TMGLB1@(TDFN,"CRITERIA",TAX))>0 Q
 . S @TMGLB1@(TDFN)=$G(@TMGLB1@(TDFN))+1
 . M @TMGLB1@(TDFN)=@TMGLB2@(TDFN)
 K BQIREF
 ;
 ;  Patients with mean Blood Pressure value
 S TMPG=$NA(^TMP("BQIBP",UID)),FREF="9000010.01"
 K @TMPG
 D ABP^BQITBMI(TMFRAME,.TMPG)
 S TDFN=0
 F  S TDFN=$O(@TMPG@(TDFN)) Q:'TDFN  D
 . I $$ATAG^BQITDUTL(TDFN,"Diabetes") Q
 . S TBP=@TMPG@(TDFN)
 . S SYS=$P(TBP,U,1),DIA=$P(TBP,U,2),VISITS=$P(TBP,U,3),IIENS=$P(TBP,U,4)
 . I SYS'<130!(DIA'<85) D
 .. I '$D(@TMGLB2@(TDFN)) D STOR(TDFN,"Mean BP Value",VISITS,IIENS)
 K @TMGLB2,TMGLB2
 ;
 S TMPG=$NA(^TMP("BQIBMI",UID))
 K @TMPG
 D ABMI^BQITBMI(TMFRAME,.TMPG)
 S TDFN=0
 F  S TDFN=$O(@TMPG@(TDFN)) Q:'TDFN  D
 . I $$ATAG^BQITDUTL(TDFN,"Diabetes") Q
 . S BMI=$P(@TMPG@(TDFN),"^",1)
 . I BMI'<30 D
 .. S @TMGLB1@(TDFN)=$G(@TMGLB1@(TDFN))+1
 .. F TX="BMI-Height","BMI-Weight" S VST="" D
 ... F  S VST=$O(@TMPG@(TDFN,"CRITERIA",TX,"V",VST)) Q:VST=""  D
 .... S IEN="",FREF=9000010.01,EXDT=""
 .... F  S IEN=$O(@TMPG@(TDFN,"CRITERIA",TX,"V",VST,IEN)) Q:IEN=""  D
 ..... S VSDTM=$P(@TMPG@(TDFN,"CRITERIA",TX,"V",VST,IEN),U,1)
 ..... I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
 ..... S $P(@TMGLB1@(TDFN,"CRITERIA","BMI =>30","V",VST,IEN),U,1)=VSDTM_U_EXDT_U_IEN_U_FREF
 .. D STOR(TDFN,"BMI =>30")
 K @TMPG
 ;
 S TMPG=$NA(^TMP("BQIWST",UID))
 K @TMPG
 D AWC^BQITDWC(TMFRAME,.TMPG)
 S TDFN=0
 F  S TDFN=$O(@TMPG@(TDFN)) Q:'TDFN  D
 . I $$ATAG^BQITDUTL(TDFN,"Diabetes") Q
 . S SEX=$$GET1^DIQ(2,TDFN,.02,"I")
 . S DATE="",QFL=0
 . F  S DATE=$O(@TMPG@(TDFN,DATE),-1) Q:DATE=""  D  Q:QFL
 .. ;  check if Waist Circumference is M>40 or F>35
 .. S CIRCUM=$P(@TMPG@(TDFN,DATE),"^",1)
 .. S VISIT=$P(@TMPG@(TDFN,DATE),"^",2)
 .. S IEN=$P(@TMPG@(TDFN,DATE),"^",3)
 .. S FREF=$P(@TMPG@(TDFN,DATE),"^",4)
 .. I SEX="M",CIRCUM>40 D STOR(TDFN,"Waist Circumference",VISIT,IEN) S QFL=1 Q
 .. I SEX="F"!(SEX="U"),CIRCUM>35 D STOR(TDFN,"Waist Circumference",VISIT,IEN) S QFL=1
 K @TMPG,TMPG
 ; 
 S TDFN=""
 F  S TDFN=$O(@TMGLB1@(TDFN)) Q:TDFN=""  I @TMGLB1@(TDFN)<3 K @TMGLB1@(TDFN)
 ;
 ; Finish with all the logic and have a list of patients to file from TGLOB
 S TDFN=""
 F  S TDFN=$O(@TMGLB1@(TDFN)) Q:TDFN=""  D
 . I '$$ATAG^BQITDUTL(TDFN,"Diabetes") M @TGLOB@(TDFN)=@TMGLB1@(TDFN)
 ;
 K @TMGLB,@TMGLB1,@TREF
 K TDFN,SYS,DIA,TBP,TDXN,RESULT,VSDTM,VISIT,SEX,DFN,IEN,TIEN
 K TAX,GREF,FREF,TREF,TX,SDFN,PC,TMGLB,TMGLB1,TXDXCN,TMPG
 Q
 ;
PAT(DEF,TGLOB,PDFN) ; EP -- By patient
 ;Description
 ;  Checks if a patient meets the criteria for PreDM Metabolic Syndrome
 ;Input
 ;  BQARY - Array of taxonomies and other information
 ;  DFN   - patient internal entry number
 ;
 NEW DXOK,TMFRAME,ENDT,TMGLB1,FREF,GREF,TREF,TAX,GLOBAL,PC,IEN,TIEN,VISIT,VSDTM
 NEW SYS,DIA,TBP,SEX,BQARY,VISITS,TXDXCN,BMID,VIENS,HYOK,IIENS,BDT,EDT
 ;
 I $$ATAG^BQITDUTL(PDFN,"Diabetes") Q 0
 ;
 S BQDXN=$$GDXN^BQITUTL(DEF)
 S BQARY="BQIRY"
 D GDF^BQITUTL(BQDXN,BQARY)
 S DXOK=0
 S DXOK=$$PAT^BQITDGN(BQARY,TGLOB,PDFN) I DXOK Q DXOK
 ;
 S TMFRAME="T-12M",EXDT="",DTDIF="",BDT=$$DATE^BQIUL1(TMFRAME),EDT=DT
 S TMGLB1=$NA(^TMP("BQITD11A",UID))
 K @TMGLB1
 I $G(TMFRAME)'="" D
 . S ENDT=$$DATE^BQIUL1(TMFRAME),STDT=$$DT^XLFDT()
 . S DTDIF=$$FMDIFF^XLFDT(STDT,ENDT,1)
 ;
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
 K @TREF
 S TAX="DM AUDIT TRIGLYCERIDE TAX" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="BGP TRIGLYCERIDE LOINC CODES" D BLD^BQITUTL(TAX,TREF)
 D
 . S IEN="",QFL=0
 . F  S IEN=$O(@GREF@("AC",PDFN,IEN),-1) Q:IEN=""  D  Q:QFL
 .. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") Q:TIEN=""
 .. I '$D(@TREF@(TIEN)) Q
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I RESULT'>149 Q
 .. D STOR(PDFN,"Triglyceride Test Value",VISIT,IEN)
 .. S QFL=1
 ;
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
 K @TREF
 S TAX="DM AUDIT HDL TAX" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="BGP HDL LOINC CODES" D BLD^BQITUTL(TAX,TREF)
 D
 . S IEN="",QFL=0
 . F  S IEN=$O(@GREF@("AC",PDFN,IEN),-1) Q:IEN=""  D  Q:QFL
 .. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") Q:TIEN=""
 .. I '$D(@TREF@(TIEN)) Q
 .. S SEX=$$GET1^DIQ(2,PDFN,.02,"I")
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I SEX="M"!(SEX="U"),RESULT<40 D STOR(PDFN,"HDL Test Value",VISIT,IEN) S QFL=1 Q
 .. I SEX="F",RESULT<50 D STOR(PDFN,"HDL Test Value",VISIT,IEN) S QFL=1
 ;
 S FREF=9000010.09,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID))
 K @TREF
 S TAX="DM AUDIT FASTING GLUCOSE TESTS" D BLD^BQITUTL(TAX,TREF,"L")
 S TAX="DM AUDIT FASTING GLUC LOINC" D BLD^BQITUTL(TAX,TREF)
 D
 . S IEN="",QFL=0
 . F  S IEN=$O(@GREF@("AC",PDFN,IEN),-1) Q:IEN=""  D  Q:QFL
 .. S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") Q:TIEN=""
 .. I '$D(@TREF@(TIEN)) Q
 .. S SEX=$$GET1^DIQ(2,PDFN,.02,"I")
 .. S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 .. I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 .. S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 .. I $G(TMFRAME)'="",VSDTM<ENDT Q
 .. S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 .. I RESULT="" Q
 .. I RESULT<100!(RESULT'<126) Q
 .. D STOR(PDFN,"Fasting Glucose Test Value",VISIT,IEN)
 .. S QFL=1
 ;
 S FREF=9000010.07,GREF=$$ROOT^DILFD(FREF,"",1),TREF=$NA(^TMP("BQITAX",UID)) K @TREF
 S TAX="BGP IMPAIRED FASTING GLUCOSE" D BLD^BQITUTL(TAX,.TREF)
 ;D BLDSV^BQITUTL(80,790.21,TREF)
 S IEN="",QFL=0
 F  S IEN=$O(@GREF@("AC",PDFN,IEN),-1) Q:IEN=""  D  Q:QFL
 . S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") Q:TIEN=""
 . I '$D(@TREF@(TIEN)) Q
 . S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") Q:VISIT=""
 . I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 . S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:'VSDTM
 . I $G(TMFRAME)'="",VSDTM<ENDT Q
 . S RESULT=$$GET1^DIQ(FREF,IEN,.04,"E")
 . I RESULT="" Q
 . I RESULT<100!(RESULT'<126) Q
 . D STOR(PDFN,"Fasting Glucose Test Value",VISIT,IEN)
 . S QFL=1
 ;
 S BQDXN=$$GDXN^BQITUTL("Hypertension")
 S BQARY="BQIRY"
 D GDF^BQITUTL(BQDXN,BQARY)
 S $P(BQIRY(1),U,4)="T-12M",TAX=$P(BQIRY(1),U,1)
 S TMGLB2=$NA(^TMP("BQITD11B",UID)) K @TMGLB2
 S DXOK=0,HYOK=0
 S DXOK=$$PAT^BQITDGN(BQARY,TMGLB2,PDFN)
 I DXOK D
 . I $G(@TMGLB1@(PDFN))>3 Q
 . I $D(@TMGLB1@(PDFN,"CRITERIA",TAX))>0 Q
 . M @TMGLB1@(PDFN,"CRITERIA")=@TMGLB2@(PDFN,"CRITERIA")
 . S @TMGLB1@(PDFN)=$G(@TMGLB1@(PDFN))+1,HYOK=1,DXOK=0
 K @TMGLB2
 ;
 S FREF="9000010.01"
 S TBP=$$BP^BQITBMI(PDFN,TMFRAME)
 S SYS=$P(TBP,U,1),DIA=$P(TBP,U,2),VISITS=$P(TBP,U,3),IIENS=$P(TBP,U,4)
 I SYS'<130!(DIA'<85) I 'HYOK D STOR(PDFN,"Mean BP Value",VISITS,IIENS)
 ;
 ;S BMID=$$OBMI^BQITBMI(PDFN,TMFRAME)
 NEW BV,BMI,BMR,QFL
 S BMID=$$PBMI^APCLV(PDFN,DT)
 S BMI=$P(BMID,"^",1)
 I BMI'="" D
 . I $P(BMID,"^",3)<BDT!($P(BMID,"^",3)>EDT)!($P(BMID,"^",6)<BDT)!($P(BMID,"^",7)>EDT) S BMI="" Q
 . S VIENS=$P(BMID,"^",4)_","_$P(BMID,"^",7),IIENS=$P(BMID,"^",10)
 . I IIENS="" S QFL=0 D
 .. I $P(BMID,"^",4)=$P(BMID,"^",7) D  Q:QFL
 ... S BV=$P(BMID,"^",4),BVI="",BMR=$$FIND1^DIC(9999999.07,,"MX","BMI")
 ... F  S BVI=$O(^AUPNVMSR("AD",BV,BVI)) Q:BVI=""  I $P(^AUPNVMSR(BVI,0),"^",1)=BMR S IIENS=BVI,QFL=1
 .. S BV=$P(BMID,"^",4),BVI="",BMR=$$FIND1^DIC(9999999.07,,"MX","HEIGHT")
 .. F  S BVI=$O(^AUPNVMSR("AD",BV,BVI)) Q:BVI=""  I $P(^AUPNVMSR(BVI,0),"^",1)=BMR S IIENS=BVI_","
 .. S BV=$P(BMID,"^",7),BVI="",BMR=$$FIND1^DIC(9999999.07,,"MX","WEIGHT")
 .. F  S BVI=$O(^AUPNVMSR("AD",BV,BVI)) Q:BVI=""  I $P(^AUPNVMSR(BVI,0),"^",1)=BMR S IIENS=IIENS_BVI
 I BMI'<30 D STOR(PDFN,"BMI =>30",VIENS,IIENS)
 ;
 NEW VALUE
 S VALUE=$$WC^BQITDWC(PDFN,TMFRAME)
 S CIRCUM=$P(VALUE,U,1),VISIT=$P(VALUE,U,2),IEN=$P(VALUE,U,3)
 S SEX=$$GET1^DIQ(2,PDFN,.02,"I")
 I SEX="M",CIRCUM>40 I '$D(@TMGLB1@(PDFN,"CRITERIA","BMI =>30")) D STOR(PDFN,"Waist Circumference",VISIT,IEN)
 I SEX="F"!(SEX="U"),CIRCUM>35 I '$D(@TMGLB1@(PDFN,"CRITERIA","BMI =>30")) D STOR(PDFN,"Waist Circumference",VISIT,IEN)
 ;
 I $G(@TMGLB1@(PDFN))<3 S DXOK=$S(DXOK=1:1,1:0)
 I $G(@TMGLB1@(PDFN))'<3 S DXOK=1
 ;
 I DXOK M @TGLOB@(PDFN)=@TMGLB1@(PDFN)
 K @TMGLB1
 Q DXOK
 ;
STOR(SDFN,CRIT,VIENS,IENS) ;  Store the patient's met criteria
 NEW VST,I,VSDTM,IIEN
 I $G(@TMGLB1@(SDFN))>3 Q
 ;I $D(@TMGLB1@(SDFN,"CRITERIA",CRIT))>0 Q
 S @TMGLB1@(SDFN)=$G(@TMGLB1@(SDFN))+1
 S @TMGLB1@(SDFN,"CRITERIA",CRIT)=""
 I $G(VIENS)["," D  Q
 . F I=1:1 S VST=$P(VIENS,",",I) Q:VST=""  D
 .. I IENS["," S IIEN=$P(IENS,",",I)
 .. I IENS'["," S IIEN=IENS
 .. S VSDTM=$$GET1^DIQ(9000010,VST_",",.01,"I") Q:'VSDTM
 .. I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
 .. S @TMGLB1@(SDFN,"CRITERIA",CRIT,"V",VST,IIEN)=VSDTM_U_U_IIEN_U_FREF
 .. I EXDT'="" S $P(@TMGLB1@(SDFN,"CRITERIA",CRIT,"V",VST,IIEN),U,2)=EXDT
 I $G(VIENS)'="" D
 . S VSDTM=$$GET1^DIQ(9000010,VIENS_",",.01,"I") Q:'VSDTM
 . I DTDIF'="" S EXDT=$$FMADD^XLFDT(VSDTM,DTDIF)
 . S @TMGLB1@(SDFN,"CRITERIA",CRIT,"V",VIENS,IENS)=VSDTM_U_U_IENS_U_FREF
 . I EXDT'="" S $P(@TMGLB1@(SDFN,"CRITERIA",CRIT,"V",VIENS,IENS),U,2)=EXDT
 Q