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

IBCNEDE4.m

Go to the documentation of this file.
  1. IBCNEDE4 ;AITC/DM - EICD (Electronic Insurance Coverage Discovery) extract; 24-JUN-2002
  1. ;;2.0;INTEGRATED BILLING;**184,271,416,621,602,668,702,778**;21-MAR-94;Build 28
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ; **Program Description**
  1. ; The Electronic Insurance Coverage Discovery a.k.a EICD extract (#4)
  1. ; is called from the nightly job - IBCNEDE.
  1. ;
  1. ; Formerly known as "No Insurance", we are reworking the entire logic for
  1. ; determining insurance for those who don't have active policies with patch IB*2.0*621.
  1. ;
  1. Q
  1. ;
  1. EN ; EICD extract entry
  1. N CLNC,DATA1,DATA2,DATA5,DFN,EACTIVE,ELG,FRESHDT,IBACTV,IBAPPTDT
  1. N IBBEGDT,IBCSIEN,IBDFNDONE,IBEFF,IBEICDPAY,IBENDDT,IBERR,IBEXP,IBFDA
  1. N IBFREQ,IBIDX,IBINSNM,IBMSG,IBSDA,IBTASKTOT,IBTOPIEN,IBTQCNT,IBTQIEN
  1. N IBTQSTAT,IBWK1,IBWK2,IBWKIEN,MAXCNT,OK
  1. ;
  1. ; Get Extract parameters
  1. S EACTIVE=$$SETTINGS^IBCNEDE7(4)
  1. I 'EACTIVE G ENQQ ; not active, or required fields missing
  1. S MAXCNT=$P(EACTIVE,U,4) ; throttle daily extract queries
  1. S:MAXCNT="" MAXCNT=9999999999
  1. S IBWK1=$P(EACTIVE,U,6) ; start days
  1. S IBBEGDT=$$FMADD^XLFDT(DT,IBWK1) ; begin date = today + start days
  1. S IBENDDT=$$FMADD^XLFDT(DT,IBWK1+$P(EACTIVE,U,7)) ; end date = today + start days + days after start
  1. S IBFREQ=$P(EACTIVE,U,8) ; frequency
  1. S FRESHDT=$$FMADD^XLFDT(DT,-IBFREQ)
  1. S IBCSIEN=$$FIND1^DIC(355.12,,"X","CONTRACT SERVICES","C")
  1. S IBTQSTAT=$$FIND1^DIC(365.14,,"X","Ready to Transmit","B")
  1. ;
  1. ;/vd-IB*2*668 - replaced the following 2 lines of code to obtain the internal
  1. ; identifier for the Payer Application.
  1. ;IB*702/TAZ Moved Payer checks to EPAYR^IBCNEUT5 (includes the lines IB*668 fixed)
  1. S IBEICDPAY=$$EPAYR^IBCNEUT5 I 'IBEICDPAY G ENQQ
  1. ;
  1. S IBTASKTOT=0 ; Taskman check
  1. S IBTQCNT=0 ; TQ entry count
  1. K ^TMP($J,"SDAMA301"),^TMP($J,"IBCNEDE4"),IBDFNDONE
  1. ;
  1. ; Loop through clinics
  1. S CLNC=0 F S CLNC=$O(^SC(CLNC)) Q:'CLNC D
  1. . ;IB*778/TAZ - Redirected CLINICEX call to IBCNEDE6
  1. . ;D CLINICEX^IBCNEDE2 Q:'OK ; clinic excluded
  1. . D CLINICEX^IBCNEDE6 Q:'OK ; clinic excluded
  1. . S ^TMP($J,"IBCNEDE4",CLNC)=""
  1. ;
  1. ; Set up variables for scheduling api and call
  1. S IBSDA("FLDS")=8
  1. S IBSDA(1)=IBBEGDT_";"_IBENDDT
  1. S IBSDA(2)="^TMP($J,""IBCNEDE4"","
  1. S IBSDA(3)="R"
  1. S OK=$$SDAPI^SDAMA301(.IBSDA) I OK<1 D:OK<0 ERRMSG G ENQQ
  1. ;
  1. ; loop through returned clinics
  1. S CLNC=0
  1. F S CLNC=$O(^TMP($J,"SDAMA301",CLNC)) Q:'CLNC D G ENQQ:$G(ZTSTOP)!(IBTQCNT'<MAXCNT)
  1. . ;
  1. . ; Loop through patients returned
  1. . S DFN=0
  1. . F S DFN=$O(^TMP($J,"SDAMA301",CLNC,DFN)) Q:'DFN D Q:$G(ZTSTOP)!(IBTQCNT'<MAXCNT)
  1. .. ;
  1. .. ; CHECK DFN STUFF
  1. .. Q:$D(IBDFNDONE(DFN)) ; DFN has been handled
  1. .. ;
  1. .. ;IB*702/TAZ Checks for TEST PATIENT, DATE LAST EICD RUN, DATE OF DEATH, CITY AND ZIP moved to EPAT^IBCNEUT5
  1. .. I '$$EPAT^IBCNEUT5() S IBDFNDONE(DFN)="" Q ; patient requirements not met
  1. .. ;
  1. .. ; Loop through dates in range at clinic
  1. .. S IBAPPTDT=IBBEGDT
  1. .. F S IBAPPTDT=$O(^TMP($J,"SDAMA301",CLNC,DFN,IBAPPTDT)) Q:('IBAPPTDT)!((IBAPPTDT\1)>IBENDDT) D Q:$G(ZTSTOP)!(IBTQCNT'<MAXCNT)
  1. ... ;
  1. ... ; Update count for periodic check
  1. ... S IBTASKTOT=IBTASKTOT+1
  1. ... ; Check for request to stop background job, periodically
  1. ... I $D(ZTQUEUED),IBTASKTOT#100=0,$$S^%ZTLOAD() S ZTSTOP=1 Q
  1. ... ;
  1. ... Q:$D(IBDFNDONE(DFN)) ; we've already seen this DFN
  1. ... ;
  1. ... S IBWK1=$G(^TMP($J,"SDAMA301",CLNC,DFN,IBAPPTDT))
  1. ... S ELG=$P(IBWK1,U,8)
  1. ... S:ELG="" ELG=$$GET1^DIQ(2,DFN_",",.361) ; "PRIMARY ELIGIBILITY CODE"
  1. ... ;IB*778/TAZ - Redirected ELG call to IBCNEDE6
  1. ... ;D ELG^IBCNEDE2 Q:'OK ; eligibility exclusion
  1. ... D ELG^IBCNEDE6 Q:'OK ; eligibility exclusion
  1. ... ;IB*602/TAZ Screen out bad pointers to File 36
  1. ... ;IB*702/TAZ - Active Insurance check was moved to EACTPOL^IBCNEUT5
  1. ... I $$EACTPOL^IBCNEUT5 Q ; Active policies on patient. (screen out bad ptr's to File 36)
  1. ... ;
  1. ... ; This DFN is considered non-active, we'll attempt a TQ entry
  1. ... S IBDFNDONE(DFN)="" ; ok to flag DFN as handled now
  1. ... ; there should be no TQ entry for this DFN, consider it a safety check
  1. ... I '$$ADDTQ^IBCNEUT5(DFN,IBEICDPAY,DT,IBFREQ,1) Q
  1. ... ; SET prepare and file the TQ
  1. ... ; DFN:Patient IEN
  1. ... ; IBEICDPAY:EICD payer IEN
  1. ... ; IBTQSTAT:TQ STATUS IEN - Ready to Transmit
  1. ... ; FRESHDT:Freshness date
  1. ... ; 4:EICD data extract (#4)
  1. ... ; I:Identification
  1. ... ; DT:Todays date
  1. ... ; IBCSIEN:Source of Information IEN - Contract Services
  1. ... S DATA1=DFN_U_IBEICDPAY_U_IBTQSTAT_U_""_U_""_U_FRESHDT
  1. ... S DATA2=4_U_"I"_U_DT
  1. ... S DATA5=IBCSIEN
  1. ... S IBTQIEN=$$SETTQ^IBCNEDE7(DATA1,DATA2,,,DATA5) ; Sets in TQ
  1. ... I IBTQIEN="" K IBDFNDONE(DFN) Q ; didn't file, unmark DFN
  1. ... S IBTQCNT=IBTQCNT+1 ; increment the TQ count
  1. ... ; place a stub into EIV EICD TRACKING (#365.18)
  1. ... K IBFDA,IBERR
  1. ... ; EIV EICD TRACKING, .01:TRANSMISSION .02:DATE CREATED .03:PAYER .05:PATIENT
  1. ... S IBFDA(365.18,"+1,",.01)=IBTQIEN,IBFDA(365.18,"+1,",.02)=DT
  1. ... S IBFDA(365.18,"+1,",.03)=IBEICDPAY,IBFDA(365.18,"+1,",.05)=DFN
  1. ... D UPDATE^DIE(,"IBFDA",,"IBERR")
  1. ... I $G(IBERR("DIERR",1,"TEXT",1))'="" D Q
  1. .... S IBMSG=""
  1. .... D MSG002^IBCNEMS1(.IBMSG,.IBERR,IBTQIEN)
  1. .... D MSG^IBCNEUT5($$MGRP^IBCNEUT5(),"eIV Problem: Error writing EIV EICD TRACKING (#365.18)","IBMSG(")
  1. ... Q ; next clinic appt
  1. ... ;
  1. ENQQ ; clean and quit
  1. K ^TMP($J,"SDAMA301"),^TMP($J,"IBCNEDE2")
  1. Q
  1. ;
  1. ERRMSG ; Send a message indicating an extract error has occurred
  1. S IBMSG=""
  1. D MSG001^IBCNEMS1(.IBMSG,"EICD")
  1. D MSG^IBCNEUT5($$MGRP^IBCNEUT5(),"eIV Problem: EICD Extract","IBMSG(")
  1. ;
  1. Q
  1. ;
  1. ;NAINSCO ; Non-active Insurance companies and NATPLANS ; Non-active Type of Plans Moved to IBCNEUT5