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

ABMDVCK.m

Go to the documentation of this file.
  1. ABMDVCK ; IHS/ASDST/DMJ - PCC Visit Edits ;
  1. ;;2.6;IHS 3P BILLING SYSTEM;**11,19,20,21**;NOV 12, 2009;Build 379
  1. ;Original;TMD;08/19/96 4:49 PM
  1. ;Note special input variable ABMDFN
  1. ;It is optional
  1. ;If it is defined claims will be generated only for the one patient
  1. ;whose ien is the value of ABMDFN.
  1. ;If it is undefined claims will be generated for all patient with new
  1. ;PCC visits.
  1. ;
  1. ; IHS/SD/SDR - v2.5 p8
  1. ; Check for uncoded Dxs on visit
  1. ;
  1. ; IHS/SD/SDR - v2.5 p8
  1. ; Check PCC EHR/Chart Audit Start Date; if populated, the Chart Audit
  1. ; Status will need to be checked for ea visit with a service cat or
  1. ; A/O/S. If DOS is equal or after the Audit Start Date and the status
  1. ; is anything but REVIEWED the claim will not generate.
  1. ;
  1. ; IHS/SD/SDR - v2.5 p8 -When inpatient, check if coding complete field is null; if so, generate claim.
  1. ; IHS/SD/SDR - v2.5 p9 - IM19304 - Fix supplied by Jim Gray, checking to see if variable ABMP("INS") is set
  1. ; IHS/SD/SDR - v2.5 p9 - Fix to Uncoded Dxs to check lag time
  1. ; IHS/SD/SDR - v2.5 p10 - IM21846 - Made change to stop error <UNDEF>EXP+1^ABMDE2X5
  1. ;
  1. ;IHS/SD/SDR - 2.6*19 - HEAT128988 - Made change to CG to check A/R PARENT/SATELLITE SETUP so CG can check
  1. ; parent locations first, then satellites; claims were generated under wrong location when satellite IEN
  1. ; was lower than parent IEN.
  1. ;IHS/SD/SDR - 2.6*19 - HEAT251398 - Changed claim generator to allow service category TELEMEDICINE to
  1. ; generate claims.
  1. ;IHS/SD/SDR - 2.6*20 - HEAT270671 - Made change to stop <UNDEF>SITE+1^ABMDVCK error. Occurs when there is an entry
  1. ; in the A/R Parent/Satellite file but no matching entry in the 3P Parameter file.
  1. ;IHS/SD/SDR - 2.6*21 - HEAT130406 - Removed auto-purge of claims from CG.
  1. ; *********************************************************************
  1. START ;START HERE
  1. I DUZ(2)="" S DUZ(2)=1
  1. S X="APCDCHKJ"
  1. X ^%ZOSF("TEST") ;See if rtn exists.
  1. I D ^APCDCHKJ ;PCC linker - INPAT
  1. I '$D(ABMDFN) D ^APCDK ;PCC relinker
  1. N ABMVDFN,ABMCPTTB,ABMDT
  1. S X1=DT
  1. S X2=-180
  1. D C^%DTC
  1. S ABM("C")=X
  1. ;The ^ABMDTMP("KCLM" nodes are still being set in ver 2.0 as of 8/27/96
  1. S ABM=0
  1. F S ABM=$O(^ABMDTMP("KCLM",ABM)) Q:'ABM Q:ABM>ABM("C") D
  1. .S ABM("D")=0
  1. .F S ABM("D")=$O(^ABMDTMP("KCLM",ABM,ABM("D"))) Q:'ABM("D") D
  1. ..K ^ABMDTMP("KCLM",ABM,ABM("D"))
  1. ;These ^ABMDTMP("KBILL" nodes are not being set in version 2.0
  1. ;These nodes are the audit trail from ver 1.6
  1. ;This checking must continue for 6 months after conversion from 1.6
  1. S ABM=0
  1. F S ABM=$O(^ABMDTMP("KBILL",ABM)) Q:'ABM Q:ABM>ABM("C") D
  1. .S ABM("D")=0
  1. .F S ABM("D")=$O(^ABMDTMP("KBILL",ABM,ABM("D"))) Q:'ABM("D") D
  1. ..K ^ABMDTMP("KBILL",ABM,ABM("D"))
  1. S U="^"
  1. K ABM,ABMP,ABML
  1. I $D(^ABMDTMP("VCK",DT)),^(DT)'=$J,'$D(ABMDFN) Q
  1. S:'$D(ABMDFN) ^ABMDTMP("VCK",DT)=$J
  1. ;Set up ABILL X-ref for parent of all added or changed I & D visits
  1. N V,V0,P,P0
  1. S ABMDT=""
  1. F S ABMDT=$O(^AUPNVSIT("ABILL",ABMDT)) Q:'ABMDT D
  1. .S V=""
  1. .F S V=$O(^AUPNVSIT("ABILL",ABMDT,V)) Q:'V D
  1. ..S V0=$G(^AUPNVSIT(V,0))
  1. ..S SERVCAT=$P(V0,U,7)
  1. ..Q:"ID"'[SERVCAT ;SERVCAT needs to be either I or D
  1. ..I $D(ABMDFN),ABMDFN'=$P(V0,U,5) Q ;For a set patient
  1. ..S P=$P(V0,U,12)
  1. ..Q:'P
  1. ..S P0=$G(^AUPNVSIT(P,0))
  1. ..Q:"HOS"'[$P(P0,U,7)
  1. ..S ^AUPNVSIT("ABILL",+P0,P)=""
  1. I $D(ABMDFN) D SITE Q ;For real time billing
  1. ;
  1. LOOP ;LOOP THROUGH SITES
  1. ;start old code abm*2.6*11 HEAT86425
  1. ;Only loop through sites that are in the parameters file
  1. S DUZ(2)=0
  1. ;start old abm*2.6*19 HEAT128988
  1. ;F S DUZ(2)=$O(^ABMDPARM(DUZ(2))) Q:+DUZ(2)=0 D Q:$G(ZTSTOP)
  1. ;.Q:$D(^ABMDPARM(DUZ(2),1))'=10
  1. ;.D SITE
  1. ;.D ^ABMDACK
  1. ;.S DIE="^ABMDPARM(DUZ(2),"
  1. ;.S DA=1
  1. ;.S DR=".21////"_DT
  1. ;.D ^ABMDDIE
  1. ;end old start new abm*2.6*19 HEAT128988
  1. F S DUZ(2)=$O(^BAR(90052.05,DUZ(2))) Q:+DUZ(2)=0 D Q:$G(ZTSTOP)
  1. .Q:$D(^ABMDPARM(DUZ(2),1))'=10
  1. .I +$P($G(^ABMDPARM(DUZ(2),1,4)),U,9)=1 D LOOP2 Q
  1. .S ABMHDUZ=DUZ(2)
  1. .S DUZ(2)=0
  1. .F S DUZ(2)=$O(^BAR(90052.05,ABMHDUZ,DUZ(2))) Q:+DUZ(2)=0 D Q:$G(ZTSTOP)
  1. ..Q:$D(^ABMDPARM(DUZ(2),1))'=10 ;abm*2.6*20 IHS/SD/SDR HEAT270671
  1. ..D LOOP2
  1. .S DUZ(2)=ABMHDUZ
  1. ;end new code abm*2.6*19 HEAT128988
  1. ;end old code start new code HEAT86425
  1. ;K ABMPSLST
  1. ;S DUZ(2)=0
  1. ;F S DUZ(2)=$O(^BAR(90052.05,DUZ(2))) Q:'DUZ(2) D
  1. ;.S ABMLDFN=0
  1. ;.F S ABMLDFN=$O(^BAR(90052.05,DUZ(2),ABMLDFN)) Q:'ABMLDFN D
  1. ;..S ABMPSLST(DUZ(2),ABMLDFN)=$S(DUZ(2)=ABMLDFN:$P($G(^ABMDPARM(DUZ(2),1,4)),U,9),1:"")
  1. ;..I ABMLDFN=DUZ(2) S ABMPS(DUZ(2))=""
  1. ;;
  1. ;S ABMDUZ2=0
  1. ;F S ABMDUZ2=$O(ABMPS(ABMDUZ2)) Q:'ABMDUZ2 D
  1. ;.S ABMARPS=$G(ABMPSLST(ABMDUZ2,ABMDUZ2))
  1. ;.I ABMARPS D Q
  1. ;..S DUZ(2)=ABMDUZ2
  1. ;..Q:$D(^ABMDPARM(DUZ(2),1))'=10 ;not setup in 3P Parameters
  1. ;..D SITE
  1. ;..D ^ABMDACK
  1. ;..S DIE="^ABMDPARM(DUZ(2),"
  1. ;..S DA=1
  1. ;..S DR=".21////"_DT
  1. ;..D ^ABMDDIE
  1. ;.I 'ABMARPS D Q
  1. ;..S DUZ(2)=0
  1. ;..F S DUZ(2)=$O(ABMPSLST(ABMDUZ2,DUZ(2))) Q:'DUZ(2) D
  1. ;...Q:$D(^ABMDPARM(DUZ(2),1))'=10 ;not setup in 3P Parameters
  1. ;...D SITE
  1. ;...D ^ABMDACK
  1. ;...S DIE="^ABMDPARM(DUZ(2),"
  1. ;...S DA=1
  1. ;...S DR=".21////"_DT
  1. ;...D ^ABMDDIE
  1. ;end new code HEAT86425
  1. K ^ABMDTMP("VCK")
  1. K ABMP,ABMACTVI,ABMCOVD,ABMD,ABMPCAT,ABMPINS,ABMSRC,ABMV,DIE,DA,DR
  1. K SERVCAT,X,X1,X2,Y0
  1. Q
  1. ;start new abm*2.6*19 IHS/SD/SDR HEAT128988
  1. LOOP2 ;
  1. D SITE
  1. D ^ABMDACK
  1. S DIE="^ABMDPARM(DUZ(2),"
  1. S DA=1
  1. S DR=".21////"_DT
  1. D ^ABMDDIE
  1. Q
  1. ;end new code abm*2.6*19 IHS/SD/SDR HEAT128988
  1. ;
  1. ; *********************************************************************
  1. SITE ;ONE SITE
  1. I '$D(ABMDFN),$P(^ABMDPARM(DUZ(2),1,0),U,19) D ^ABMDBACK
  1. ;
  1. AP ;AUTO PURGE CLAIMS
  1. ;start old abm*2.6*21 IHS/SD/SDR HEAT130406
  1. ;S ABM("DIF")=$S($P($G(^ABMDPARM(DUZ(2),1,2)),U,8):$P(^(2),U,8),1:180)
  1. ;S X1=DT
  1. ;S X2=-ABM("DIF")
  1. ;D C^%DTC
  1. ;S ABM("DIF")=X
  1. ;;X-ref AC on date last edited
  1. ;I '$D(ABMDFN) D
  1. ;.;F ABM("C")=0:0 S ABM("C")=$O(^ABMDCLM(DUZ(2),"AC",ABM("C"))) Q:'ABM("C") Q:ABM("C")>ABM("DIF") D
  1. ;..S ABMP("CDFN")=0
  1. ;..F S ABMP("CDFN")=$O(^ABMDCLM(DUZ(2),"AC",ABM("C"),ABMP("CDFN"))) Q:'ABMP("CDFN") D
  1. ;...Q:$P($G(^ABMDCLM(DUZ(2),ABMP("CDFN"),0)),"^",4)="U"
  1. ;...Q:$D(^ABMDBILL(DUZ(2),"AS",ABMP("CDFN")))
  1. ;...;Kill claim
  1. ;...S DR=".04///2"
  1. ;...D KCLM^ABMDECAN
  1. ;end old abm*2.6*21 IHS/SD/SDR HEAT130406
  1. ;
  1. VLP ;LOOP THROUGH VISITS IN VISIT FILE
  1. ;ABILL X-REF set in ABMDBACK. On date visit created
  1. ;ENDT is the entry date, not the end date
  1. S ABMP("ENDT")=""
  1. F S ABMP("ENDT")=$O(^AUPNVSIT("ABILL",ABMP("ENDT"))) Q:ABMP("ENDT")="" D Q:$G(ZTSTOP)
  1. .S ABMVDFN=0
  1. .F S ABMVDFN=$O(^AUPNVSIT("ABILL",ABMP("ENDT"),ABMVDFN)) Q:'ABMVDFN D Q:$G(ZTSTOP)
  1. ..S ABMODFN=ABMVDFN
  1. ..I $$S^%ZTLOAD S ZTSTOP=1 Q
  1. ..I $D(ABMDFN),'$D(^AUPNVSIT("AC",ABMDFN,ABMVDFN)) Q ;Real time claim
  1. ..D V2
  1. ..D:$G(ABMNFLG) ^ABMEAUTO
  1. ..K ABMNFLG
  1. ..I ABMVDFN="" S ABMVDFN=ABMODFN
  1. ..D RESET
  1. K ^TMP($J,"PROC")
  1. K ABMDFN
  1. Q
  1. ;
  1. ; ********************************************************************
  1. V2 ;CHECK VISIT (NEEDS ABMVDFN DEFINED)
  1. ;This entry point can be called from the debugger
  1. ;ABMP("V0") is the zero node of the visit file rec
  1. ;ABMDA is the ien of the V file source.
  1. N SERVCAT,ABMHIEN,ABMDISDT,ABMPARNT,ABMDA
  1. ;ABMP("ENDT") is the entry date or the visit date
  1. ;ABMP("VDT") is the visit date (.01) with the time stripped off
  1. Q:'$D(^AUPNVSIT(ABMVDFN,0))
  1. S ABMP("V0")=^AUPNVSIT(ABMVDFN,0)
  1. S ABMP("VDT")=$P(ABMP("V0"),U)\1
  1. S SERVCAT=$P(ABMP("V0"),U,7)
  1. ; I is an offspring of an H category. O is more like an admission.
  1. ; It is not expected to be the offspring of H.
  1. ; ABMHIEN is the ien for the corresponding V HOSPITALIZATION entry
  1. S ABMHIEN=$O(^AUPNVINP("AD",ABMVDFN,0))
  1. S ABMDISDT=$S(ABMHIEN]"":$P(^AUPNVINP(ABMHIEN,0),U,1),1:0)
  1. S ABMPARNT=$P(ABMP("V0"),U,12)
  1. S ABMP("PRIMVSIT")=ABMVDFN
  1. ; I will also check the parent links to make sure these visits
  1. ; are being attached right.
  1. S ABMIFLG=$$ICDCHK^ABMDVCK3(ABMVDFN) ;check for uncoded ICDs (.9999)
  1. I $G(ABMIFLG)=1 D
  1. .S ABMILAG=$P($G(^ABMDPARM(DUZ(2),1,5)),U,2)
  1. .S X1=DT
  1. .S X2=ABMP("VDT")
  1. .D ^%DTC
  1. .I X>ABMILAG K ABMIFLG ;past lag time
  1. I $G(ABMIFLG)=1 D PCFL(59) Q ;error for uncoded Dx
  1. ;I "ASO"[SERVCAT,($P($G(^APCCCTRL(DUZ(2),0)),U,12)'=""),($P(^APCCCTRL(DUZ(2),0),U,12)'>ABMP("VDT")),($P($G(^AUPNVSIT(ABMVDFN,11)),U,11)'="R") D PCFL(60) Q ;EHR/Chart Audit Start Date ;abm*2.6*19 IHS/SD/SDR HEAT251398
  1. I "ASOM"[SERVCAT,($P($G(^APCCCTRL(DUZ(2),0)),U,12)'=""),($P(^APCCCTRL(DUZ(2),0),U,12)'>ABMP("VDT")),($P($G(^AUPNVSIT(ABMVDFN,11)),U,11)'="R") D PCFL(60) Q ;EHR/Chart Audit Start Date ;abm*2.6*19 IHS/SD/SDR HEAT251398
  1. I "AS"[SERVCAT D Q
  1. .;If the visit has a parent and
  1. .;the visit is in the date range I will treat it like an I type.
  1. .I ABMPARNT]"",ABMP("VDT")'>ABMDISDT,ABMP("VDT")'<^AUPNVSIT(ABMPARNT,0) Q
  1. .Q:$D(^TMP($J,"PROC",ABMVDFN))
  1. .D VCHX^ABMDVCK0(ABMVDFN)
  1. .; Assume children of S cat visit belong to the S visit
  1. .Q:SERVCAT="A"
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("AD",ABMVDFN,ABMV)) Q:'ABMV D
  1. ..Q:$D(^TMP($J,"PROC",ABMV))
  1. ..I '$G(ABMP("CDFN")) D Q
  1. ...;No claim created for parent visit
  1. ...D PCFL(30)
  1. ...S ^TMP($J,"PROC",ABMV)=""
  1. ...D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. ..D VCHX^ABMDVCK0(ABMV)
  1. ..D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. I "O"=SERVCAT,$P(ABMP("V0"),U,12)="" D Q
  1. .Q:$D(^TMP($J,"PROC",ABMVDFN))
  1. .D VCHX^ABMDVCK0(ABMVDFN)
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("AD",ABMVDFN,ABMV)) Q:'ABMV D
  1. ..Q:$D(^TMP($J,"PROC",ABMV))
  1. ..I '$G(ABMP("CDFN")) D Q
  1. ...;No claim created for parent visit
  1. ...D PCFL(30)
  1. ...S ^TMP($J,"PROC",ABMV)=""
  1. ...D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. ..S Y0=^AUPNVSIT(ABMV,0)
  1. ..I ABMP("VDT")>((+Y0)\1) D Q
  1. ...Q:$P(Y0,U,7)=""!("ID"'[$P(Y0,U,7))
  1. ...;I visit linked to an O visit on a different date.
  1. ...D PCFL(26)
  1. ...S ^TMP($J,"PROC",ABMV)=""
  1. ...D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. ..D VCHX^ABMDVCK0(ABMV)
  1. ..D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. I "ID"[SERVCAT,ABMPARNT="" D VCHX^ABMDVCK0(ABMVDFN) Q
  1. I "ID"[SERVCAT S ABMP("FLAG1")=1 Q
  1. I "H"=SERVCAT D Q
  1. .I $G(ABMHIEN)="" D PCFL(61) Q ;abm*2.6*11 HEAT89149
  1. .I $G(ABMHIEN)'="",($P($G(^AUPNVINP(ABMHIEN,0)),U,15)'="") D PCFL(61) Q ;inpt coding complete?
  1. .N ABMF,ABMACTVI
  1. .I $D(^TMP($J,"PROC",ABMVDFN)) D Q:ABMF
  1. ..I $P(ABMP("V0"),U,4)>23 S ABMF=0 Q
  1. ..I $P(ABMP("V0"),U,12)="" S ABMF=0 Q
  1. ..S ABMF=1
  1. ..;Hospitalization with a parent link.
  1. ..S DIE="^AUPNVSIT("
  1. ..S DA=ABMVDFN
  1. ..S DR=".04////27"
  1. ..D ^DIE
  1. .D VCHX^ABMDVCK0(ABMVDFN)
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("AD",ABMVDFN,ABMV)) Q:'ABMV D
  1. ..I '$G(ABMP("CDFN")) D Q
  1. ...;No claim created for parent visit
  1. ...S DIE="^AUPNVSIT("
  1. ...S DA=ABMV
  1. ...S DR=".04////30"
  1. ...D ^DIE
  1. ...S ^TMP($J,"PROC",ABMV)=""
  1. ...D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. ..D VCHX^ABMDVCK0(ABMV)
  1. ..N ABMEDT,ABMD,ABMF
  1. ..S ABMEDT=$P(^AUPNVSIT(ABMV,0),U,2)
  1. ..I '$D(^AUPNVSIT("ABILL",ABMEDT,ABMV)),$D(ABMP("ENDT")) D
  1. ...S ABMD=+^AUPNVSIT(ABMV,0)-.3
  1. ...S ABMF=0
  1. ...S ABMDL=$S($G(ABMP("DDT"))>ABMP("ENDT"):ABMP("DDT")+.25,ABMP("ENDT")>ABMEDT:ABMP("ENDT")+.25,1:ABMEDT+10000)
  1. ...F S ABMD=$O(^AUPNVSIT("ABILL",ABMD)) Q:'ABMD!(ABMD>ABMDL) D Q:ABMF
  1. ....Q:'$D(^AUPNVSIT("ABILL",ABMD,ABMV))
  1. ....S ABMF=1
  1. ....S ABMEDT=ABMD
  1. ..D KABILL(ABMV,ABMEDT)
  1. .;I need code here to check if ABMP("DDT") exists and if so
  1. .;ABMP("HDATE") is equal to it. If not I need a way to redo
  1. .;ABMDVST4.
  1. .I $D(ABMP("DDT")),ABMP("HDATE")<ABMP("DDT") D
  1. ..N ABMCHVDT,P,I
  1. ..;Vars need to be set up for use by ABMDVST4
  1. ..S ABMCHVDT=ABMP("DDT")
  1. ..S P=0
  1. ..F S P=$O(ABML(P)) Q:'P D Q:ABMP("PRI")=P
  1. ...S I=0
  1. ...F S I=$O(ABML(P,I)) Q:'I D Q:ABMP("INS")=I
  1. ....Q:I'=ABMACTVI
  1. ....S ABMP("PRI")=P
  1. ....S ABMP("INS")=I
  1. ..Q:ABMP("INS")=""
  1. ..D DISCHRG^ABMDVSTH
  1. .S ABMV=""
  1. .F S ABMV=$O(^AUPNVSIT("ABP",ABMVDFN,ABMV)) Q:'ABMV D
  1. ..;ABMVDFN is the H visit, ABMV may be an OP visit in 3 days.
  1. ..S V0=^AUPNVSIT(ABMV,0) ;Check for OP vis on admit day
  1. ..Q:$P(V0,U,11) ;Deleted visit
  1. ..Q:"AS"'[$P(V0,U,7)
  1. ..S X1=ABMP("VDT")
  1. ..S X2=-3
  1. ..D C^%DTC
  1. ..Q:$P(+V0,".")<X
  1. ..Q:$P(+V0,".")>ABMP("VDT")
  1. ..I '$D(ABMP("CDFN")) D Q
  1. ...;No claim created for parent visit
  1. ...S DIE="^AUPNVSIT("
  1. ...S DA=ABMV
  1. ...S DR=".04////30"
  1. ...D ^DIE
  1. ...S ^TMP($J,"PROC",ABMV)=""
  1. ...D KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. ..D VCHX^ABMDVCK0(ABMV),KABILL(ABMV,$P(^AUPNVSIT(ABMV,0),U,2))
  1. Q:$D(^TMP($J,"PROC",ABMVDFN))
  1. D VCHX^ABMDVCK0(ABMVDFN)
  1. Q
  1. ;
  1. ; ********************************************************************
  1. KABILL(V,ENTDT) ;
  1. I '$D(ENTDT) S ENTDT=$G(ABMP("ENDT"))
  1. Q:'$D(^TMP($J,"PROC",V))
  1. Q:$D(ABMP("LOCKFAIL"))
  1. Q:$G(ABMP("NOKILLABILL"))
  1. I $G(ENTDT),$G(ABMP("FLAG1")) K ^AUPNVSIT("ABILL",ENTDT,V)
  1. Q
  1. ;
  1. ; *********************************************************************
  1. RESET ;
  1. D KABILL(ABMVDFN,ABMP("ENDT"))
  1. S ABM("ENDT")=$G(ABMP("ENDT"))
  1. K ABMP
  1. S ABMP("ENDT")=ABM("ENDT")
  1. K ABM,ABML,ABMI,ABMR,DA
  1. Q
  1. ;
  1. ; *********************************************************************
  1. PCFL(X) ;EP-file VISIT file field .04
  1. S DIE="^AUPNVSIT("
  1. S DA=ABMVDFN
  1. S DR=".04////"_X
  1. D ^DIE
  1. Q