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

ACHSGAO.m

Go to the documentation of this file.
ACHSGAO ; IHS/OIT/FCJ -version 2-GAO REPORT-DENIAL AND DEF LIST BY ISSUE DATE ; 30 Jul 2010  10:39 AM
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;**18,19,23**;JUNE 11, 2001;Build 43
 ;;
ST ;
 K X2,X3
 I '$D(DUZ(2)) W !,"DUZ(2) Must be set" Q
 D ^ACHSVAR
 K ^XTMP("ACHSGAO",$J)
 ;SELECT FAC
 D SEL Q:Y<0
 ;
BDT ; --- Beginning date
 S ACHSBDT=$$DATE^ACHS("B","GAO UNMET NEED-DENIED SERVICES")
 Q:$D(DUOUT)!(Y="")
 G:ACHSBDT<1 EXT
 ;
EDT ; --- Ending date
 S ACHSEDT=$$DATE^ACHS("E","GAO UNMET NEED-DENIED SERVICES")
 G:ACHSEDT<1 BDT
 I $$EBB^ACHS(ACHSBDT,ACHSEDT) G BDT
 ;
A1 ;
 S ACHSXHRN=0,ACHSIEN=0,ACHSCNT=0,ACHSDCT=0,ACHSLN=0
 S Y=ACHSBDT X ^DD("DD") S ACHS("BDT")=Y,Y=ACHSEDT X ^DD("DD") S ACHS("EDT")=Y
 S ACHST1=$$C^XBFUNC($S(ACHSBDT=1:"***   ALL UNMET NEED AND DENIED SERVICES   ***",1:"For the period "_ACHS("BDT")_" through "_ACHS("EDT")),80)
 D BRPT^ACHSFU
 D HDR
 D LP1
 D LP2
 D SAV
 D EXT
 Q
SEL ;SELECT FACILITY
 S ACHSFAC="",DIC(0)="AE",DIC="^ACHSDEN("
 D ^DIC
 Q:Y<0
 S ACHSFAC=+Y,ACHSFACN=$P(^AUTTLOC(ACHSFAC,0),U,10)
 Q
