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

ADEKNT2.m

Go to the documentation of this file.
ADEKNT2 ; IHS/HQT/MJL - COMPILE DENTAL REPORTS ;   [ 04/03/2001  6:56 PM ]
 ;;6.0;ADE;**4,7,15,26**;JAN 01, 2004;Build 13
 ;;IHS/OIT/GAB 10.2014 Modified for 2015 Code Updates - PATCH 26
OBJECT ;EP
 ;Called for each patient to execute patient level counts
 ;Get dental history in ^TMP("ADEHXF",$J,CODE,DATE)=FACILITY
 N ADEHXC,ADEHXO,ADEHXF
 D GETHX^ADEGRL33(ADEDFN)
 Q:'$D(^TMP("ADEHXF",$J))
 D:ADESELOB["USER"!(ADESELOB["ALL") DUSER
 ;$O thru ^ADEKOB("AD","p",ADEIEN) - PATIENT LEVEL OBJECTIVES
 ;Quit if '$D(ADEOBJ(ADEIEN))
 ;Else execute logic in ^TMP($J,"CTR",ADEIEN,"LOGIC")
 S ADEIEN=0
 F  S ADEIEN=$O(^ADEKOB("AD","p",ADEIEN)) Q:'+ADEIEN  D
 . Q:'$D(ADEOBJ(ADEIEN))
 . ;B:ADEIEN=17!(ADEIEN=19)  ;***Before ^TMP($J,"CTR",ADEIEN,"LOGIC")
 . X ^TMP($J,"CTR",ADEIEN,"LOGIC")
 . ;B:ADEIEN=17!(ADEIEN=19)  ;***after Xecuting ^TMP($J,"CTR",ADEIEN,"LOGIC")
 Q
 ;
 ;Logic for each objective in subs below
 ;Each entry point is contained in the LOGIC field of the OBJECTIVE file
 ;
 ;ADELIM=1:Indians only, 2:Non-Indians only, 0:ALL (no limit)
 ;
NEWUSER(ADEASOF,ADELIM) ;EP
 ;Dental NEW user count (new user as of ADEASOF)
 ;ADEASOF can by "FY" or "3YR" to switch between
 ;counting fy new users and 3yr new users.
 N ADEVD,ADEK
 I ADELIM Q:'(ADELIM=ADEIND)
 ;Merge 0190 and 0000 dates
 F ADEVD="0000","0190" D
 . Q:'$D(^TMP("ADEHXF",$J,ADEVD))
 . S ADEK=0 F  S ADEK=$O(^TMP("ADEHXF",$J,ADEVD,ADEK)) Q:'+ADEK  S ADEVD(ADEK)=$P(^TMP("ADEHXF",$J,ADEVD,ADEK),U,2)
 I ADEASOF="3YR" D  Q
 . S ADEVD=$$NEWU2()
 . Q:'+ADEVD
 . Q:+ADEVD>ADEED
 . D INCREM(ADEIEN,ADEOBJ(ADEIEN),"",+ADEVD,1)
 . D INCREM(ADEIEN,ADEOBJ(ADEIEN),$P(ADEVD,U,2),+ADEVD,1)
 ;
 ;beginning Y2K fix
 ;S ADEASOF="2"_$S($E(ADEED,4,5)<10:$E(ADEED,2,3)-1,1:$E(ADEED,2,3))_"1000"
 S ADEASOF=$E($P($$FISCAL^XBDT(ADEED),U,2),1,5)_"00" ;Y2000
 ;end Y2K fix block
 S ADEVD=$O(ADEVD(ADEASOF))
 Q:'+ADEVD
 Q:+ADEVD>ADEED
 D INCREMFY(ADEIEN,ADEOBJ(ADEIEN),"",+ADEVD,1) ;No facility-level count
 Q
 ;
NEWU2() ;EP
 ;Assumes ADEVD(; returns date when pt was last new
 ;Or zero if last new was before ADE3BD
 ;2nd piece of ADEVD is facility at which pt was last new
 ;
 N ADEVD1,ADEVD2
 I '+$O(ADEVD(0)) Q 0
 I $O(ADEVD(0))>ADE3BD Q $O(ADEVD(0))
 S ADEVD=0
 S ADEVD1=$O(ADEVD(0))
 F  S ADEVD2=$O(ADEVD(ADEVD1)) Q:'+ADEVD2  D  Q:+ADEVD  Q:ADEVD="NO"
 . I ADEVD2<ADE3BD S ADEVD1=ADEVD2 Q
 . I ADEVD2>(ADEVD1+30000) S ADEVD=ADEVD2_U_$P(ADEVD(ADEVD2),U,2) Q
 . S ADEVD="NO"
 S:ADEVD="NO" ADEVD=0
 Q ADEVD
 ;
DUSER ;EP
 ;Dental Different user count - # of different people per period
 ;Get latest visit (0190 or 0000) prior to ending date ADEED
 ;
 N ADEVD,ADEIEN,K,L,ADEF
 ;
 ;First, set all-facility counter
 S ADEVD("0190")=0,ADEVD("0000")=0
 I $D(ADEHXC("0190")) S ADEVD("0190")=$O(ADEHXC("0190",ADEED+1),-1)
 I $D(ADEHXC("0000")) S ADEVD("0000")=$O(ADEHXC("0000",ADEED+1),-1)
 S ADEVD=ADEVD("0190")
 I ADEVD("0000")>ADEVD S ADEVD=ADEVD("0000")
 Q:ADEVD=0
 Q:ADEVD<ADE3BD
 S ADEVD=9999999-ADEVD
 ;F ADEIEN="DENTAL USER (ALL)",$S(ADEIND=1:"DENTAL USER (INDIAN)",1:"DENTAL USER (NON-INDIAN)") D
 F ADEIEN=6,$S(ADEIND=1:4,1:5) D
 . F K=$S(ADEVD'>ADEQBDI:1,ADEVD'>ADE1BDI:2,1:3):1:3 S $P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN)),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN)),U,K)+1
 ;
 ;
 ;Next, For each facility in ADEFAC
 F J=1:1:$L(ADEFAC,U) S ADELOE=$P(ADEFAC,U,J) D
 . K ADEF
 . S ADEVD("0190")=0,ADEVD("0000")=0
 . I $D(^TMP("ADEHXF",$J,"0190")) S L=0 F  S L=$O(^TMP("ADEHXF",$J,"0190",L)) Q:'+L  D
 . . S:$P(^TMP("ADEHXF",$J,"0190",L),U,2)=ADELOE ADEF("0190",L)=^TMP("ADEHXF",$J,"0190",L)
 . I $D(^TMP("ADEHXF",$J,"0000")) S L=0 F  S L=$O(^TMP("ADEHXF",$J,"0000",L)) Q:'+L  D
 . . S:$P(^TMP("ADEHXF",$J,"0000",L),U,2)=ADELOE ADEF("0000",L)=^TMP("ADEHXF",$J,"0000",L)
 . I $D(ADEF("0190")) S ADEVD("0190")=$O(ADEF("0190",ADEED+1),-1)
 . I $D(ADEF("0000")) S ADEVD("0000")=$O(ADEF("0000",ADEED+1),-1)
 . S ADEVD=ADEVD("0190")
 . I ADEVD("0000")>ADEVD S ADEVD=ADEVD("0000")
 . Q:'+ADEVD
 . Q:ADEVD<ADE3BD
 . S ADEVD=9999999-ADEVD
 . F ADEIEN=6,$S(ADEIND=1:4,1:5) D
 . . F K=$S(ADEVD'>ADEQBDI:1,ADEVD'>ADE1BDI:2,1:3):1:3 S $P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN),ADELOE),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN),ADELOE),U,K)+1
 . Q
 Q
 ;
