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

IVMTLOG.m

Go to the documentation of this file.
  1. IVMTLOG ;ALB/CJM - API for IVM TRANSMISSION LOG file; 4-SEP-97
  1. ;;2.0;INCOME VERIFICATION MATCH;**9**; 21-OCT-94
  1. ;;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. LOCK(IEN) ;
  1. ;Description: Locks a record in the IVM TRANSMISSION LOG file.
  1. ;Input:
  1. ; IEN - ien of record in IVM TRANSMISSION LOG file.
  1. ;Output:
  1. ; Function Value - 1 if successful, 0 otherwise.
  1. ;
  1. I $G(IEN) L +^IVM(301.6,IEN):3
  1. Q $T
  1. ;
  1. UNLOCK(IEN) ;
  1. ;Description: Unlocks a record in the IVM TRANSMISSION LOG file.
  1. ;Input:
  1. ; IEN - ien of record in the IVM TRANSMISSION LOG file.
  1. ;Output: None
  1. ;
  1. I $G(IEN) L -^IVM(301.6,IEN)
  1. Q
  1. ;
  1. SETSTAT(IEN,STATUS,ERROR) ;
  1. ;Description: Sets the value of the STATUS field of the
  1. ; IVM TRANSMISSION LOG file for a particular record.
  1. ;Input:
  1. ; IEN - internal entry number of a record in IVM TRANSMISSION LOG file.
  1. ; STATUS - status code - 1:RECEIVED, 0:TRANSMITTED, 2:RE-TRANSMITTED, 3:ERROR IN TRANSMITTED RECORD
  1. ; ERROR - optional - text error message
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure.
  1. ;
  1. Q:'$$TESTVAL^DGENDBS(301.6,.03,STATUS) 0
  1. ;
  1. N DATA,RET
  1. Q:'$$LOCK($G(IEN)) 0
  1. S DATA(.03)=STATUS
  1. I $G(ERROR)'="" S DATA(.04)=$E(ERROR,1,80)
  1. ;
  1. ;DATE/TIME ACK RECEIVED should only be entered for appropriate status
  1. I (STATUS=1)!(STATUS=3) D
  1. .S DATA(.06)=$$NOW^XLFDT
  1. E S DATA(.06)="@"
  1. ;
  1. ;ERROR PROCESSING STATUS should only be entered if error status
  1. I (STATUS=3) D
  1. .S DATA(.07)=1
  1. E S DATA(.07)="@"
  1. ;
  1. S RET=$$UPD^DGENDBS(301.6,IEN,.DATA)
  1. D UNLOCK(IEN)
  1. Q RET
  1. ;
  1. ERRSTAT(IEN,STATUS,ERROR) ;
  1. ;Description: Sets the ERROR PROCESSING STATUS field of a record in the IVM TRANSMISSION LOG file.
  1. ;
  1. ;Input:
  1. ; IEN - ien of record in IVM TRANSMISSION LOG file.
  1. ; STATUS - error processing status code
  1. ;Output:
  1. ; Function Value - 1 if successful, 0 otherwise.
  1. ; ERROR - error message (optional), pass by reference - will return message on failure
  1. ;
  1. N DATA,RET
  1. ;
  1. S ERROR=""
  1. I '$$TESTVAL^DGENDBS(301.6,.07,STATUS) S ERROR="INVALID TRANSMISSION PROCESSING STATUS" Q 0
  1. I '$G(IEN) S ERROR="NO RECORD SPECIFIED" Q 0
  1. I $P(^IVM(301.6,IEN,0),"^",3)'=3 S ERROR="STATUS IS NOT 'ERROR IN TRANSMITTED RECORD'" Q 0
  1. I '$$LOCK($G(IEN)) S ERROR="COULD NOT OBTAIN LOCK ON RECORD" Q 0
  1. S DATA(.07)=STATUS
  1. S RET=$$UPD^DGENDBS(301.6,IEN,.DATA,.ERROR)
  1. D UNLOCK(IEN)
  1. Q RET
  1. ;
  1. GET(IEN,TLOG) ;
  1. ;Description: Used to obtain a record in the IVM TRANSMISSION LOG file. The
  1. ;values are returned in the TLOG() array.
  1. ;Input:
  1. ; IEN - internal entry number of a record in the IVM TRANSMISSION LOG file.
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure.
  1. ; TLOG() array, pass by reference. Subscripts are
  1. ; "PAT" - value of the IVM PATIENT field (#.01) which is the ien of record in the IVM PATIENT file.
  1. ; "DFN" - ien, PATIENT file
  1. ; "DT/TM SENT" - value of the TRANSMISSION DATE/TIME field (#.02)
  1. ; "STATUS" - value of the STATUS field (#.03)
  1. ; "ERROR" - value of the ERROR MESSAGE field (#.04)
  1. ; "MSGID" - value of the MESSAGE CONTROL ID field (#.05)
  1. ; "EVENTS","IVM" - value of the IVM EVENT (#30.01) field
  1. ; "EVENTS","DCD" - value of the DCD EVENT (#30.02) field
  1. ; "EVENTS","ENROLL" - value of the ENROLLMENT EVENT (#30.03) field
  1. ; "DT/TM ACK" - value of the DATE/TIME ACK RECEIVED (#.06) field
  1. ; "ERROR STATUS" - value of the ERROR PROCESSING STATUS (#.07) field
  1. ; "MT STATUS" - value of the MEANS TEST STATUS field (#1.01)
  1. ; "INS STATUS" - value of the INSURANCE STATUS field (#1.02)
  1. ;
  1. N NODE
  1. K TLOG S TLOG=""
  1. Q:'$G(IEN) 0
  1. S NODE=$G(^IVM(301.6,IEN,0))
  1. Q:(NODE="") 0
  1. S TLOG("PAT")=$P(NODE,"^")
  1. S TLOG("DFN")=$S(TLOG("PAT"):$P(^IVM(301.5,TLOG("PAT"),0),"^"),1:"")
  1. S TLOG("DT/TM SENT")=$P(NODE,"^",2)
  1. S TLOG("STATUS")=$P(NODE,"^",3)
  1. S TLOG("ERROR")=$P(NODE,"^",4)
  1. S TLOG("MSGID")=$P(NODE,"^",5)
  1. S TLOG("DT/TM ACK")=$P(NODE,"^",6)
  1. S TLOG("ERROR STATUS")=$P(NODE,"^",7)
  1. S NODE=$G(^IVM(301.6,IEN,"E"))
  1. S TLOG("EVENTS","IVM")=$P(NODE,"^")
  1. S TLOG("EVENTS","DCD")=$P(NODE,"^",2)
  1. S TLOG("EVENTS","ENROLL")=$P(NODE,"^",3)
  1. S NODE=$G(^IVM(301.6,IEN,1))
  1. S TLOG("MT STATUS")=$P(NODE,"^")
  1. S TLOG("INS STATUS")=$P(NODE,"^",2)
  1. Q 1
  1. ;
  1. LOG(PAT,WHEN,MSGID,EVENTS,MTSTAT,INSSTAT) ;
  1. ;Description: Called after completing a transmission for a particular
  1. ;patient. It creates a new record in the IVM TRANSMISSION LOG file.
  1. ;
  1. ;Input:
  1. ; PAT - ien of record in the IVM PATIENT file.
  1. ; WHEN - date/time message sent, in FM format.
  1. ; MSGID - message id used for message, in format used by MESSAGE CONTROL ID field.
  1. ; EVENTS () - an array of reasons for transmission, pass by reference.
  1. ; EVENTS("IVM") = 1 if transmission due to IVM criteria, 0 otherwise
  1. ; EVENTS("DCD")=1 if transmission due to DCD criteria, 0 otherwise
  1. ; EVENTS("ENROLL")=1 if transmission due to enrollment criteria, 0 otherwise
  1. ; 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)
  1. ; INSSTAT - 1 if the patient had active insurance at the time of the transmission, 0 otherwise. (Optional)
  1. ;
  1. ;Output:
  1. ; Function Value - If successful, returns the internal entry number of the record in the IVM TRANSMSISION LOG file, otherwise returns NULL.
  1. ;
  1. Q:'$$TESTVAL^DGENDBS(301.6,.01,PAT) ""
  1. Q:'$$TESTVAL^DGENDBS(301.6,.02,WHEN) ""
  1. ;
  1. ;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
  1. ;Q:'$$TESTVAL^DGENDBS(301.6,.05,MSGID) ""
  1. ;
  1. I ($G(MTSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.01,MTSTAT) Q ""
  1. I ($G(INSSTAT)'=""),'$$TESTVAL^DGENDBS(301.6,1.02,INSSTAT) Q ""
  1. ;
  1. N DATA
  1. S DATA(.01)=PAT,DATA(.02)=WHEN,DATA(.03)=0,DATA(.05)=MSGID
  1. S:($G(MTSTAT)'="") DATA(1.01)=MTSTAT
  1. S:($G(INSSTAT)'="") DATA(1.02)=INSSTAT
  1. S:($G(EVENTS("IVM"))=1) DATA(30.01)=1
  1. S:($G(EVENTS("DCD"))=1) DATA(30.02)=1
  1. S:($G(EVENTS("ENROLL"))=1) DATA(30.03)=1
  1. Q $$ADD^DGENDBS(301.6,,.DATA)
  1. ;
  1. DELETE(IEN) ;
  1. ;Description: Used to delete a record in the IVM TRANSMISSION LOG file.
  1. ;
  1. ;Input:
  1. ; IEN - the internal entry number for a record in the IVM TRANSMISSION LOG file
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure
  1. ;
  1. Q:'$G(IEN) 1
  1. ;
  1. Q:'$$LOCK(IEN) 0
  1. ;
  1. N DIK,DA
  1. S DIK="^IVM(301.6,"
  1. S DA=IEN
  1. D ^DIK
  1. D UNLOCK(IEN)
  1. Q 1
  1. ;
  1. EXT(SUB,VAL) ;
  1. ;Description: Given the subscript used in the IVM TRANSMISSION LOG
  1. ; array and a field value, returns the external representation of the
  1. ; value, as defined in the fields output transform of the IVM
  1. ; TRANSMISSION LOG file.
  1. ;Input:
  1. ; SUB - array subscript
  1. ; VAL - field value
  1. ;Output:
  1. ; Function Value - returns the external value of the field
  1. ;
  1. Q:(($G(SUB)="")!($G(VAL)="")) ""
  1. ;
  1. N FLD
  1. 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:"")
  1. ;
  1. Q:(FLD="") ""
  1. Q $$EXTERNAL^DILFD(301.6,FLD,"F",VAL)