LP1 ; DENIALS
 W !!,"Denials"
 S ACHSISU=ACHSBDT-1
 F  S ACHSISU=$O(^ACHSDEN(ACHSFAC,"D","AISSUE",ACHSISU)) Q:+ACHSISU=0!(ACHSISU>ACHSEDT)  D
 .S DA="" F  S DA=$O(^ACHSDEN(ACHSFAC,"D","AISSUE",ACHSISU,DA)) Q:DA=""  D  Q:$D(DUOUT)!$D(DTOUT)
 ..S ACHS(0)=$G(^ACHSDEN(ACHSFAC,"D",DA,0))
 ..S (ACHSDTYP,ACHSREG,ACHSPTID,ACHSISDT,ACHSRDT,ACHSMDT,ACHSPRI,ACHSPDT,ACHSPRTY,ACHSSTYP)="",ACHS("$")=0
 ..Q:ACHS(0)=""
 ..Q:$P(ACHS(0),U,8)="Y"  ; CANCELLED REQUEST
 ..I $P(ACHS(0),U,6)="N" Q:$P($G(^ACHSDEN(ACHSFAC,"D",DA,10)),U)=""  S ACHSXHRN=ACHSXHRN+1,ACHSPTID=ACHSFACN_"X"_$E(100000+ACHSXHRN,2,7),ACHSREG=0
 ..I $P(ACHS(0),U,6)="Y" Q:$P(ACHS(0),U,7)=""  S ACHSHRN=$$HRN^ACHS($P(ACHS(0),U,7),ACHSFAC),ACHSPTID=ACHSFACN_$E(1000000+ACHSHRN,2,7),ACHSREG=1
 ..Q:ACHSPTID=""
 ..W "." S ACHSCNT=ACHSCNT+1
 ..S Y=ACHSISU X ^DD("DD") S ACHSISDT=Y
 ..;IF DENIAL IN RCIS THEN SET THE ACHSRDT REF DT AND THE ACHSMDT MANAGED CARE DATE
 ..S ACHSREF="",ACHSREF=$O(^BMCREF("CD",$P(ACHS(0),U),ACHSREF))
 ..I ACHSREF D
 ...S Y=$P(^BMCREF(ACHSREF,0),U) X ^DD("DD") S ACHSRDT=Y
 ...S Y=$P($G(^BMCREF(ACHSREF,11)),U,24) I Y X ^DD("DD") S ACHSMDT=Y
 ...;IF PO IN RCIS THEN SET THE PAID DATE OF THE FIRST PO  ACHSPDT-FINAL PAY DATE OR FINAL INTERIUM PAY
 ...I $D(^BMCREF(ACHSREF,41)) S ACHSDFN=0 F  S ACHSDFN=$O(^BMCREF(ACHSREF,41,ACHSDFN)) Q:ACHSDFN'?1N.N  D  Q:ACHSPDT
 ....I $D(^ACHSF(ACHSFAC,"D",ACHSDFN,"PA")) S ACHSPTY="" D PDT
 ..S ACHSPRI=$P($G(^ACHSMPRI($P($G(^ACHSDEN(ACHSFAC,"D",DA,400)),U,2),0)),U)
 ..I $P($G(^ACHSDEN(ACHSFAC,"D",DA,100)),U)="Y" S (ACHS,ACHS1)="" D
 ...S ACHS=$P($G(^ACHSDEN(ACHSFAC,"D",DA,100)),U,2)
 ...Q:ACHS=""  S ACHS1=$P($G(^AUTTVNDR(ACHS,11)),U,3)
 ...I ACHS1 S ACHSPRTY=$P(^AUTTVTYP(ACHS1,0),U,2)
 ..S ACHS("$")=$S(+$P(^ACHSDEN(ACHSFAC,"D",DA,100),U,9):+$P(^(100),U,9),1:+$P(^(100),U,8))
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,200)) F DA(1)=0:0 S DA(1)=$O(^ACHSDEN(ACHSFAC,"D",DA,200,DA(1))) Q:'DA(1)  I $D(^(DA(1),0)) S ACHS("$")=ACHS("$")+$S(+$P(^(0),U,3):$P(^(0),U,3),1:+$P(^(0),U,2))
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,210)) F DA(1)=0:0 S DA(1)=$O(^ACHSDEN(ACHSFAC,"D",DA,210,DA(1))) Q:'DA(1)  I $D(^(DA(1),0)) S ACHS("$")=ACHS("$")+$S(+$P(^(0),U,7):+$P(^(0),U,7),1:+$P(^(0),U,6))
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,250)) S ACHSREA=$P($G(^ACHSDENS($P(^ACHSDEN(ACHSFAC,"D",DA,250),U),0)),U)
 ..;DECISION-TEST $P(ACHS(0),U,8)="R" DEFAULT DENINED IF SET THEN REVERSED
 ..S ACHSDEC=$S($P(ACHS(0),U,8):"REVERSED",1:"DENINED")
 ..;ACHSSTYP-TYPE OF SERVICE ACHSDTYP=SERVICES TYPE
 ..S X="",X=$P($G(^ACHSDEN(ACHSFAC,"D",DA,100)),U,10) S ACHSSTYP=$S(X="I":"INPATIENT",X="O":"OUTPATIENT",X="A":"AMBULANCE","P":"PATIENT ESCORT","D":"DENTAL",1:"")
 ..S X="",X=$P($G(^ACHSDEN(ACHSFAC,"D",DA,400)),U) S ACHSDTYP=$S(X="N":"NOT DEFERRED",X="S":"SURGICAL",X="E":"EVALUATION/DIAG",X="D":"DENTAL",X="M":"MENTAL HEALTH",X="C":"COSMETIC SURGERY",X="O":"OPHTHALMOLOGY",1:"")
 ..S (LN2,LN3)="",LN2=ACHSSTYP_"^"_ACHSDTYP_"^"
 ..;ICD AND CPT DATA
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,500)) S X=0 F  S X=$O(^ACHSDEN(ACHSFAC,"D",DA,500,X)) Q:X'?1N.N  D
 ...;S LN2="^"_$P(^ICD9($P(^ACHSDEN(ACHSFAC,"D",DA,500,X,0),U),0),U)  ;ACHS*3.1*23
 ...S LN2="^"_$P($$ICDDX^ICDEX($P(^ACHSDEN(ACHSFAC,"D",DA,500,X,0),U),,,"I"),2)  ;ACHS*3.1*23
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,700)) S X=0 F  S X=$O(^ACHSDEN(ACHSFAC,"D",DA,700,X)) Q:X'?1N.N  D
 ...;S LN3=$P(^ICPT($P(^ACHSDEN(ACHSFAC,"D",DA,700,X,0),U),0),U)_"^"  ;ACHS*3.1*23
 ...S LN3=$P($$CPT^ICPTCOD($P(^ACHSDEN(ACHSFAC,"D",DA,700,X,0),U)),U,2)_"^"  ;ACHS*3.1*23
 ..D XTMP
 ..;APPEALS 430 AND 431 IS THE MULTIPLE
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,431)) S X=0 F  S X=$O(^ACHSDEN(ACHSFAC,"D",DA,431,X)) Q:X'?1N.N  D
 ...S ACHSAPST="",ACHSAP="",ACHSAPST=$P(^ACHSDEN(ACHSFAC,"D",DA,431,X,0),U,2)
 ...Q:ACHSAPST=""
 ...I ACHSAPST,$D(^ACHSDENA(ACHSAPST)) S ACHSAP=$P(^ACHSDENA(ACHSAPST,0),U)
 ...S ACHSIEN=ACHSIEN+1
 ...S ^XTMP($J,"ACHSGAO",ACHSIEN)=ACHSLN_"D^"_ACHSAP_"^"_$P(^ACHSDEN(ACHSFAC,"D",DA,431,X,0),U,5)
 ..;COMMENTS FIELD 900 WORD
 ..I $D(^ACHSDEN(ACHSFAC,"D",DA,900)) S X=0 F  S X=$O(^ACHSDEN(ACHSFAC,"D",DA,900,X)) Q:X'?1N.N  D
 ...S ACHSIEN=ACHSIEN+1
 ...S ^XTMP("ACHSGAO",$J,ACHSIEN)=ACHSLN_"E^"_^ACHSDEN(ACHSFAC,"D",DA,900,X,0)
 Q