COUNT(ADECOD,ADELIM)       ;EP
 ;Count PATIENTS with one of the codes in ADECOD
 ;where ADECOD is ^-delimited list of ADA codes
 ;and where code occurred on visit between ADE3BD and ADEED
 ;
 I ADELIM Q:'(ADELIM=ADEIND)
 N ADEVD,ADEC,ADED,ADELOE,ADEF
 ;First, do overall count
 S ADEC=0
 F K=1:1:$L(ADECOD,U) D  Q:ADEC
 . S ADED=$P(ADECOD,U,K)
 . Q:ADED=""
 . Q:'$D(ADEHXC(ADED))
 . S ADEVD=$O(ADEHXC(ADED,ADEED+1),-1)
 . Q:'+ADEVD
 . Q:ADEVD<ADE3BD
 . D INCREM(ADEIEN,ADEOBJ(ADEIEN),"",ADEVD,1)
 . S ADEC=1
 . Q
 ;Next, do facility count
 F J=1:1:$L(ADEFAC,U) S ADELOE=$P(ADEFAC,U,J) D
 . K ADEF
 . S ADEC=0 F  S ADEC=$O(^TMP("ADEHXF",$J,ADEC)) Q:ADEC=""  D
 . . S ADED=0 F  S ADED=$O(^TMP("ADEHXF",$J,ADEC,ADED))  Q:'+ADED  D
 . . . S:$P(^TMP("ADEHXF",$J,ADEC,ADED),U,2)=ADELOE ADEF(ADEC,ADED)=^TMP("ADEHXF",$J,ADEC,ADED)
 . . . Q
 . . Q
 . S ADEC=0
 . F K=1:1:$L(ADECOD,U) D  Q:ADEC
 . . S ADED=$P(ADECOD,U,K)
 . . Q:ADED=""
 . . Q:'$D(ADEF(ADED))
 . . S ADEVD=$O(ADEF(ADED,ADEED+1),-1)
 . . Q:'+ADEVD
 . . Q:ADEVD<ADE3BD
 . . D INCREM(ADEIEN,ADEOBJ(ADEIEN),ADELOE,ADEVD,1)
 . . S ADEC=1
 . . Q
 . Q
 Q
 ;
