HMPDJ02A ;ASMR/MKB/JD,CK,CPC,PB - Problems,Allergies,Vitals ;Jan 17, 2107 09:56:26
 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**3**;Jan 17, 2017;Build 15
 ;Per VA Directive 6402, this routine should not be modified.
 ;
 ; External References          DBIA#
 ; -------------------          ----- 
 ; ^AUPNVSIT(                    2028
 ;
 Q
GETVIEN(DFNN,VISITDT)  ;JL; get the Visit IEN from VISIT file based on patient ID and Datetime
 Q:'+$G(DFNN)!'$L(VISITDT) -1  ;return -1 if bad parameter
 N REVDT,VISITIEN
 S REVDT=9999999-$P(VISITDT,".",1)_$S($P(VISITDT,".",2)'="":"."_$P(VISITDT,".",2),1:"")
 S VISITIEN=$O(^AUPNVSIT("AA",DFNN,REVDT,""))  ; using "AA" cross-reference
 Q:VISITIEN="" -1
 Q VISITIEN
 ;
VSTIEN(VSTIEN) ; Jan 17, 2017 - PB - DE6877 - Function to check for the visit and the patient to exist for the visit in the Visit File
 ; INPUT - VSTIEN the IEN for the visit in the Visit File
 ; OUTPUT - 1 = missing required data element, 0 = required data elements are present
 N VSTDATA
 S VSTDATA=$G(^AUPNVSIT(VSTIEN,0))  ;ICR 2028
 Q:$P(VSTDATA,U)="" 1  ; if the .01 field is null quit and return 1
 Q:$P(VSTDATA,U,5)="" 1  ; if field .05 is null quit and return 1
 Q 0
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPDJ02A   1211     printed  Sep 23, 2025@19:29:19                                                                                                                                                                                                    Page 2
HMPDJ02A  ;ASMR/MKB/JD,CK,CPC,PB - Problems,Allergies,Vitals ;Jan 17, 2107 09:56:26
 +1       ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**3**;Jan 17, 2017;Build 15
 +2       ;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4       ; External References          DBIA#
 +5       ; -------------------          ----- 
 +6       ; ^AUPNVSIT(                    2028
 +7       ;
 +8        QUIT 
GETVIEN(DFNN,VISITDT) ;JL; get the Visit IEN from VISIT file based on patient ID and Datetime
 +1       ;return -1 if bad parameter
           if '+$GET(DFNN)!'$LENGTH(VISITDT)
               QUIT -1
 +2        NEW REVDT,VISITIEN
 +3        SET REVDT=9999999-$PIECE(VISITDT,".",1)_$SELECT($PIECE(VISITDT,".",2)'="":"."_$PIECE(VISITDT,".",2),1:"")
 +4       ; using "AA" cross-reference
           SET VISITIEN=$ORDER(^AUPNVSIT("AA",DFNN,REVDT,""))
 +5        if VISITIEN=""
               QUIT -1
 +6        QUIT VISITIEN
 +7       ;
VSTIEN(VSTIEN) ; Jan 17, 2017 - PB - DE6877 - Function to check for the visit and the patient to exist for the visit in the Visit File
 +1       ; INPUT - VSTIEN the IEN for the visit in the Visit File
 +2       ; OUTPUT - 1 = missing required data element, 0 = required data elements are present
 +3        NEW VSTDATA
 +4       ;ICR 2028
           SET VSTDATA=$GET(^AUPNVSIT(VSTIEN,0))
 +5       ; if the .01 field is null quit and return 1
           if $PIECE(VSTDATA,U)=""
               QUIT 1
 +6       ; if field .05 is null quit and return 1
           if $PIECE(VSTDATA,U,5)=""
               QUIT 1
 +7        QUIT 0