LP2 ;UNMET NEED (DEFERRALS)
 K DUOUT,DTOUT
 W !,"Unmet Need Services"
 S ACHSISU=ACHSBDT-1
 F  S ACHSISU=$O(^ACHSDEF(ACHSFAC,"D","AISSUE",ACHSISU)) Q:+ACHSISU=0!(ACHSISU>ACHSEDT)  D
 .S DA="" F  S DA=$O(^ACHSDEF(ACHSFAC,"D","AISSUE",ACHSISU,DA)) Q:DA=""  D  Q:$D(DUOUT)!$D(DTOUT)
 ..S ACHS(0)=$G(^ACHSDEF(ACHSFAC,"D",DA,0))
 ..S (ACHSDTYP,ACHSREG,ACHSPTID,ACHSISDT,ACHSRDT,ACHSMDT,ACHSPRI,ACHSPDT,ACHSPRTY,ACHSSTYP,ACHSCAT,ACHSPO)="",ACHS("$")=0
 ..Q:ACHS(0)=""
 ..Q:$P(ACHS(0),U,8)="Y"  ; CANCELLED REQUEST
 ..I $P(ACHS(0),U,5)="N" Q:$P(ACHS(0),U,7)=""  S ACHSXHRN=ACHSXHRN+1,ACHSPTID=ACHSFACN_"X"_$E(100000+ACHSXHRN,2,7),ACHSREG=0
 ..I $P(ACHS(0),U,5)="Y" Q:$P(ACHS(0),U,6)=""  S ACHSHRN=$$HRN^ACHS($P(ACHS(0),U,6),ACHSFAC),ACHSPTID=ACHSFACN_$E(1000000+ACHSHRN,2,7),ACHSREG=1
 ..Q:ACHSPTID=""
 ..W "." S ACHSDCT=ACHSDCT+1
 ..S Y=ACHSISU X ^DD("DD") S ACHSISDT=Y
 ..;PO SET IF PAID
 ..S ACHSPO=$P($G(^ACHSDEF(ACHSFAC,"D",DA,500)),U,8) I ACHSPO D
 ...S ACHSPO=1_$E(ACHSPO,2)_$E(ACHSPO,8,12) S ACHSDFN="",ACHSDFN=$O(^ACHSF(ACHSFAC,"D","B",ACHSPO,0))
 ...Q:'ACHSDFN
 ...I $D(^ACHSF(ACHSFAC,"D",ACHSDFN,"PA")) S ACHSPTY="" D PDT
 ..S ACHS("$")=$P($G(^ACHSDEF(ACHSFAC,"D",DA,100)),U,5)
 ..S ACHSREA="UNMET NEED",ACHSDEC="DEFFERED"
 ..;ACHSSTYP-TYPE OF SERVICE ACHSDTYP=SERVICES TYPE
 ..S X="",X=$P($G(^ACHSDEF(ACHSFAC,"D",DA,100)),U,2) S ACHSSTYP=$S(X="I":"INPATIENT",X="O":"OUTPATIENT",1:"")
 ..S X="",X=$P($G(^ACHSDEF(ACHSFAC,"D",DA,100)),U) I X S ACHSDTYP=$P(^ACHSDFC(X,0),U)
 ..S X1="",X1=$P($G(^ACHSDEF(ACHSFAC,"D",DA,100)),U,4) I X1 S ACHSCAT=$P(^ACHSDFC(X,1,X1,0),U)
 ..S (LN2,LN3)="",LN2=ACHSSTYP_"^"_ACHSDTYP_"^"_ACHSCAT
 ..;ICD AND CPT DATA
 ..I $D(^ACHSDEF(ACHSFAC,"D",DA,200)) S X=0 F  S X=$O(^ACHSDEF(ACHSFAC,"D",DA,200,X)) Q:X'?1N.N  D
 ...;S LN2=LN2_"^"_$P(^ICD9($P(^ACHSDEF(ACHSFAC,"D",DA,200,X,0),U),0),U)  ;ACHS*3.1*23
 ...S LN2=LN2_"^"_$P($$ICDDX^ICDCODE($P(^ACHSDEF(ACHSFAC,"D",DA,200,X,0),U)),U,2)  ;ACHS*3.1*23
 ..I $D(^ACHSDEF(ACHSFAC,"D",DA,300)) S X=0 F  S X=$O(^ACHSDEF(ACHSFAC,"D",DA,300,X)) Q:X'?1N.N  D
 ...;S LN3=$P(^ICPT($P(^ACHSDEF(ACHSFAC,"D",DA,300,X,0),U),0),U)_"^"          ;ACHS*3.1*23
 ...S LN3=$P($$CPT^ICPTCOD($P(^ACHSDEF(ACHSFAC,"D",DA,300,X,0),U)),U,2)_"^"  ;ACHS*3.1*23
 ..D XTMP
 ..;COMMENTS FIELD 400 WORD
 ..I $D(^ACHSDEF(ACHSFAC,"D",DA,400)) S X=0 F  S X=$O(^ACHSDEF(ACHSFAC,"D",DA,400,X)) Q:X'?1N.N  D
 ...S ACHSIEN=ACHSIEN+1
 ...S ^XTMP("ACHSGAO",$J,ACHSIEN)=ACHSLN_"E^"_^ACHSDEF(ACHSFAC,"D",DA,400,X,0)
 Q