TOTAL(ADECOD,ADELIM)         ;EP
 ;Count Total Number of CODES ADECOD between ADEVD and ADE3BD
 N ADEVD,J,ADEF,ADED,ADELOE,K
 I ADELIM Q:'(ADELIM=ADEIND)
 Q:'$D(^TMP("ADEHXF",$J,ADECOD))
 F J=1:1:$L(ADEFAC,U) S ADELOE=$P(ADEFAC,U,J) D
 . K ADEF
 . S ADED=0 F  S ADED=$O(^TMP("ADEHXF",$J,ADECOD,ADED))  Q:'+ADED  D
 . . S:$P(^TMP("ADEHXF",$J,ADECOD,ADED),U,2)=ADELOE ADEF(ADECOD,ADED)=^TMP("ADEHXF",$J,ADECOD,ADED)
 . . Q
 . Q:'$D(ADEF(ADECOD))
 . F K="",ADELOE D
 . . S ADEVD=ADEED+1
 . . F  S ADEVD=$O(ADEF(ADECOD,ADEVD),-1) Q:'+ADEVD  Q:ADEVD<ADE3BD  D INCREM(ADEIEN,ADEOBJ(ADEIEN),K,$P(ADEVD,"."),+ADEF(ADECOD,ADEVD))
 . Q
 Q
 ;
