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

IVMCQ.m

Go to the documentation of this file.
  1. IVMCQ ;ALB/KCL/AEG/GAH,BDB - API FOR FINANCIAL QUERIES ; 28-N0V-06
  1. ;;2.0;INCOME VERIFICATION MATCH;**17,30,55,120,154**;21-OCT-94;Build 28
  1. ;
  1. ;
  1. OPT ; Entry point for stand-alone financial query option.
  1. ;
  1. N IVMQUIT
  1. W !!,"This option allows queries to be sent to the Health Eligibility"
  1. W !,"Center (HEC) for patients that require updated income information."
  1. S IVMQUIT=0 F D EACH1 Q:IVMQUIT
  1. Q
  1. ;
  1. EACH1 ; Description: Used to send a financial query for each patient selected. from stand-alone option.
  1. ;
  1. N DFN,IVMERROR,IVMOK,IVMOUT,IVMQUE,IVMREPLY,Y
  1. S DIC="^DPT(",DIC(0)="AEMQ"
  1. W ! D ^DIC K DIC S DFN=+Y I Y<1 S IVMQUIT=1 G EACH1Q
  1. ;
  1. ; does patient need a financial query?
  1. I '$$NEED(DFN,1,.IVMERROR) W !!,"A financial query can not be sent for this patient!" W !,IVMERROR G EACH1Q
  1. ;
  1. ; ask if okay to send query?
  1. I '$$ASK(.IVMOK)!($G(IVMOK)) G EACH1Q
  1. ;
  1. ; notify when a reply to query is received?
  1. S IVMREPLY=$$NOTIFY(.IVMOUT)
  1. I $G(IVMOUT) G EACH1Q
  1. ;
  1. ; send query for patient, else write error
  1. I $$QUERY^IVMCQ1(DFN,$G(DUZ),$G(IVMREPLY),$G(XQY),.IVMERROR,1) W !!,"Financial query sent ..."
  1. E D
  1. .W !!,"Failure to send query: ",IVMERROR
  1. ;
  1. EACH1Q Q
  1. ;
  1. ;
  1. REG(DFN) ; Entry point to automatically send a query to HEC for updated financial information.
  1. ;
  1. ; This entry point is called from hooks in registration:
  1. ; - Register a Patient option (DGREG)
  1. ; - Load/Edit Patient Data option (DG10)
  1. ;
  1. ; Input:
  1. ; DFN - IEN of patient record in PATIENT file
  1. ;
  1. ; Output: none
  1. ;
  1. I '$G(DFN) G REGQ
  1. I '$$NEED(DFN) G REGQ
  1. I $$QUERY^IVMCQ1(DFN,$G(DUZ),0,$G(XQY),,1) W !!,"Financial query sent ..."
  1. REGQ Q
  1. ;
  1. ;
  1. APPT ; Entry point for IVM SEND FINANCIAL QUERY protocol.
  1. ;
  1. ; Input:
  1. ; SDAMEVT - IEN of record in APPOINTMENT TRANSACTION TYPE file.
  1. ; (Transaction type that can occur against an appointment)
  1. ; SDATA - Array passed from the [SDAM APPOINTMENT EVENTS]
  1. ; extended protocol. 2nd piece of SDATA is IEN of patient
  1. ; record in PATIENT file.
  1. ;
  1. ; Output: none
  1. ;
  1. N DFN
  1. ;
  1. ; quit if supported Sched vars not defined
  1. I '$D(SDAMEVT) G APPTQ
  1. S DFN=$P($G(SDATA),"^",2)
  1. I 'DFN G APPTQ
  1. ;
  1. ; quit if transaction type not (make appt, check-in, check-out)
  1. I SDAMEVT'=1,(SDAMEVT'=4),(SDAMEVT'=5) G APPTQ
  1. ;
  1. ; does patient need query sent?
  1. I '$$NEED(DFN,1) G APPTQ
  1. ;
  1. ; send query for patient
  1. I $$QUERY^IVMCQ1(DFN,$G(DUZ),0,$G(XQY),,1)
  1. ;
  1. APPTQ Q
  1. ;
  1. ;
  1. ASK(IVMTOUT) ; Ask user if ok to send financial query for patient.
  1. ;
  1. ; Input: none
  1. ;
  1. ; Output:
  1. ; Function Value: 1=Yes and 0=No
  1. ; IVMTOUT (pass by reference) 1=Timeout or up-arrow
  1. ;
  1. N DIR,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR("A")="Would you like to send a financial query for this patient"
  1. S DIR("B")="YES"
  1. S DIR(0)="Y"
  1. W ! D ^DIR
  1. I $D(DTOUT)!($D(DUOUT)) S IVMTOUT=1
  1. Q +$G(Y)
  1. ;
  1. ;
  1. NOTIFY(IVMOUT) ; Ask if user should be notified when a reply to query is received.
  1. ;
  1. ; Input: none
  1. ;
  1. ; Output:
  1. ; Function Value: 1=Yes and 0=No
  1. ; IVMOUT (pass by reference) 1=Timeout or up-arrow
  1. ;
  1. N DIR,DTOUT,DUOUT,X,Y
  1. S DIR("A")="Do you want to be notified when a query reply is received"
  1. S DIR("B")="YES"
  1. S DIR(0)="Y"
  1. W ! D ^DIR
  1. I $D(DTOUT)!($D(DUOUT)) S IVMOUT=1
  1. Q +$G(Y)
  1. ;
  1. ;
  1. NEED(DFN,IVMSENT,ERROR) ; Description: Used to determine if a financial query should be sent for a patient.
  1. ;
  1. ; Input:
  1. ; DFN - ien of patient record in PATIENT file
  1. ; IVMSENT - (optional) Check if query sent on same day 0=>No|1=>Yes
  1. ; Output:
  1. ; Function Value: Does pt. need a query? 1 on success, 0 on failure
  1. ; ERROR - If failure, return the reason for not sending
  1. ; the query (pass by reference)
  1. ;
  1. N DGMSGF,DGADDF,DGREQF,IVMBT,IVML,SUCCESS
  1. N IVMDOD
  1. ;
  1. S SUCCESS=0,(DGMSGF,DGADDF)=1
  1. I '$D(IVMSENT) S IVMSENT=1
  1. ; Can this patient be identified?
  1. I '$G(DFN) S ERROR="PATIENT CAN NOT BE IDENTIFIED" G NEEDQ
  1. ; is this patient deceased?
  1. S IVMDOD=$$GET1^DIQ(2,DFN_",",.351,"I")
  1. I IVMDOD]"" S ERROR="Patient Expired on "_$$GET1^DIQ(2,DFN_",",.351,"E")_". Financial query unnecessary." G NEEDQ
  1. ; Check to see if this patient is currently on a DOM ward.
  1. D DOM^DGMTR I $G(DGDOM) D G NEEDQ
  1. .S ERROR="PATIENT CURRENTLY A DOMICILIARY PATIENT - "
  1. .S ERROR=ERROR_"QUERY NOT REQUIRED"
  1. .K DGDOM
  1. .Q
  1. ; Check for PRIMARY test either MEANS or Copay exemption.
  1. S IVML=$$LST^DGMTCOU1(DFN,DT_.2359,3)
  1. ; If no primary test on file check to see if patient requires a means
  1. ; test or copay exemption test. Call to DGMTR invokes EN^DGMTCOR as
  1. ; well.
  1. I IVML']"" D EN^DGMTR I +$G(DGREQF) S SUCCESS=1 G NEEDQ
  1. ;
  1. ; If current test is not incomplete and not required and is less than
  1. ; 365 days old, presume a current test exists, no query necessary.
  1. ; IVM*2.0*154 MT less than 1 year old as of "VFA Start Date" and point forward do not expire
  1. I ($P(IVML,U,4)'="I")&($P(IVML,U,4)'="R"),'$$OLDMTPF^DGMTU4($P(IVML,U,2)) D G NEEDQ
  1. .S ERROR="PATIENT HAS A CURRENT "_$S($P(IVML,U,5)=1:"MEANS",$P(IVML,U,5)=2:"COPAY EXEMPTION",1:"MEANS")_" TEST ON FILE"
  1. .Q
  1. ;
  1. ; If the current test is NO LONGER REQUIRED or NO LONGER APPLICABLE no
  1. ; query is necessary.
  1. I ($P(IVML,U,4)="N")!($P(IVML,U,4)="L") D G NEEDQ
  1. .S ERROR="PATIENT'S "_$S($P(IVML,U,5)=1:"MEANS",$P(IVML,U,5)=2:"COPAY EXEMPTION",1:"MEANS")_" TEST STATUS "_$P(IVML,U,3)_"."
  1. .Q
  1. ;
  1. ; If current test is not REQUIRED and not NO LONGER REQUIRED and it is
  1. ; older than 365 days, initiate query.
  1. ; IVM*2.0*154 MT less than 1 year old as of "VFA Start Date" and point forward do not expire
  1. I ($P(IVML,U,4)'="R")&($P(IVML,U,4)'="N"),$$OLDMTPF^DGMTU4($P(IVML,U,2)) S SUCCESS=1 G NEEDQ
  1. ;
  1. ; If a query is pending, don't send another.
  1. I $$OPEN^IVMCQ2(DFN) S ERROR="A QUERY IS ALREADY PENDING FOR THIS PATIENT" G NEEDQ
  1. ;
  1. ; if a query has already been sent today, don't send another.
  1. I IVMSENT,$$SENT^IVMCQ2(DFN) S ERROR="A QUERY HAS BEEN SENT FOR PATIENT TODAY" G NEEDQ
  1. ;
  1. ; Has a bene travel cert been filed with a year?
  1. S IVMBT=$O(^DGBT(392.2,"C",DFN,0))
  1. I IVMBT,$$FMDIFF^XLFDT(DT,+$G(^DGBT(392.2,IVMBT,0))\1)>330 S SUCCESS=1 G NEEDQ
  1. ;
  1. S ERROR="A FINANCIAL QUERY IS NOT REQUIRED FOR THIS PATIENT"
  1. ;
  1. NEEDQ Q SUCCESS