XTMP ;SET XTMP GLOBAL WITH DATA
 ;ACHSISDT-ISSUE DATE; ACHSPTID-PAT ID; ACHSRDT-REF INIT DT; ACHSMDT-MANAGE CARE DECESION DT;ACHSPDT-FINAL PAY DATE; ACHSPRI-CHS PRIORITY;
 ;ACHSPRTY-VENDOR TYPE; ACHS("$")-ESTIMATED AMOUNT FOR ALL PROVIDERS;ACHSREA-PRIM DENIAL REASON;ACHSDEC-REVERSED-DENIED-DEFFERED
 S ACHSIEN=ACHSIEN+1,ACHSLN=ACHSLN+1
 S ^XTMP("ACHSGAO",$J,ACHSIEN)=ACHSLN_"A"_"^"_ACHSISDT_"^"_ACHSPTID_"^"_ACHSRDT_"^"_ACHSMDT_"^"_ACHSPDT_"^"_ACHSPRI_"^"_ACHSPRTY_"^"_ACHS("$")_"^"_ACHSREA_"^"_ACHSDEC
 S ACHSIEN=ACHSIEN+1,^XTMP("ACHSGAO",$J,ACHSIEN)=ACHSLN_"B^"_LN2
 S ACHSIEN=ACHSIEN+1,^XTMP("ACHSGAO",$J,ACHSIEN)=ACHSLN_"C^"_LN3
 Q
 ;