SVC(ADELIM,ADEMIN)           ;
 ;ADEMIN=1:Count Services, 0:Count Minutes
 ; ----- BEGIN IHS MODIFICATIONS ADE*6.0*15
 ; ADEMIN=2:Count RVU's
 ; ----- END IHS MODIFICATIONS
 ;Between ADEVD and ADE3BD
 N ADECOD,J,K,ADEF
 I ADELIM Q:'(ADELIM=ADEIND)
 S ADECOD=0
 F J=1:1:$L(ADEFAC,U) S ADELOE=$P(ADEFAC,U,J) D
 . K ADEF
 . S ADEC=0 F  S ADEC=$O(^TMP("ADEHXF",$J,ADEC)) Q:ADEC=""  D
 . . S ADED=0 F  S ADED=$O(^TMP("ADEHXF",$J,ADEC,ADED))  Q:'+ADED  D
 . . . S:$P(^TMP("ADEHXF",$J,ADEC,ADED),U,2)=ADELOE ADEF(ADEC,ADED)=^TMP("ADEHXF",$J,ADEC,ADED)
 . . . Q
 . . Q
 . S ADECOD=0
 . ;B  ;New facility
 . F  S ADECOD=$O(ADEF(ADECOD)) Q:ADECOD=""  D
 . . ;IHS/OIT/GAB 10.2014 Modified below line and added the next for 2015 Code updates - PATCH #26
 . . ;Q:"0000;0190;9130;9140;9990"[ADECOD
 . . Q:"0000;0190;9130;9140;9986;9987;9990"[ADECOD
 . . Q:ADECOD?1"IH"2N
 . . N ADENOD,ADELVL
 . . S ADENOD=$O(^AUTTADA("B",ADECOD,0)) Q:'ADENOD
 . . ; ----- BEGIN IHS MODIFICATIONS ADE*6.0*15
 . . S ADERVU=$P($G(^AUTTADA(ADENOD,5)),U)
 . . ; ----- END IHS MODIFICATIONS
 . . S ADENOD=^AUTTADA(ADENOD,0)
 . . S ADELVL=$P(ADENOD,U,5)
 . . Q:ADELVL<1!(ADELVL>6)
 . . F K="",ADELOE D
 . . . S ADEVD=ADEED+1
 . . . ; ----- BEGIN IHS MODIFICATIONS ADE*6.0*15
 . . . ;F  S ADEVD=$O(ADEF(ADECOD,ADEVD),-1) Q:'+ADEVD  Q:ADEVD<ADE3BD  D INCREM(ADEIEN,ADEOBJ(ADEIEN),K,ADEVD,$S(ADEMIN:+ADEF(ADECOD,ADEVD),1:+ADEF(ADECOD,ADEVD)*$P(ADENOD,U,4)))
 . . . F  S ADEVD=$O(ADEF(ADECOD,ADEVD),-1) Q:'+ADEVD  Q:ADEVD<ADE3BD  D
 . . . . S ADEINCR=(+ADEF(ADECOD,ADEVD)*$P(ADENOD,U,4))
 . . . . S:ADEMIN=1 ADEINCR=+ADEF(ADECOD,ADEVD)
 . . . . I ADEMIN=2 D
 . . . . . S ADEINCR=(+ADEF(ADECOD,ADEVD)*ADERVU)
 . . . . . S ADEINCR=$FN(ADEINCR,"",2)
 . . . . D INCREM(ADEIEN,ADEOBJ(ADEIEN),K,ADEVD,ADEINCR)
 . . . ; ----- END IHS MODIFICATIONS
 . Q
 Q
 ;
ASSESSD ;EP
 ;Get most recent any 437 code prior to ADEED increment counter
 ;INDIANS ONLY
 Q:ADEIND'=1
 N ADECOD,ADEASD,ADELOE,J,ADEF,ADEC,ADED
 S ADEASD=0
 F ADECOD="IH70","IH71","IH72","IH73","IH74","IH75","IH76","IH77" I $D(ADEHXC(ADECOD)) D
 . S ADEVD=$O(ADEHXC(ADECOD,ADEED+1),-1)
 . S ADEVD=$P(ADEVD,".")
 . S:ADEVD>ADEASD ADEASD=ADEVD
 Q:'ADEASD
 S ADEVD=ADEASD
 I ADEVD<ADE3BDI D INCREM(ADEIEN,ADEOBJ(ADEIEN),"",ADEVD,1)
 ;
 ;Next, do facility count
 F J=1:1:$L(ADEFAC,U) S ADELOE=$P(ADEFAC,U,J) D
 . K ADEF
 . S ADEC=0 F  S ADEC=$O(^TMP("ADEHXF",$J,ADEC)) Q:ADEC=""  D
 . . S ADED=0 F  S ADED=$O(^TMP("ADEHXF",$J,ADEC,ADED))  Q:'+ADED  D
 . . . S:$P(^TMP("ADEHXF",$J,ADEC,ADED),U,2)=ADELOE ADEF(ADEC,ADED)=^TMP("ADEHXF",$J,ADEC,ADED)
 . . . Q
 . . Q
 . S ADEASD=0
 . F ADECOD="IH70","IH71","IH72","IH73","IH74","IH75","IH76","IH77" I $D(ADEF(ADECOD)) D
 . . S ADEVD=$O(ADEF(ADECOD,ADEED+1),-1)
 . . S ADEVD=$P(ADEVD,".")
 . . S:ADEVD>ADEASD ADEASD=ADEVD
 . Q:'ADEASD
 . S ADEVD=ADEASD
 . I ADEVD<ADE3BDI D INCREM(ADEIEN,ADEOBJ(ADEIEN),ADELOE,ADEVD,1)
 Q
 ;
INCREM(ADEIEN,ADEAGEG,ADELOE,ADEVD,ADEINC) ;EP
 ;Increment counter ^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN)[,ADELOE]) by ADEINC
 ;using visit date ADEVD
 N K
 S ADEVD=9999999-ADEVD
 I '+ADELOE D  Q
 . F K=$S(ADEVD'>ADEQBDI:1,ADEVD'>ADE1BDI:2,1:3):1:3 S $P(^TMP($J,"CTR",ADEIEN,ADEAGEG),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEAGEG),U,K)+ADEINC
 F K=$S(ADEVD'>ADEQBDI:1,ADEVD'>ADE1BDI:2,1:3):1:3 S $P(^TMP($J,"CTR",ADEIEN,ADEAGEG,ADELOE),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEAGEG,ADELOE),U,K)+ADEINC
 ;
 Q
 ;
INCREMFY(ADEIEN,ADEAGEG,ADELOE,ADEVD,ADEINC)       ;EP
 ;Same as increm, but use FY as beginning date and skip setting
 ;the 3-year piece
 N K
 S ADEVD=9999999-ADEVD
 I '+ADELOE D  Q
 . F K=$S(ADEVD'>ADEQBDI:1,1:2):1:2 S $P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN)),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEOBJ(ADEIEN)),U,K)+ADEINC
 F K=$S(ADEVD'>ADEQBDI:1,ADEVD'>ADE1BDI:2,1:3):1:3 S $P(^TMP($J,"CTR",ADEIEN,ADEAGEG,ADELOE),U,K)=$P(^TMP($J,"CTR",ADEIEN,ADEAGEG,ADELOE),U,K)+ADEINC
 Q