IVMTLOG ;ALB/CJM - API for IVM TRANSMISSION LOG file; 4-SEP-97
;;2.0;INCOME VERIFICATION MATCH;**9**; 21-OCT-94
;;Per VHA Directive 10-93-142, this routine should not be modified.
;
LOCK(IEN) ;
;Description: Locks a record in the IVM TRANSMISSION LOG file.
;Input:
; IEN - ien of record in IVM TRANSMISSION LOG file.
;Output:
; Function Value - 1 if successful, 0 otherwise.
;
I $G(IEN) L +^IVM(301.6,IEN):3
Q $T
;
UNLOCK(IEN) ;
;Description: Unlocks a record in the IVM TRANSMISSION LOG file.
;Input:
; IEN - ien of record in the IVM TRANSMISSION LOG file.
;Output: None
;
I $G(IEN) L -^IVM(301.6,IEN)
Q
;
SETSTAT(IEN,STATUS,ERROR) ;
;Description: Sets the value of the STATUS field of the
; IVM TRANSMISSION LOG file for a particular record.
;Input:
; IEN - internal entry number of a record in IVM TRANSMISSION LOG file.
; STATUS - status code - 1:RECEIVED, 0:TRANSMITTED, 2:RE-TRANSMITTED, 3:ERROR IN TRANSMITTED RECORD
; ERROR - optional - text error message
;Output:
; Function Value - 1 on success, 0 on failure.
;
Q:'$$TESTVAL^DGENDBS(301.6,.03,STATUS) 0
;
N DATA,RET
Q:'$$LOCK($G(IEN)) 0
S DATA(.03)=STATUS
I $G(ERROR)'="" S DATA(.04)=$E(ERROR,1,80)
;
;DATE/TIME ACK RECEIVED should only be entered for appropriate status
I (STATUS=1)!(STATUS=3) D
.S DATA(.06)=$$NOW^XLFDT
E S DATA(.06)="@"
;
;ERROR PROCESSING STATUS should only be entered if error status
I (STATUS=3) D
.S DATA(.07)=1
E S DATA(.07)="@"
;
S RET=$$UPD^DGENDBS(301.6,IEN,.DATA)
D UNLOCK(IEN)
Q RET
;
ERRSTAT(IEN,STATUS,ERROR) ;
;Description: Sets the ERROR PROCESSING STATUS field of a record in the IVM TRANSMISSION LOG file.
;
;Input:
; IEN - ien of record in IVM TRANSMISSION LOG file.
; STATUS - error processing status code
;Output:
; Function Value - 1 if successful, 0 otherwise.
; ERROR - error message (optional), pass by reference - will return message on failure
;
N DATA,RET
;
S ERROR=""
I '$$TESTVAL^DGENDBS(301.6,.07,STATUS) S ERROR="INVALID TRANSMISSION PROCESSING STATUS" Q 0
I '$G(IEN) S ERROR="NO RECORD SPECIFIED" Q 0
I $P(^IVM(301.6,IEN,0),"^",3)'=3 S ERROR="STATUS IS NOT 'ERROR IN TRANSMITTED RECORD'" Q 0
I '$$LOCK($G(IEN)) S ERROR="COULD NOT OBTAIN LOCK ON RECORD" Q 0
S DATA(.07)=STATUS
S RET=$$UPD^DGENDBS(301.6,IEN,.DATA,.ERROR)
D UNLOCK(IEN)
Q RET
;
GET(IEN,TLOG) ;
;Description: Used to obtain a record in the IVM TRANSMISSION LOG file. The
;values are returned in the TLOG() array.
;Input:
; IEN - internal entry number of a record in the IVM TRANSMISSION LOG file.
;Output:
; Function Value - 1 on success, 0 on failure.
; TLOG() array, pass by reference. Subscripts are
; "PAT" - value of the IVM PATIENT field (#.01) which is the ien of record in the IVM PATIENT file.
; "DFN" - ien, PATIENT file
; "DT/TM SENT" - value of the TRANSMISSION DATE/TIME field (#.02)
; "STATUS" - value of the STATUS field (#.03)
; "ERROR" - value of the ERROR MESSAGE field (#.04)
; "MSGID" - value of the MESSAGE CONTROL ID field (#.05)
; "EVENTS","IVM" - value of the IVM EVENT (#30.01) field
; "EVENTS","DCD" - value of the DCD EVENT (#30.02) field
; "EVENTS","ENROLL" - value of the ENROLLMENT EVENT (#30.03) field
; "DT/TM ACK" - value of the DATE/TIME ACK RECEIVED (#.06) field
; "ERROR STATUS" - value of the ERROR PROCESSING STATUS (#.07) field
; "MT STATUS" - value of the MEANS TEST STATUS field (#1.01)
; "INS STATUS" - value of the INSURANCE STATUS field (#1.02)
;
N NODE
K TLOG S TLOG=""
Q:'$G(IEN) 0
S NODE=$G(^IVM(301.6,IEN,0))
Q:(NODE="") 0
S TLOG("PAT")=$P(NODE,"^")
S TLOG("DFN")=$S(TLOG("PAT"):$P(^IVM(301.5,TLOG("PAT"),0),"^"),1:"")
S TLOG("DT/TM SENT")=$P(NODE,"^",2)
S TLOG("STATUS")=$P(NODE,"^",3)
S TLOG("ERROR")=$P(NODE,"^",4)
S TLOG("MSGID")=$P(NODE,"^",5)
S TLOG("DT/TM ACK")=$P(NODE,"^",6)
S TLOG("ERROR STATUS")=$P(NODE,"^",7)
S NODE=$G(^IVM(301.6,IEN,"E"))
S TLOG("EVENTS","IVM")=$P(NODE,"^")
S TLOG("EVENTS","DCD")=$P(NODE,"^",2)
S TLOG("EVENTS","ENROLL")=$P(NODE,"^",3)
S NODE=$G(^IVM(301.6,IEN,1))
S TLOG("MT STATUS")=$P(NODE,"^")
S TLOG("INS STATUS")=$P(NODE,"^",2)
Q 1
;
LOG(PAT,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
;Description: Called after completing a transmission for a particular
;patient. It creates a new record in the IVM TRANSMISSION LOG file.
;
;Input:
; PAT - ien of record in the IVM PATIENT file.
; WHEN - date/time message sent, in FM format.
; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
; EVENTS () - an array of reasons for transmission, pass by reference.
; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
; EVENTS("DCD")=1 if transmission due to DCD criteria, 0 otherwise
; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
; MTSTAT - pointer to the MEANS TEST STATUS file. Is the status of the patient's means test at the time of the transmission for the income year of the transmission. (Optional)
; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise. (Optional)
;
;Output:
; Function Value - If successful, returns the internal entry number of the record in the IVM TRANSMSISION LOG file, otherwise returns NULL.
;
Q:'$$TESTVAL^DGENDBS(301.6,.01,PAT) ""
Q:'$$TESTVAL^DGENDBS(301.6,.02,WHEN) ""
;
;skip this test - msgid is created by HL7 pkg, they can change it, so do not want to pass it by IVM's input transform
;Q:'$$TESTVAL^DGENDBS(301.6,.05,MSGID) ""
;
I ($G(MTSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.01,MTSTAT) Q ""
I ($G(INSSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.02,INSSTAT) Q ""
;
N DATA
S DATA(.01)=PAT,DATA(.02)=WHEN,DATA(.03)=0,DATA(.05)=MSGID
S:($G(MTSTAT)'="") DATA(1.01)=MTSTAT
S:($G(INSSTAT)'="") DATA(1.02)=INSSTAT
S:($G(EVENTS("IVM"))=1) DATA(30.01)=1
S:($G(EVENTS("DCD"))=1) DATA(30.02)=1
S:($G(EVENTS("ENROLL"))=1) DATA(30.03)=1
Q $$ADD^DGENDBS(301.6,,.DATA)
;
DELETE(IEN) ;
;Description: Used to delete a record in the IVM TRANSMISSION LOG file.
;
;Input:
; IEN - the internal entry number for a record in the IVM TRANSMISSION LOG file
;Output:
; Function Value - 1 on success, 0 on failure
;
Q:'$G(IEN) 1
;
Q:'$$LOCK(IEN) 0
;
N DIK,DA
S DIK="^IVM(301.6,"
S DA=IEN
D ^DIK
D UNLOCK(IEN)
Q 1
;
EXT(SUB,VAL) ;
;Description: Given the subscript used in the IVM TRANSMISSION LOG
; array and a field value, returns the external representation of the
; value, as defined in the fields output transform of the IVM
; TRANSMISSION LOG file.
;Input:
; SUB - array subscript
; VAL - field value
;Output:
; Function Value - returns the external value of the field
;
Q:(($G(SUB)="")!($G(VAL)="")) ""
;
N FLD
S FLD=$S(SUB="PAT":.01,SUB="DT/TM SENT":.02,SUB="STATUS":.03,SUB="ERROR":.04,SUB="MSGID":.05,SUB="DT/TM ACK":.06,SUB="ERROR STATUS":.07,SUB="IVM":30.01,SUB="DCD":30.02,SUB="ENROLL":30.03,SUB="MT STATUS":1.01,SUB="INS STATUS":1.02,1:"")
;
Q:(FLD="") ""
Q $$EXTERNAL^DILFD(301.6,FLD,"F",VAL)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMTLOG 7237 printed Oct 16, 2024@18:03:25 Page 2
IVMTLOG ;ALB/CJM - API for IVM TRANSMISSION LOG file; 4-SEP-97
+1 ;;2.0;INCOME VERIFICATION MATCH;**9**; 21-OCT-94
+2 ;;Per VHA Directive 10-93-142, this routine should not be modified.
+3 ;
LOCK(IEN) ;
+1 ;Description: Locks a record in the IVM TRANSMISSION LOG file.
+2 ;Input:
+3 ; IEN - ien of record in IVM TRANSMISSION LOG file.
+4 ;Output:
+5 ; Function Value - 1 if successful, 0 otherwise.
+6 ;
+7 IF $GET(IEN)
LOCK +^IVM(301.6,IEN):3
+8 QUIT $TEST
+9 ;
UNLOCK(IEN) ;
+1 ;Description: Unlocks a record in the IVM TRANSMISSION LOG file.
+2 ;Input:
+3 ; IEN - ien of record in the IVM TRANSMISSION LOG file.
+4 ;Output: None
+5 ;
+6 IF $GET(IEN)
LOCK -^IVM(301.6,IEN)
+7 QUIT
+8 ;
SETSTAT(IEN,STATUS,ERROR) ;
+1 ;Description: Sets the value of the STATUS field of the
+2 ; IVM TRANSMISSION LOG file for a particular record.
+3 ;Input:
+4 ; IEN - internal entry number of a record in IVM TRANSMISSION LOG file.
+5 ; STATUS - status code - 1:RECEIVED, 0:TRANSMITTED, 2:RE-TRANSMITTED, 3:ERROR IN TRANSMITTED RECORD
+6 ; ERROR - optional - text error message
+7 ;Output:
+8 ; Function Value - 1 on success, 0 on failure.
+9 ;
+10 if '$$TESTVAL^DGENDBS(301.6,.03,STATUS)
QUIT 0
+11 ;
+12 NEW DATA,RET
+13 if '$$LOCK($GET(IEN))
QUIT 0
+14 SET DATA(.03)=STATUS
+15 IF $GET(ERROR)'=""
SET DATA(.04)=$EXTRACT(ERROR,1,80)
+16 ;
+17 ;DATE/TIME ACK RECEIVED should only be entered for appropriate status
+18 IF (STATUS=1)!(STATUS=3)
Begin DoDot:1
+19 SET DATA(.06)=$$NOW^XLFDT
End DoDot:1
+20 IF '$TEST
SET DATA(.06)="@"
+21 ;
+22 ;ERROR PROCESSING STATUS should only be entered if error status
+23 IF (STATUS=3)
Begin DoDot:1
+24 SET DATA(.07)=1
End DoDot:1
+25 IF '$TEST
SET DATA(.07)="@"
+26 ;
+27 SET RET=$$UPD^DGENDBS(301.6,IEN,.DATA)
+28 DO UNLOCK(IEN)
+29 QUIT RET
+30 ;
ERRSTAT(IEN,STATUS,ERROR) ;
+1 ;Description: Sets the ERROR PROCESSING STATUS field of a record in the IVM TRANSMISSION LOG file.
+2 ;
+3 ;Input:
+4 ; IEN - ien of record in IVM TRANSMISSION LOG file.
+5 ; STATUS - error processing status code
+6 ;Output:
+7 ; Function Value - 1 if successful, 0 otherwise.
+8 ; ERROR - error message (optional), pass by reference - will return message on failure
+9 ;
+10 NEW DATA,RET
+11 ;
+12 SET ERROR=""
+13 IF '$$TESTVAL^DGENDBS(301.6,.07,STATUS)
SET ERROR="INVALID TRANSMISSION PROCESSING STATUS"
QUIT 0
+14 IF '$GET(IEN)
SET ERROR="NO RECORD SPECIFIED"
QUIT 0
+15 IF $PIECE(^IVM(301.6,IEN,0),"^",3)'=3
SET ERROR="STATUS IS NOT 'ERROR IN TRANSMITTED RECORD'"
QUIT 0
+16 IF '$$LOCK($GET(IEN))
SET ERROR="COULD NOT OBTAIN LOCK ON RECORD"
QUIT 0
+17 SET DATA(.07)=STATUS
+18 SET RET=$$UPD^DGENDBS(301.6,IEN,.DATA,.ERROR)
+19 DO UNLOCK(IEN)
+20 QUIT RET
+21 ;
GET(IEN,TLOG) ;
+1 ;Description: Used to obtain a record in the IVM TRANSMISSION LOG file. The
+2 ;values are returned in the TLOG() array.
+3 ;Input:
+4 ; IEN - internal entry number of a record in the IVM TRANSMISSION LOG file.
+5 ;Output:
+6 ; Function Value - 1 on success, 0 on failure.
+7 ; TLOG() array, pass by reference. Subscripts are
+8 ; "PAT" - value of the IVM PATIENT field (#.01) which is the ien of record in the IVM PATIENT file.
+9 ; "DFN" - ien, PATIENT file
+10 ; "DT/TM SENT" - value of the TRANSMISSION DATE/TIME field (#.02)
+11 ; "STATUS" - value of the STATUS field (#.03)
+12 ; "ERROR" - value of the ERROR MESSAGE field (#.04)
+13 ; "MSGID" - value of the MESSAGE CONTROL ID field (#.05)
+14 ; "EVENTS","IVM" - value of the IVM EVENT (#30.01) field
+15 ; "EVENTS","DCD" - value of the DCD EVENT (#30.02) field
+16 ; "EVENTS","ENROLL" - value of the ENROLLMENT EVENT (#30.03) field
+17 ; "DT/TM ACK" - value of the DATE/TIME ACK RECEIVED (#.06) field
+18 ; "ERROR STATUS" - value of the ERROR PROCESSING STATUS (#.07) field
+19 ; "MT STATUS" - value of the MEANS TEST STATUS field (#1.01)
+20 ; "INS STATUS" - value of the INSURANCE STATUS field (#1.02)
+21 ;
+22 NEW NODE
+23 KILL TLOG
SET TLOG=""
+24 if '$GET(IEN)
QUIT 0
+25 SET NODE=$GET(^IVM(301.6,IEN,0))
+26 if (NODE="")
QUIT 0
+27 SET TLOG("PAT")=$PIECE(NODE,"^")
+28 SET TLOG("DFN")=$SELECT(TLOG("PAT"):$PIECE(^IVM(301.5,TLOG("PAT"),0),"^"),1:"")
+29 SET TLOG("DT/TM SENT")=$PIECE(NODE,"^",2)
+30 SET TLOG("STATUS")=$PIECE(NODE,"^",3)
+31 SET TLOG("ERROR")=$PIECE(NODE,"^",4)
+32 SET TLOG("MSGID")=$PIECE(NODE,"^",5)
+33 SET TLOG("DT/TM ACK")=$PIECE(NODE,"^",6)
+34 SET TLOG("ERROR STATUS")=$PIECE(NODE,"^",7)
+35 SET NODE=$GET(^IVM(301.6,IEN,"E"))
+36 SET TLOG("EVENTS","IVM")=$PIECE(NODE,"^")
+37 SET TLOG("EVENTS","DCD")=$PIECE(NODE,"^",2)
+38 SET TLOG("EVENTS","ENROLL")=$PIECE(NODE,"^",3)
+39 SET NODE=$GET(^IVM(301.6,IEN,1))
+40 SET TLOG("MT STATUS")=$PIECE(NODE,"^")
+41 SET TLOG("INS STATUS")=$PIECE(NODE,"^",2)
+42 QUIT 1
+43 ;
LOG(PAT,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
+1 ;Description: Called after completing a transmission for a particular
+2 ;patient. It creates a new record in the IVM TRANSMISSION LOG file.
+3 ;
+4 ;Input:
+5 ; PAT - ien of record in the IVM PATIENT file.
+6 ; WHEN - date/time message sent, in FM format.
+7 ; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
+8 ; EVENTS () - an array of reasons for transmission, pass by reference.
+9 ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
+10 ; EVENTS("DCD")=1 if transmission due to DCD criteria, 0 otherwise
+11 ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
+12 ; MTSTAT - pointer to the MEANS TEST STATUS file. Is the status of the patient's means test at the time of the transmission for the income year of the transmission. (Optional)
+13 ; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise. (Optional)
+14 ;
+15 ;Output:
+16 ; Function Value - If successful, returns the internal entry number of the record in the IVM TRANSMSISION LOG file, otherwise returns NULL.
+17 ;
+18 if '$$TESTVAL^DGENDBS(301.6,.01,PAT)
QUIT ""
+19 if '$$TESTVAL^DGENDBS(301.6,.02,WHEN)
QUIT ""
+20 ;
+21 ;skip this test - msgid is created by HL7 pkg, they can change it, so do not want to pass it by IVM's input transform
+22 ;Q:'$$TESTVAL^DGENDBS(301.6,.05,MSGID) ""
+23 ;
+24 IF ($GET(MTSTAT)'="")
IF '$$TESTVAL^DGENDBS(301.6,1.01,MTSTAT)
QUIT ""
+25 IF ($GET(INSSTAT)'="")
IF '$$TESTVAL^DGENDBS(301.6,1.02,INSSTAT)
QUIT ""
+26 ;
+27 NEW DATA
+28 SET DATA(.01)=PAT
SET DATA(.02)=WHEN
SET DATA(.03)=0
SET DATA(.05)=MSGID
+29 if ($GET(MTSTAT)'="")
SET DATA(1.01)=MTSTAT
+30 if ($GET(INSSTAT)'="")
SET DATA(1.02)=INSSTAT
+31 if ($GET(EVENTS("IVM"))=1)
SET DATA(30.01)=1
+32 if ($GET(EVENTS("DCD"))=1)
SET DATA(30.02)=1
+33 if ($GET(EVENTS("ENROLL"))=1)
SET DATA(30.03)=1
+34 QUIT $$ADD^DGENDBS(301.6,,.DATA)
+35 ;
DELETE(IEN) ;
+1 ;Description: Used to delete a record in the IVM TRANSMISSION LOG file.
+2 ;
+3 ;Input:
+4 ; IEN - the internal entry number for a record in the IVM TRANSMISSION LOG file
+5 ;Output:
+6 ; Function Value - 1 on success, 0 on failure
+7 ;
+8 if '$GET(IEN)
QUIT 1
+9 ;
+10 if '$$LOCK(IEN)
QUIT 0
+11 ;
+12 NEW DIK,DA
+13 SET DIK="^IVM(301.6,"
+14 SET DA=IEN
+15 DO ^DIK
+16 DO UNLOCK(IEN)
+17 QUIT 1
+18 ;
EXT(SUB,VAL) ;
+1 ;Description: Given the subscript used in the IVM TRANSMISSION LOG
+2 ; array and a field value, returns the external representation of the
+3 ; value, as defined in the fields output transform of the IVM
+4 ; TRANSMISSION LOG file.
+5 ;Input:
+6 ; SUB - array subscript
+7 ; VAL - field value
+8 ;Output:
+9 ; Function Value - returns the external value of the field
+10 ;
+11 if (($GET(SUB)="")!($GET(VAL)=""))
QUIT ""
+12 ;
+13 NEW FLD
+14 SET FLD=$SELECT(SUB="PAT":.01,SUB="DT/TM SENT":.02,SUB="STATUS":.03,SUB="ERROR":.04,SUB="MSGID":.05,SUB="DT/TM ACK":.06,SUB="ERROR STATUS":.07,SUB="IVM":30.01,SUB="DCD":30.02,SUB="ENROLL":30.03,SUB="MT STATUS":1.01,SUB="INS STATUS":1.02,1:"")
+15 ;
+16 if (FLD="")
QUIT ""
+17 QUIT $$EXTERNAL^DILFD(301.6,FLD,"F",VAL)