PDT ;SET PAY DATE IF AVAILABLE
 S ACHSPTY=$P(^ACHSF(ACHSFAC,"D",ACHSDFN,"PA"),U,4)
 S Y=$S(ACHSPTY="F":$P(^ACHSF(ACHSFAC,"D",ACHSDFN,"PA"),U,3),1:$P($G(^ACHSF(ACHSFAC,"D",ACHSDFN,"IP")),U,3))
 I Y X ^DD("DD") S ACHSPDT=Y
 Q
SAV ;SAVE GLOBAL AND SEND TO AREA
 N X1,XBCON,XBE,XBF,XBQ,XBQSHO,XBFN,XBGL,XBFLT,XBMED,XBS1
 S XBFN="chsgao"_ACHSFACN_".txt"
 S XBGL="XTMP(("_$J_",""ACHSGAO"","
 S XBF=$J
 S XBE=$J
 S XBFLT=1
 S XBMED="F"
 S XBCON=1
 D ^XBGSAVE
 Q
EXT ;
 W !!,"TOTAL UNMET NEED:",ACHSCNT,?40,"TOTAL DEFFERALS: ",ACHSDCT
 ;K ^XTMP("ACHSGAO",$J)
 K ACHSDTYP,ACHSREG,ACHSPTID,ACHSISDT,ACHSRDT,ACHSMDT,ACHSPRI,ACHSPDT,ACHSPRTY,ACHSSTYP,ACHSFC,ACHSIEN,ACHSFYDT,ACHSFYWK,ACHSHRN
 K ACHS1,ACHSACFY,ACHSAP,ACHSAPST,ACHSCAT,ACHSCFY,ACHSCNT,ACHSDCT,ACHSDEC,ACHSDFN,ACHSDTYP,ACHSERR,ACHSFAC,ACHSFACN,ACHSXHRN
 K ACHSISDT,ACHSISU,ACHSLN,ACHSMDT,ACHSPDT,ACHSPO,ACHSPRI,ACHSPRTY,ACHSPTID,ACHSPTY,ACHSRDT,ACHSREA,ACHSREF,ACHSREG,ACHSSTYP
 D ERPT^ACHS,^ACHSVAR    ;ACHS*3.1*19 ADDED ACHSVAR
 Q
 ;
HDR ; Print header.
 S ACHSPG=ACHSPG+1
 W @IOF,!!,$$C^XBFUNC("***  CONTRACT HEALTH CARE SYSTEM REPORT  ***",80),!!
 W ACHSLOC,!?20,"UNMET NEED-DENIED DOCUMENTS BY ISSUE DATE",!,ACHSTIME,!!,ACHST1
 Q