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

ACRFVLK3.m

Go to the documentation of this file.
ACRFVLK3 ;IHS/OIRM/DSD/EFG - VENDOR FILE LOOKUP 3 ; [ 04/23/2007  10:56 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**21,22**;NOV 5, 2001
 ;
 ;    New routine ACR*2.1*21.04 IM22466
 ;    Subroutines were moved here from ACRFVLK2 and heavily rewritten
 ;    due to routine size restrictions.
 ;    Heavily modified to remedy <SUBSCRIPT>IV+44^ACRFVLK2 error ACR*2.1*22.11c IM24263
 Q  ;MUST ENTER AT LINE LABEL
 ;
SUBH(ACT,ERR,VAR,HD1) ;
 ;
 S ERR=$E(ACT,2)                    ;0 = NO ERR MSG 1 = ERROR MSG
 S VAR=$E(ACT,3,4)                  ;E=EIN, D=DUNS, Z=ZIP (0=MISSING,1=HAS)
 S ACT=$E(ACT,1)                    ;0 = INACTIVE   1 = ACTIVE
 S:ERR="" ERR=0
 S:VAR="" VAR=0
 S:ACT="" ACT=0
 S HD1=$S(ACT=0:"INACTIVE",1:"ACTIVE")_" VENDORS "
 Q
V(ACT) ;EP - GATHER VENDORS AND SORTS BY NAME, DUNS, EIN, OR ZIP
 ; --------ENTERS WITH ACT STRING (ACTIVE, ERROR, SORT NAME)
 N TITLE
 N HD2,HD1,TAIL,ACRVAR
 D SUBH(.ACT,.ERR,.VAR,.HD1)
 S HD2="SORTED BY NAME "
 S ACRVAR=$S(VAR="E0":"NO EIN",VAR="D0":"NO DUNS",VAR="Z0":"ZIP",1:"")
 S:ACRVAR]"" HD1=HD1_"WITH "_ACRVAR
 S TAIL=$S(ERR=1:"WITH MISSING DATA",1:"")
 S HD2=HD2_TAIL
 S TITLE="NAME^DUNS^EIN+SUFFIX^MAILING ZIP^EFT TYPE-ACCT#-EFT ROUT#"
 I TAIL["MISSING" S TITLE=TITLE_U_"ERRORS"
 D HEAD^ACRFVLK2(HD1,HD2)
 D SUBHEAD^ACRFVLK2(TITLE,1)
 D LOOP(ACT,ERR,VAR)
 Q
 ;
ADEZ(ACT) ;EP - GATHER ACTIVE VENDORS WITH DUNS, EIN, OR ZIP
 N TITLE,NUM
 D SUBH(.ACT,.ERR,.VAR,.HD1)
 S ACRVAR=$S(VAR="E1":"EIN NO.",VAR="D1":"DUNS",VAR="Z1":"ZIP",1:"")
 S HD2="SORTED BY "_ACRVAR
 S:ACRVAR]"" HD1=HD1_"WITH "_ACRVAR
 I ACRVAR["EIN" D
 .S NUM=2
 .S TITLE=ACRVAR_"^VENDOR NAME^DUNS^MAILING ZIP^EFT TYPE-ACCT#-ROUT#"
 I ACRVAR["DUNS" D
 .S NUM=3
 .S TITLE=ACRVAR_"^VENDOR NAME^EIN+SUFFIX^MAILING ZIP^EFT TYPE-ACCT#-ROUT#"
 I ACRVAR["ZIP" D
 .S NUM=4
 .S TITLE=ACRVAR_"^VENDOR NAME^EIN+SUFFIX^DUNS^EFT TYPE-ACCT#-ROUT#"
 D HEAD^ACRFVLK2(HD1,HD2)
 D SUBHEAD^ACRFVLK2(TITLE,NUM)
 D LOOP(ACT,ERR,VAR)
 Q
 ;
LOOP(ACT,ERR,VAR) ; LOOP THROUGH VENDOR AND SET BY NAME
 ;   ---- ENTERS WITH WRITE SUBROUTINE CALL
 ;        ACTIVE FLAG -- 1 OR 0
 ;        ERROR FLAG  -- 1 OR 0
 ;        VAR STRING  -- E(IN), D(UNS), Z(IP) + 1 FOR HAS, 0 FOR MISSING
 ;
 N ACRVREC,NUM
 S ACRVREC=0,NUM=1
 S ACRERR=""
 F  S ACRVREC=$O(^AUTTVNDR(ACRVREC)) Q:'ACRVREC!($D(ACROUT))  D
 .I ERR D  Q:ACRERR=""                 ;ONLY WANT IF HAS ERRORS
 ..D CKVEND^ACRFUFMU(ACRVREC)          ;RETURNS WITH ACRERR STRING
 .D GETDATA
 .Q:ACT'=ACRACT                        ;ONLY WHAT IS WANTED
 .I VAR="D0" Q:ACRDUNS]""              ;WANT MISSING DUNS
 .I VAR="D1" Q:ACRDUNS=""              ;WANT DUNS
 .I VAR="E0" Q:ACREIN]""               ;WANT MISSING EIN
 .I VAR="E1" Q:ACREIN=""               ;WANT EIN
 .I VAR="Z0",$L($TR(ACRZIP,"-",""))=9 Q   ;WANT MISSING/BAD ZIP
 .I VAR="Z1" Q:ACRZIP=""               ;WANT ZIP
 .S VARN=ACRVNAM                       ;SET DEFAULT FOR NAME SORT
 .S STR=ACRVNAM_U_ACRDUNS_U_ACREX_U_ACRZIP_U_ACREFT
 .I VAR="D1" D                         ;SORT BY DUNS
 ..S VARN=ACRDUNS,NUM=2
 ..S STR=ACRDUNS_U_ACRVNAM_U_ACREX_U_ACRZIP_U_ACREFT
 .I VAR="E1" D                         ;SORT BY EIN
 ..S VARN=ACREX,NUM=2
 ..S STR=ACREX_U_ACRVNAM_U_ACRDUNS_U_ACRZIP_U_ACREFT
 .I VAR="Z1" D                         ;SORT BY ZIP
 ..S VARN=ACRZIP,NUM=2
 ..S STR=ACRZIP_ACRVNAM_U_ACRDUNS_U_ACREX_U_ACREFT
 .S:ERR STR=STR_U_ACRERR               ;ADD ERR STRING IF WANTED
 .S ^TMP("ACR",$J,VARN)=STR
 D WRT^ACRFVLK2(NUM)
 Q
GETDATA ;SET VENDOR VARIABLES
 K ACRV0,ACRV11,ACRV13,ACRV19,ACRZIP,ACROUT,ACRVNAM,ACRREC
 K ACRDUNS,ACREX,ACREFTT,ACREFT,ACRACT
 S ACRV0=$G(^AUTTVNDR(ACRVREC,0))
 S ACRV11=$G(^AUTTVNDR(ACRVREC,11))
 S ACRV13=$G(^AUTTVNDR(ACRVREC,13))
 S ACRV19=$G(^AUTTVNDR(ACRVREC,19))
 S ACRZIP=$P(ACRV13,U,4)
 S ACRVNAM=$P(ACRV0,U)
 S:ACRVNAM="" ACRVNAM="NO NAME "_ACRVREC
 S ACRDUNS=$P(ACRV0,U,7)
 S ACREIN=$P(ACRV11,U)                        ;EIN
 S ACREX=$P(ACRV11,U,13)                      ;EIN + SUFFIX
 S ACREFTT=$P(ACRV19,U)
 S ACREFT=ACREFTT_"-"_$P(ACRV19,U,3)_"-"_$P(ACRV19,U,2)
 S ACRACT=$S($$IDATE^ACRFUFMU(ACRVREC)]"":0,1:1)  ;IF VENDOR IS ACTIVE
 Q