IVMCQ2 ;ALB/KCL - API FOR FINANCIAL QUERIES (continued) ; 27-APR-95
;;2.0;INCOME VERIFICATION MATCH;**17**;21-OCT-94
;
;
MONITOR ; Description: This entry point is used to monitor the IVM FINANCIAL
; QUERY LOG file and check for query transmissions that have not been
; responded to for more than 2 days. If a query is > 2 days old, the
; corresponding entry in the IVM FINANCIAL QUERY LOG file will be
; updated/closed and a new financial query may be sent.
;
N IVMQLOG,QRYIEN,%
;
; roll through query log entries with 'open' status
S QRYIEN=0 F S QRYIEN=$O(^IVM(301.62,"AC",0,QRYIEN)) Q:'QRYIEN D
.;
.; obtain record from IVM FINANCIAL QUERY LOG
.Q:'$$GET(+QRYIEN,.IVMQLOG)
.;
.; quit if query msg not old enough
.Q:IVMQLOG("SENT")>$$FMADD^XLFDT(DT,-2)
.;
.; update/auto-close query in IVM FINANCIAL QUERY LOG file
.D NOW^%DTC,UPD(IVMQLOG("DFN"),+QRYIEN,%,6,2)
.;
.; quit if new query is not needed
.Q:'$$NEED^IVMCQ(IVMQLOG("DFN"))
.;
.; send new query
.I $$QUERY^IVMCQ1(IVMQLOG("DFN"),IVMQLOG("TRANBY"),IVMQLOG("NOTIFY"),IVMQLOG("OPTION"))
;
Q
;
;
FIND(DFN,IVMMSG,IVMRECD,IVMCR,IVMCS) ; Description: Used to find and update
; entry in IVM FINANCIAL QUERY LOG file.
;
; Input:
; DFN - ien of patient record in PATIENT file
; IVMMSG - query message id
; IVMRECD - date/time query response received
; IVMCR - query closure reason code
; IVMCS - query closure source (1|DCD -- 2|DHCP)
;
; Output: none
;
I '$G(DFN)!'$G(IVMCR)!'$G(IVMCS) G FINDQ
N IVM,IVMD
S IVM=0 F S IVM=$O(^IVM(301.62,"B",DFN,IVM)) Q:'IVM D
.S IVMD=$G(^IVM(301.62,+IVM,0))
.Q:$P(IVMD,"^",5)'=$G(IVMMSG) ; message, query ID's not same
.D UPD(DFN,+IVM,$G(IVMRECD),IVMCR,IVMCS)
FINDQ Q
;
;
UPD(DFN,IVMDA,IVMRECD,IVMCR,IVMCS) ; Description: Used to update record found in IVM FINANCIAL QUERY LOG file.
;
; Input:
; DFN - ien of patient record in PATIENT file
; IVMMSG - query message id
; IVMRECD - date/time query response received
; IVMCR - query closure reason code
; IVMCS - query closure source (1|DCD -- 2|DHCP)
;
; Output: none
;
I '$G(DFN)!'$G(IVMDA)!'$G(IVMCR)!'$G(IVMCS) G FINDQ
N DA,DIE,DR,IVMCRP,IVMOPT
S IVMCRP=$O(^IVM(301.94,"AC",IVMCR,0)) S:'IVMCRP IVMCRP=IVMCR
S DIE="^IVM(301.62,",DA=IVMDA
S DR=".03////1"_$S($G(IVMRECD):";.06////"_IVMRECD,1:"")
S DR=DR_";1.01////"_IVMCRP_";1.02///NOW;1.03////"_IVMCS
D ^DIE
;
; determine if query reply requires user notification
I '$$NOTIFY(IVMDA)
;
UPDQ Q
;
;
FINDMSG(MSGID) ;
; Description: Used to find a record in the IVM FINANCIAL QUERY LOG
; file, given the unique message id assigned to the query by the
; HL7 package.
;
; Input:
; MSGID - The unique id assigned to the query by the HL7 package and
; stored in the IVM FINANCIAL QUERY LOG as the HL7 MESSAGE
; CONTROL ID field.
;
; Output:
; Function Value - If successful, returns the ien of the record in
; the file, otherwise returns 0 on failure.
;
Q:($G(MSGID)="") 0
Q +$O(^IVM(301.62,"C",MSGID,0))
;
;
GET(IEN,IVMQRY) ;
; Description: Used to obtain a record in the IVM FINANCIAL QUERY LOG
; file. The values are returned in the IVMQRY() array.
;
; Input:
; IEN - internal entry number of a record in the IVM FINANCIAL QUERY LOG file.
;
; Output:
; Function Value - 1 on success, 0 on failure.
; IVMQRY() array, pass by reference. Subscripts are:
; "DFN" - PATIENT field
; "SENT" - QUERY TRANS DT/TM field
; "STATUS" - QUERY STATUS field
; "TRANBY" - TRANSMITTED BY field
; "MSGID" - HL7 MESSAGE CONTROL ID field
; "RESPONSE" - QUERY RESPONSE REC'D DT/TM field
; "OPTION" - DHCP OPTION field
; "NOTIFY" - NOTIFY FLAG field
; "CLOSURE RSN" - CLOSURE REASON field
; "CLOSURE" - CLOSURE DT/TM field
; "CLOSURE SRC" - CLOSURE SOURCE field
;
N IVMNODE
K IVMQRY S IVMQRY=""
Q:'$G(IEN) 0
;
S IVMNODE=$G(^IVM(301.62,IEN,0))
Q:IVMNODE="" 0
;
S IVMQRY("DFN")=$P(IVMNODE,"^")
S IVMQRY("SENT")=$P(IVMNODE,"^",2)
S IVMQRY("STATUS")=$P(IVMNODE,"^",3)
S IVMQRY("TRANBY")=$P(IVMNODE,"^",4)
S IVMQRY("MSGID")=$P(IVMNODE,"^",5)
S IVMQRY("RESPONSE")=$P(IVMNODE,"^",6)
S IVMQRY("OPTION")=$P(IVMNODE,"^",7)
S IVMQRY("NOTIFY")=$P(IVMNODE,"^",8)
;
S IVMNODE=$G(^IVM(301.62,IEN,1))
S IVMQRY("CLOSURE RSN")=$P(IVMNODE,"^")
S IVMQRY("CLOSURE")=$P(IVMNODE,"^",2)
S IVMQRY("CLOSURE SRC")=$P(IVMNODE,"^",3)
;
Q 1
;
;
DELETE(IEN) ;
; Description: Delete record in the IVM FINANCIAL QUERY LOG file,
; given the internal entry number (IEN).
;
; Input:
; IEN - The internal entry number of the record.
;
; Output:
; Function Value - 1 on success, 0 on failure.
;
Q:'$G(IEN) 0
N DIK,DA
S DIK="^IVM(301.62,"
S DA=IEN
D ^DIK
Q 1
;
;
LASTQRY(DFN) ; Description: Used to find the last financial query for a patient.
;
; Input:
; DFN - ien of patient record in PATIENT file
;
; Output:
; Function Value - If successful, returns the ien of the record in
; the file, otherwise returns 0 on failure.
;
Q:'$G(DFN) 0
N QRYDT
S QRYDT=$O(^IVM(301.62,"ADT1",DFN,9999999.999999),-1)
Q:'QRYDT 0
Q $O(^IVM(301.62,"ADT1",DFN,QRYDT,0))
;
;
OPEN(DFN) ; Description: Used to determine if a patient has a financial query that is open (QUERY STATUS=TRANSMITTED).
;
; Input:
; DFN - ien of patient record in PATIENT file
;
; Output:
; Function Value - returns 1 if open query, otherwise returns 0.
;
N IVMQRY,IVMIEN,OPEN
S OPEN=0
S IVMIEN=$$LASTQRY($G(DFN))
I IVMIEN,$$GET(IVMIEN,.IVMQRY) D
.I 'IVMQRY("STATUS") S OPEN=1
Q OPEN
;
SENT(DFN,IVMDT) ; Description: Used to determine if a query was sent for a patien on a specific date.
;
; Input:
; DFN - IEN of patient record in PATIENT file
; IVMDT - (optional) Date/Time - default TODAY
;
; Output:
; Function Value: returns 1 if query sent on date, 0 otherwise.
;
N IVMIDT,IVMIEN,IVMLDT,IVMQRY,SAMEDAY
;
S SAMEDAY=0
I '$G(DFN) G SENTQ
S IVMIDT=$S($G(IVMDT)>0:IVMDT,1:DT) S:'$P(IVMIDT,".",2) IVMIDT=IVMIDT_.999999
S IVMIEN=$$LASTQRY(DFN)
I IVMIEN,$$GET(IVMIEN,.IVMQRY) D
.I $P(IVMIDT,".")=$P(IVMQRY("SENT"),".") S SAMEDAY=1
;
SENTQ Q SAMEDAY
;
;
QRYQUE(DFN) ; Description: Queue off job to send a financial query to the
; the HEC. This does first check to see if a query is needed.
;
; Input:
; DFN - ien of patient record in PATIENT file
;
; Output: none
;
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S ZTDESC="IVM Financial Query" ; task description
S ZTDTH=$H ; task start time
S ZTRTN="QUERY^IVMCQ2(DFN)" ; entry point of tasked routine
S ZTSAVE("DFN")="" ; input parameters
S ZTIO="" ; i/o device - (not needed)
D ^%ZTLOAD
Q
;
QRYQUE2(DFN,DUZ,NOTIFY,OPTION) ; Description: Queue off job to send a financial query to the
; the HEC. This version does NOT first check to see if a query is
; needed, but does check to see if a query is currently open.
;
; Input:
; DFN - ien of patient record in PATIENT file
; DUZ (optional)
; NOTIFY - (optional) 1 if the user requested notification when reply received
; OPTION - (optional) the option where the query was requested
;
; Output: none
;
N ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
S ZTDESC="IVM Financial Query" ; task description
S ZTDTH=$H ; task start time
S ZTRTN="QUERY2^IVMCQ1(DFN,$G(DUZ),$G(NOTIFY),$G(OPTION),,1)" ; entry point of tasked routine
S ZTSAVE("DFN")="",ZTSAVE("DUZ")="",ZTSAVE("NOTIFY")="",ZTSAVE("OPTION")=""
S ZTIO="" ; i/o device - (not needed)
D ^%ZTLOAD
Q
;
QUERY(DFN) ; Description: Determine if a financial query should be sent to the HEC.
;
; Input:
; DFN - ien of patient record in PATIENT file
;
; Output: none
;
;
I '$G(DFN) Q
I '$$NEED^IVMCQ(DFN,0) Q
;
; send query for patient
I $$QUERY^IVMCQ1(DFN)
;
Q
;
;
NOTIFY(QRYIEN) ; Description: Send notification message of reply received for financial query.
;
; Input:
; QRYIEN - ien of record in IVM FINANCIAL QUERY LOG file
;
; Output:
; Function Value: 1 on success, 0 on failure
;
N DIFROM,IVMTEXT,PATIENT,QARRAY,SUCCESS,XMDUZ,XMTEXT,XMSUB,XMY,XMZ
;
S SUCCESS=0
;
I '$G(QRYIEN) G MSGQ
;
; obtain record from IVM FINANCIAL QUERY LOG
I '$$GET(QRYIEN,.QARRAY) G MSGQ
;
; check NOTIFY FLAG
I '$G(QARRAY("NOTIFY")) G MSGQ
;
; obtain patient identifiers
I '$$GETPAT^IVMUFNC($G(QARRAY("DFN")),.PATIENT) G MSGQ
;
; build notification message
S XMDUZ="IVM PACKAGE"
S XMY(QARRAY("TRANBY")_"@"_$G(^XMB("NETNAME")))=""
S XMSUB="Financial Query Reply for: "_PATIENT("NAME")_" ("_PATIENT("SSN")_")"
S XMTEXT="IVMTEXT("
S IVMTEXT(1)="A reply to the financial query that you sent has been received."
S IVMTEXT(2)=" "
S IVMTEXT(3)=" Patient Name: "_PATIENT("NAME")
S IVMTEXT(4)=" Patient SSN: "_PATIENT("SSN")
S IVMTEXT(5)=" "
S IVMTEXT(6)=" Query Transmission Date/Time: "_$$EXTERNAL^DILFD(301.62,.02,"F",QARRAY("SENT"))
S IVMTEXT(7)=" Query Response Date/Time: "_$$EXTERNAL^DILFD(301.62,.06,"F",QARRAY("RESPONSE"))
S IVMTEXT(8)=" "
S IVMTEXT(9)=" Closure Reason: "_$$EXTERNAL^DILFD(301.62,1.01,"F",QARRAY("CLOSURE RSN"))
S IVMTEXT(10)=" Closure Source: "_$$EXTERNAL^DILFD(301.62,1.03,"F",QARRAY("CLOSURE SRC"))
;
D ^XMD
;
S SUCCESS=1
;
MSGQ Q SUCCESS
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMCQ2 9629 printed Dec 13, 2024@02:01:37 Page 2
IVMCQ2 ;ALB/KCL - API FOR FINANCIAL QUERIES (continued) ; 27-APR-95
+1 ;;2.0;INCOME VERIFICATION MATCH;**17**;21-OCT-94
+2 ;
+3 ;
MONITOR ; Description: This entry point is used to monitor the IVM FINANCIAL
+1 ; QUERY LOG file and check for query transmissions that have not been
+2 ; responded to for more than 2 days. If a query is > 2 days old, the
+3 ; corresponding entry in the IVM FINANCIAL QUERY LOG file will be
+4 ; updated/closed and a new financial query may be sent.
+5 ;
+6 NEW IVMQLOG,QRYIEN,%
+7 ;
+8 ; roll through query log entries with 'open' status
+9 SET QRYIEN=0
FOR
SET QRYIEN=$ORDER(^IVM(301.62,"AC",0,QRYIEN))
if 'QRYIEN
QUIT
Begin DoDot:1
+10 ;
+11 ; obtain record from IVM FINANCIAL QUERY LOG
+12 if '$$GET(+QRYIEN,.IVMQLOG)
QUIT
+13 ;
+14 ; quit if query msg not old enough
+15 if IVMQLOG("SENT")>$$FMADD^XLFDT(DT,-2)
QUIT
+16 ;
+17 ; update/auto-close query in IVM FINANCIAL QUERY LOG file
+18 DO NOW^%DTC
DO UPD(IVMQLOG("DFN"),+QRYIEN,%,6,2)
+19 ;
+20 ; quit if new query is not needed
+21 if '$$NEED^IVMCQ(IVMQLOG("DFN"))
QUIT
+22 ;
+23 ; send new query
+24 IF $$QUERY^IVMCQ1(IVMQLOG("DFN"),IVMQLOG("TRANBY"),IVMQLOG("NOTIFY"),IVMQLOG("OPTION"))
End DoDot:1
+25 ;
+26 QUIT
+27 ;
+28 ;
FIND(DFN,IVMMSG,IVMRECD,IVMCR,IVMCS) ; Description: Used to find and update
+1 ; entry in IVM FINANCIAL QUERY LOG file.
+2 ;
+3 ; Input:
+4 ; DFN - ien of patient record in PATIENT file
+5 ; IVMMSG - query message id
+6 ; IVMRECD - date/time query response received
+7 ; IVMCR - query closure reason code
+8 ; IVMCS - query closure source (1|DCD -- 2|DHCP)
+9 ;
+10 ; Output: none
+11 ;
+12 IF '$GET(DFN)!'$GET(IVMCR)!'$GET(IVMCS)
GOTO FINDQ
+13 NEW IVM,IVMD
+14 SET IVM=0
FOR
SET IVM=$ORDER(^IVM(301.62,"B",DFN,IVM))
if 'IVM
QUIT
Begin DoDot:1
+15 SET IVMD=$GET(^IVM(301.62,+IVM,0))
+16 ; message, query ID's not same
if $PIECE(IVMD,"^",5)'=$GET(IVMMSG)
QUIT
+17 DO UPD(DFN,+IVM,$GET(IVMRECD),IVMCR,IVMCS)
End DoDot:1
FINDQ QUIT
+1 ;
+2 ;
UPD(DFN,IVMDA,IVMRECD,IVMCR,IVMCS) ; Description: Used to update record found in IVM FINANCIAL QUERY LOG file.
+1 ;
+2 ; Input:
+3 ; DFN - ien of patient record in PATIENT file
+4 ; IVMMSG - query message id
+5 ; IVMRECD - date/time query response received
+6 ; IVMCR - query closure reason code
+7 ; IVMCS - query closure source (1|DCD -- 2|DHCP)
+8 ;
+9 ; Output: none
+10 ;
+11 IF '$GET(DFN)!'$GET(IVMDA)!'$GET(IVMCR)!'$GET(IVMCS)
GOTO FINDQ
+12 NEW DA,DIE,DR,IVMCRP,IVMOPT
+13 SET IVMCRP=$ORDER(^IVM(301.94,"AC",IVMCR,0))
if 'IVMCRP
SET IVMCRP=IVMCR
+14 SET DIE="^IVM(301.62,"
SET DA=IVMDA
+15 SET DR=".03////1"_$SELECT($GET(IVMRECD):";.06////"_IVMRECD,1:"")
+16 SET DR=DR_";1.01////"_IVMCRP_";1.02///NOW;1.03////"_IVMCS
+17 DO ^DIE
+18 ;
+19 ; determine if query reply requires user notification
+20 IF '$$NOTIFY(IVMDA)
+21 ;
UPDQ QUIT
+1 ;
+2 ;
FINDMSG(MSGID) ;
+1 ; Description: Used to find a record in the IVM FINANCIAL QUERY LOG
+2 ; file, given the unique message id assigned to the query by the
+3 ; HL7 package.
+4 ;
+5 ; Input:
+6 ; MSGID - The unique id assigned to the query by the HL7 package and
+7 ; stored in the IVM FINANCIAL QUERY LOG as the HL7 MESSAGE
+8 ; CONTROL ID field.
+9 ;
+10 ; Output:
+11 ; Function Value - If successful, returns the ien of the record in
+12 ; the file, otherwise returns 0 on failure.
+13 ;
+14 if ($GET(MSGID)="")
QUIT 0
+15 QUIT +$ORDER(^IVM(301.62,"C",MSGID,0))
+16 ;
+17 ;
GET(IEN,IVMQRY) ;
+1 ; Description: Used to obtain a record in the IVM FINANCIAL QUERY LOG
+2 ; file. The values are returned in the IVMQRY() array.
+3 ;
+4 ; Input:
+5 ; IEN - internal entry number of a record in the IVM FINANCIAL QUERY LOG file.
+6 ;
+7 ; Output:
+8 ; Function Value - 1 on success, 0 on failure.
+9 ; IVMQRY() array, pass by reference. Subscripts are:
+10 ; "DFN" - PATIENT field
+11 ; "SENT" - QUERY TRANS DT/TM field
+12 ; "STATUS" - QUERY STATUS field
+13 ; "TRANBY" - TRANSMITTED BY field
+14 ; "MSGID" - HL7 MESSAGE CONTROL ID field
+15 ; "RESPONSE" - QUERY RESPONSE REC'D DT/TM field
+16 ; "OPTION" - DHCP OPTION field
+17 ; "NOTIFY" - NOTIFY FLAG field
+18 ; "CLOSURE RSN" - CLOSURE REASON field
+19 ; "CLOSURE" - CLOSURE DT/TM field
+20 ; "CLOSURE SRC" - CLOSURE SOURCE field
+21 ;
+22 NEW IVMNODE
+23 KILL IVMQRY
SET IVMQRY=""
+24 if '$GET(IEN)
QUIT 0
+25 ;
+26 SET IVMNODE=$GET(^IVM(301.62,IEN,0))
+27 if IVMNODE=""
QUIT 0
+28 ;
+29 SET IVMQRY("DFN")=$PIECE(IVMNODE,"^")
+30 SET IVMQRY("SENT")=$PIECE(IVMNODE,"^",2)
+31 SET IVMQRY("STATUS")=$PIECE(IVMNODE,"^",3)
+32 SET IVMQRY("TRANBY")=$PIECE(IVMNODE,"^",4)
+33 SET IVMQRY("MSGID")=$PIECE(IVMNODE,"^",5)
+34 SET IVMQRY("RESPONSE")=$PIECE(IVMNODE,"^",6)
+35 SET IVMQRY("OPTION")=$PIECE(IVMNODE,"^",7)
+36 SET IVMQRY("NOTIFY")=$PIECE(IVMNODE,"^",8)
+37 ;
+38 SET IVMNODE=$GET(^IVM(301.62,IEN,1))
+39 SET IVMQRY("CLOSURE RSN")=$PIECE(IVMNODE,"^")
+40 SET IVMQRY("CLOSURE")=$PIECE(IVMNODE,"^",2)
+41 SET IVMQRY("CLOSURE SRC")=$PIECE(IVMNODE,"^",3)
+42 ;
+43 QUIT 1
+44 ;
+45 ;
DELETE(IEN) ;
+1 ; Description: Delete record in the IVM FINANCIAL QUERY LOG file,
+2 ; given the internal entry number (IEN).
+3 ;
+4 ; Input:
+5 ; IEN - The internal entry number of the record.
+6 ;
+7 ; Output:
+8 ; Function Value - 1 on success, 0 on failure.
+9 ;
+10 if '$GET(IEN)
QUIT 0
+11 NEW DIK,DA
+12 SET DIK="^IVM(301.62,"
+13 SET DA=IEN
+14 DO ^DIK
+15 QUIT 1
+16 ;
+17 ;
LASTQRY(DFN) ; Description: Used to find the last financial query for a patient.
+1 ;
+2 ; Input:
+3 ; DFN - ien of patient record in PATIENT file
+4 ;
+5 ; Output:
+6 ; Function Value - If successful, returns the ien of the record in
+7 ; the file, otherwise returns 0 on failure.
+8 ;
+9 if '$GET(DFN)
QUIT 0
+10 NEW QRYDT
+11 SET QRYDT=$ORDER(^IVM(301.62,"ADT1",DFN,9999999.999999),-1)
+12 if 'QRYDT
QUIT 0
+13 QUIT $ORDER(^IVM(301.62,"ADT1",DFN,QRYDT,0))
+14 ;
+15 ;
OPEN(DFN) ; Description: Used to determine if a patient has a financial query that is open (QUERY STATUS=TRANSMITTED).
+1 ;
+2 ; Input:
+3 ; DFN - ien of patient record in PATIENT file
+4 ;
+5 ; Output:
+6 ; Function Value - returns 1 if open query, otherwise returns 0.
+7 ;
+8 NEW IVMQRY,IVMIEN,OPEN
+9 SET OPEN=0
+10 SET IVMIEN=$$LASTQRY($GET(DFN))
+11 IF IVMIEN
IF $$GET(IVMIEN,.IVMQRY)
Begin DoDot:1
+12 IF 'IVMQRY("STATUS")
SET OPEN=1
End DoDot:1
+13 QUIT OPEN
+14 ;
SENT(DFN,IVMDT) ; Description: Used to determine if a query was sent for a patien on a specific date.
+1 ;
+2 ; Input:
+3 ; DFN - IEN of patient record in PATIENT file
+4 ; IVMDT - (optional) Date/Time - default TODAY
+5 ;
+6 ; Output:
+7 ; Function Value: returns 1 if query sent on date, 0 otherwise.
+8 ;
+9 NEW IVMIDT,IVMIEN,IVMLDT,IVMQRY,SAMEDAY
+10 ;
+11 SET SAMEDAY=0
+12 IF '$GET(DFN)
GOTO SENTQ
+13 SET IVMIDT=$SELECT($GET(IVMDT)>0:IVMDT,1:DT)
if '$PIECE(IVMIDT,".",2)
SET IVMIDT=IVMIDT_.999999
+14 SET IVMIEN=$$LASTQRY(DFN)
+15 IF IVMIEN
IF $$GET(IVMIEN,.IVMQRY)
Begin DoDot:1
+16 IF $PIECE(IVMIDT,".")=$PIECE(IVMQRY("SENT"),".")
SET SAMEDAY=1
End DoDot:1
+17 ;
SENTQ QUIT SAMEDAY
+1 ;
+2 ;
QRYQUE(DFN) ; Description: Queue off job to send a financial query to the
+1 ; the HEC. This does first check to see if a query is needed.
+2 ;
+3 ; Input:
+4 ; DFN - ien of patient record in PATIENT file
+5 ;
+6 ; Output: none
+7 ;
+8 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+9 ; task description
SET ZTDESC="IVM Financial Query"
+10 ; task start time
SET ZTDTH=$HOROLOG
+11 ; entry point of tasked routine
SET ZTRTN="QUERY^IVMCQ2(DFN)"
+12 ; input parameters
SET ZTSAVE("DFN")=""
+13 ; i/o device - (not needed)
SET ZTIO=""
+14 DO ^%ZTLOAD
+15 QUIT
+16 ;
QRYQUE2(DFN,DUZ,NOTIFY,OPTION) ; Description: Queue off job to send a financial query to the
+1 ; the HEC. This version does NOT first check to see if a query is
+2 ; needed, but does check to see if a query is currently open.
+3 ;
+4 ; Input:
+5 ; DFN - ien of patient record in PATIENT file
+6 ; DUZ (optional)
+7 ; NOTIFY - (optional) 1 if the user requested notification when reply received
+8 ; OPTION - (optional) the option where the query was requested
+9 ;
+10 ; Output: none
+11 ;
+12 NEW ZTDESC,ZTDTH,ZTIO,ZTRTN,ZTSAVE,ZTSK
+13 ; task description
SET ZTDESC="IVM Financial Query"
+14 ; task start time
SET ZTDTH=$HOROLOG
+15 ; entry point of tasked routine
SET ZTRTN="QUERY2^IVMCQ1(DFN,$G(DUZ),$G(NOTIFY),$G(OPTION),,1)"
+16 SET ZTSAVE("DFN")=""
SET ZTSAVE("DUZ")=""
SET ZTSAVE("NOTIFY")=""
SET ZTSAVE("OPTION")=""
+17 ; i/o device - (not needed)
SET ZTIO=""
+18 DO ^%ZTLOAD
+19 QUIT
+20 ;
QUERY(DFN) ; Description: Determine if a financial query should be sent to the HEC.
+1 ;
+2 ; Input:
+3 ; DFN - ien of patient record in PATIENT file
+4 ;
+5 ; Output: none
+6 ;
+7 ;
+8 IF '$GET(DFN)
QUIT
+9 IF '$$NEED^IVMCQ(DFN,0)
QUIT
+10 ;
+11 ; send query for patient
+12 IF $$QUERY^IVMCQ1(DFN)
+13 ;
+14 QUIT
+15 ;
+16 ;
NOTIFY(QRYIEN) ; Description: Send notification message of reply received for financial query.
+1 ;
+2 ; Input:
+3 ; QRYIEN - ien of record in IVM FINANCIAL QUERY LOG file
+4 ;
+5 ; Output:
+6 ; Function Value: 1 on success, 0 on failure
+7 ;
+8 NEW DIFROM,IVMTEXT,PATIENT,QARRAY,SUCCESS,XMDUZ,XMTEXT,XMSUB,XMY,XMZ
+9 ;
+10 SET SUCCESS=0
+11 ;
+12 IF '$GET(QRYIEN)
GOTO MSGQ
+13 ;
+14 ; obtain record from IVM FINANCIAL QUERY LOG
+15 IF '$$GET(QRYIEN,.QARRAY)
GOTO MSGQ
+16 ;
+17 ; check NOTIFY FLAG
+18 IF '$GET(QARRAY("NOTIFY"))
GOTO MSGQ
+19 ;
+20 ; obtain patient identifiers
+21 IF '$$GETPAT^IVMUFNC($GET(QARRAY("DFN")),.PATIENT)
GOTO MSGQ
+22 ;
+23 ; build notification message
+24 SET XMDUZ="IVM PACKAGE"
+25 SET XMY(QARRAY("TRANBY")_"@"_$GET(^XMB("NETNAME")))=""
+26 SET XMSUB="Financial Query Reply for: "_PATIENT("NAME")_" ("_PATIENT("SSN")_")"
+27 SET XMTEXT="IVMTEXT("
+28 SET IVMTEXT(1)="A reply to the financial query that you sent has been received."
+29 SET IVMTEXT(2)=" "
+30 SET IVMTEXT(3)=" Patient Name: "_PATIENT("NAME")
+31 SET IVMTEXT(4)=" Patient SSN: "_PATIENT("SSN")
+32 SET IVMTEXT(5)=" "
+33 SET IVMTEXT(6)=" Query Transmission Date/Time: "_$$EXTERNAL^DILFD(301.62,.02,"F",QARRAY("SENT"))
+34 SET IVMTEXT(7)=" Query Response Date/Time: "_$$EXTERNAL^DILFD(301.62,.06,"F",QARRAY("RESPONSE"))
+35 SET IVMTEXT(8)=" "
+36 SET IVMTEXT(9)=" Closure Reason: "_$$EXTERNAL^DILFD(301.62,1.01,"F",QARRAY("CLOSURE RSN"))
+37 SET IVMTEXT(10)=" Closure Source: "_$$EXTERNAL^DILFD(301.62,1.03,"F",QARRAY("CLOSURE SRC"))
+38 ;
+39 DO ^XMD
+40 ;
+41 SET SUCCESS=1
+42 ;
MSGQ QUIT SUCCESS