IVMPLOG ;ALB/CJM,RTK - API for IVM PATIENT file; ; 12/6/00 5:28pm ;;2.0;INCOME VERIFICATION MATCH;**9,19,12,21,17,28,36,40,49,68**; 21-OCT-94 ;;Per VHA Directive 10-93-142, this routine should not be modified. ; ; FIND(DFN,YEAR) ; ;Description: Looks up an entry in the IVM PATIENT file (#301.5). ;Input: ; DFN - IEN in the PATIENT file. ; YEAR - value for the INCOME YEAR field, a year in FM format. ;Output: ; Function Value - returns IEN of record if found, NULL otherwise. ; Q:('$G(DFN)!'$G(YEAR)) "" ; N YR S YR=$E(YEAR,1,3)_"0000" Q $O(^IVM(301.5,"APT",DFN,YR,0)) ; LOCK(IEN) ; ;Description: Locks a record in the IVM PATIENT file. ;Input: ; IEN - ien of record in IVM PATIENT file. ;Output: ; Function Value - 1 if successful, 0 otherwise. ; I $G(IEN) L +^IVM(301.5,IEN):3 Q $T ; UNLOCK(IEN) ; ;Description: Unlocks a record in the IVM PATIENT file. ;Input: ; IEN - ien of record in the IVM PATIENT file. ;Output: None ; I $G(IEN) L -^IVM(301.5,IEN) Q ; STATUS(IEN,EVENTS) ; ;Description: Returns the value of the TRANSMISSION STATUS field of the ; IVM PATIENT file. ; ;Input: ; IEN - internal entry number of a record in the IVM PATIENT file ;Output: ; Function Value -returns the value of the TRANSMISSION STATUS field ; EVENTS - optional, pass by reference. Will return the types of events logged. ; EVENTS("IVM") - value of IVM EVENT field ; EVENTS("DCD") - value of DCD EVENT field ; EVENTS("ENROLL") - value of ENROLLMENT EVENT field ; ; S EVENTS("IVM")="" S EVENTS("DCD")="" S EVENTS("ENROLL")="" ; Q:'$G(IEN) "" ; N NODE S NODE=$G(^IVM(301.5,IEN,"E")) S EVENTS("IVM")=$P(NODE,"^") S EVENTS("DCD")=$P(NODE,"^",2) S EVENTS("ENROLL")=$P(NODE,"^",3) Q $P($G(^IVM(301.5,IEN,0)),"^",3) ; SETSTAT(IEN,EVENTS,ERRMSG) ; ;Description: Sets the value of the TRANSMISSION STATUS field of the ; IVM PATIENT file for a particular record to 0, meaning transmission ; is requested. If the case is closed, depending on the event types, ; the TRANSMISSION STATUS may not be set. ;Input: ; IEN - internal entry number of a record in the IVM PATIENT file. ; 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 ;Output: ; Function Value - 1 on success, 0 on failure. ; ERRMSG - optional, pass by reference if needed, returns message on failure ; N DATA,CLOSED,SUCCESS ; I ($G(DGENUPLD)="ENROLLMENT/ELIGIBILITY UPLOAD IN PROGRESS") S ERRMSG="ENROLLMENT UPLOAD IN PROGRESS" Q 0 ; I '$$LOCK($G(IEN)) S ERRMSG="UNABLE TO OBTAIN LOCK ON IVM PATIENT, TRY AGAIN LATTER" Q 0 S CLOSED=$$CLOSED(IEN) S SUCCESS=0 I ('CLOSED)!(1=$G(EVENTS("ENROLL"))) D .S DATA(.03)=0 .I 'CLOSED D ..I $G(EVENTS("IVM"))=1 S DATA(30.01)=1 ..I $G(EVENTS("DCD"))=1 S DATA(30.02)=1 .I $G(EVENTS("ENROLL"))=1 S DATA(30.03)=1 .S SUCCESS=$$UPD^DGENDBS(301.5,IEN,.DATA,.ERRMSG) E S SUCCESS=0,ERRMSG="CASE IS CLOSED" D UNLOCK(IEN) Q SUCCESS ; CLEAR(IEN,WHEN) ; ; Description: Sets the value of the TRANSMISSION STATUS field of the ;IVM PATIENT file for a particular record to 1, meaning transmission ;already occurred. ; ;Input: ; IEN - internal entry number of record in IVM PATIENT file ; WHEN - optional, date/time in FM format that transmission occurred ;Output: ; Function Value - 1 on success, 0 on failure ; N SUCCESS,PLOG,DATA Q:'$$LOCK($G(IEN)) 0 Q:'$$GET(IEN,.PLOG) 0 S DATA(.03)=1 I PLOG("EVENTS","IVM")=1 S DATA(30.01)=2 I PLOG("EVENTS","DCD")=1 S DATA(30.02)=2 I PLOG("EVENTS","ENROLL")=1 S DATA(30.03)=2 I $G(WHEN),((PLOG("FIRST")'>0)!(WHEN