IVMPLOG2 ;ALB/CJM - API for IVM PATIENT file; 4-SEP-97
 ;;2.0;INCOME VERIFICATION MATCH;**9,17**; 21-OCT-94
 ;;Per VHA Directive 10-93-142, this routine should not be modified.
 ;
 ;
CLOSE(IEN,REASON,SOURCE) ;
 ;Description: Sets the value of the STOP FLAG field to 1 for a
 ;particular record in  the IVM PATIENT file, as well as setting related
 ;fields. This has the effect of stopping updates to a particular
 ;IVM PATIENT record for some types of events, but not for enrollment
 ;events.
 ;
 ;Input:
 ;  IEN - internal entry number of a record in the IVM PATIENT file.
 ;  REASON - ien of record in the IVM CASE CLOSURE REASON file (#301.93)
 ;  SOURCE - set of codes, 1= IVM CENTER (HEC), 2 = DHCP (local site)
 ;
 ;Output:  
 ;  Function Value - 1 on success, 0 on failure.
 ;
 N DATA,ERROR
 I $G(REASON)'="",'$$TESTVAL^DGENDBS(301.5,1.01,REASON) Q 0
 I $G(SOURCE)'="",'$$TESTVAL^DGENDBS(301.5,1.02,SOURCE) Q 0
 Q:'$$LOCK^IVMPLOG($G(IEN)) 0
 S DATA(.04)=1
 S DATA(1.01)=$G(REASON)
 S DATA(1.02)=$G(SOURCE)
 S DATA(1.03)=$$NOW^XLFDT
 S ERROR=$$UPD^DGENDBS(301.5,IEN,.DATA)
 D UNLOCK^IVMPLOG(IEN)
 Q ERROR
 ;
DELETE(IEN) ;
 ;Description: Used to delete a record in the IVM PATIENT file.
 ;
 ;Input:
 ;   IEN - the internal entry number for a record in the IVM PATIENT file
 ;Output:
 ;  Function Value - 1 on success, 0 on failure
 ;
 Q:'$G(IEN) 1
 ;
 Q:'$$LOCK^IVMPLOG(IEN) 0
 ;
 N DIK,DA
 S DIK="^IVM(301.5,"
 S DA=IEN
 D ^DIK
 D UNLOCK^IVMPLOG(IEN)
 Q 1
 ;
ADDFUTR(MTIEN) ;
 ;Adds a future test to the IVM Patient file.  MTIEN is the ien
 ;of the future test in the Annual Means Test file
 ;
 Q:'$G(MTIEN)
 ;
 N NODE,DFN,DATE,IVMPAT,DATA,YEAR,TYPE
 S NODE=$G(^DGMT(408.31,MTIEN,0))
 S DATE=+NODE
 Q:'DATE
 S YEAR=($E(DATE,1,3)-1)
 S DFN=$P(NODE,"^",2)
 Q:('DFN)
 S TYPE=$P(NODE,"^",19)
 I TYPE'=1,TYPE'=2 Q
 S IVMPAT=$$LOG^IVMPLOG(DFN,YEAR)
 Q:'IVMPAT
 S:(TYPE=1) DATA(.06)=MTIEN
 S:(TYPE=2) DATA(.07)=MTIEN
 I $$UPD^DGENDBS(301.5,IVMPAT,.DATA)
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIVMPLOG2   2028     printed  Sep 23, 2025@19:37:31                                                                                                                                                                                                    Page 2
IVMPLOG2  ;ALB/CJM - API for IVM PATIENT file; 4-SEP-97
 +1       ;;2.0;INCOME VERIFICATION MATCH;**9,17**; 21-OCT-94
 +2       ;;Per VHA Directive 10-93-142, this routine should not be modified.
 +3       ;
 +4       ;
CLOSE(IEN,REASON,SOURCE) ;
 +1       ;Description: Sets the value of the STOP FLAG field to 1 for a
 +2       ;particular record in  the IVM PATIENT file, as well as setting related
 +3       ;fields. This has the effect of stopping updates to a particular
 +4       ;IVM PATIENT record for some types of events, but not for enrollment
 +5       ;events.
 +6       ;
 +7       ;Input:
 +8       ;  IEN - internal entry number of a record in the IVM PATIENT file.
 +9       ;  REASON - ien of record in the IVM CASE CLOSURE REASON file (#301.93)
 +10      ;  SOURCE - set of codes, 1= IVM CENTER (HEC), 2 = DHCP (local site)
 +11      ;
 +12      ;Output:  
 +13      ;  Function Value - 1 on success, 0 on failure.
 +14      ;
 +15       NEW DATA,ERROR
 +16       IF $GET(REASON)'=""
               IF '$$TESTVAL^DGENDBS(301.5,1.01,REASON)
                   QUIT 0
 +17       IF $GET(SOURCE)'=""
               IF '$$TESTVAL^DGENDBS(301.5,1.02,SOURCE)
                   QUIT 0
 +18       if '$$LOCK^IVMPLOG($GET(IEN))
               QUIT 0
 +19       SET DATA(.04)=1
 +20       SET DATA(1.01)=$GET(REASON)
 +21       SET DATA(1.02)=$GET(SOURCE)
 +22       SET DATA(1.03)=$$NOW^XLFDT
 +23       SET ERROR=$$UPD^DGENDBS(301.5,IEN,.DATA)
 +24       DO UNLOCK^IVMPLOG(IEN)
 +25       QUIT ERROR
 +26      ;
DELETE(IEN) ;
 +1       ;Description: Used to delete a record in the IVM PATIENT file.
 +2       ;
 +3       ;Input:
 +4       ;   IEN - the internal entry number for a record in the IVM PATIENT file
 +5       ;Output:
 +6       ;  Function Value - 1 on success, 0 on failure
 +7       ;
 +8        if '$GET(IEN)
               QUIT 1
 +9       ;
 +10       if '$$LOCK^IVMPLOG(IEN)
               QUIT 0
 +11      ;
 +12       NEW DIK,DA
 +13       SET DIK="^IVM(301.5,"
 +14       SET DA=IEN
 +15       DO ^DIK
 +16       DO UNLOCK^IVMPLOG(IEN)
 +17       QUIT 1
 +18      ;
ADDFUTR(MTIEN) ;
 +1       ;Adds a future test to the IVM Patient file.  MTIEN is the ien
 +2       ;of the future test in the Annual Means Test file
 +3       ;
 +4        if '$GET(MTIEN)
               QUIT 
 +5       ;
 +6        NEW NODE,DFN,DATE,IVMPAT,DATA,YEAR,TYPE
 +7        SET NODE=$GET(^DGMT(408.31,MTIEN,0))
 +8        SET DATE=+NODE
 +9        if 'DATE
               QUIT 
 +10       SET YEAR=($EXTRACT(DATE,1,3)-1)
 +11       SET DFN=$PIECE(NODE,"^",2)
 +12       if ('DFN)
               QUIT 
 +13       SET TYPE=$PIECE(NODE,"^",19)
 +14       IF TYPE'=1
               IF TYPE'=2
                   QUIT 
 +15       SET IVMPAT=$$LOG^IVMPLOG(DFN,YEAR)
 +16       if 'IVMPAT
               QUIT 
 +17       if (TYPE=1)
               SET DATA(.06)=MTIEN
 +18       if (TYPE=2)
               SET DATA(.07)=MTIEN
 +19       IF $$UPD^DGENDBS(301.5,IVMPAT,.DATA)
 +20       QUIT