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

XUSNPI1.m

Go to the documentation of this file.
  1. XUSNPI1 ; OAK/TKW - NATIONAL PROVIDER IDENTIFIER UTILITIES ;6/6/08 11:27
  1. ;;8.0;KERNEL;**480**; July 10, 1995;Build 38
  1. ;;Per VHA Directive 2004-038, this routine should not be modified
  1. NPIUSED(XUSNPI,XUSQID,XUSQIL,XUSIEN,XUSRSLT,XUSFLAG) ; Evaluate cases where an NPI is already in use
  1. ; and return an error or warning. Called from routines that allow an NPI to be assigned
  1. ; to either an INSTITUTION (file 4) or a NEW PERSON (file 200).
  1. ; XUSNPI = the NPI
  1. ; XUSQID = the qualified identifier for the file being edited (ex. "Individual_ID")
  1. ; XUSQIL = the delimited list of entities already using that NPI. This is output
  1. ; from $$QI^XUSNPI, in the format:
  1. ; Qualified_Identifier^IEN^Effective_date/time^Active/Inactive;
  1. ; (Qualified_Identifier=(ex. "Individual_ID")
  1. ; IEN=the IEN of the entity who owns the NPI.
  1. ; If there are multiple entities who own the NPI, there will
  1. ; be multiple entries in XUSQIL, delimited by ";".)
  1. ; XUSIEN = IEN of entry to which NPI is being assigned
  1. ; XUSRSLT = an output array returned if an error or warning message is generated.
  1. ; XUSFLAG = If set to 1, indicates that routine is being called from an input transform.
  1. ; If set to 2, indicates we're checking the current NPI prior to delete/replace
  1. ; If set to 3, indicates we're checking a new NPI (Either ADD or REPLACE).
  1. ;
  1. ; The function will return:
  1. ; 0 - No Error
  1. ; 1 - Error
  1. ; 2 - Warning
  1. ;
  1. N XUSGLOB,XUSERR,XUSWARN,XUSFILE,XUSCNT,XUSFILI,XUSNEWPT,ZZ,X,I
  1. N XUSOU,XUSOAI,XUSOIEN,XUSOQID,XUSOPT
  1. K XUSRSLT
  1. ; If NPI is not already in use, quit 0 (no error)
  1. I XUSQIL=0 Q 0
  1. ; If NPI is malformed, quit 1 (error)
  1. I +XUSQIL=0,$P(XUSQIL,U,2)="Invalid NPI" D Q 1
  1. . S XUSRSLT(1)="NPI values have a specific structure to validate them..."
  1. . S XUSRSLT(2)="The Checksum for this entry is not valid"
  1. . Q
  1. D GETLST^XPAR(.ZZ,"PKG.KERNEL","XUSNPI QUALIFIED IDENTIFIER")
  1. S ZZ=""
  1. F S ZZ=$O(ZZ(ZZ)) Q:ZZ'>0 I $P(ZZ(ZZ),U)=XUSQID Q
  1. I ZZ'>0 S XUSRSLT(1)="Invalid 'Qualified Identifier' Input Parameter "_XUSQID_" passed." Q 1
  1. S XUSFLAG=+$G(XUSFLAG)
  1. S XUSIEN=+$G(XUSIEN)
  1. ; If user being updated is NON-VA Provider, get their Provider Type and file name
  1. S XUSNEWPT=0,XUSFILI=""
  1. ; Read through list of entities that already own the NPI
  1. S (XUSERR,XUSWARN,XUSCNT)=0
  1. F I=1:1 S XUSOU=$P(XUSQIL,";",I) Q:XUSOU=""!(XUSERR) D
  1. . ; Get Qualified Identifier, IEN and Active/Inactive flag for other entity who owns the NPI
  1. . S XUSOQID=$P(XUSOU,U)
  1. . S XUSOIEN=+$P(XUSOU,U,2)
  1. . S XUSOAI=$P(XUSOU,U,4)
  1. . ; Find Qualified Identifier of file that already owns the NPI in the list of valid QIs
  1. . S ZZ="" F S ZZ=$O(ZZ(ZZ)) Q:ZZ'>0 I $P(ZZ(ZZ),U)=XUSOQID Q
  1. . I ZZ'>0 D Q
  1. . . S XUSERR=1
  1. . . S XUSRSLT(1)="Invalid Qualified Identifier "_XUSOQID_" returned from $$QI^XUSNPI" Q
  1. . ; Get global reference for file that owns NPI
  1. . S XUSGLOB="^"_$P(ZZ(ZZ),U,2)
  1. . ; If called from the input transform, and an entity is trying to enter an NPI they
  1. . ; have previously held, it's not an error, unless NPI is inactive.
  1. . I XUSFLAG=1,XUSQID=XUSOQID,XUSIEN=XUSOIEN,XUSOAI'="Inactive" Q
  1. . ; Put provider type information into XUSOPT to generate error/warning
  1. . S XUSOPT=0
  1. . I XUSFLAG'=1 D
  1. . . I XUSOQID="Individual_ID" S XUSOPT="2^"
  1. . . I XUSOQID="Organization_ID" S XUSOPT="1^"
  1. . . I XUSOQID="Non_VA_Provider_ID" S XUSOPT=$$GETPT(XUSOIEN)
  1. . . Q
  1. . ; If editing a VA Provider, and a non-VA Provider has same current NPI, build both the
  1. . ; warning a user sees prior to replacing or deleting the current NPI, and the warning
  1. . ; the user will see after replacing the NPI.
  1. . I XUSFLAG=2 D Q
  1. . . Q:XUSOQID'="Non_VA_Provider_ID"
  1. . . D MSGOLD(XUSNPI,XUSGLOB,XUSOIEN,.XUSCNT,XUSOPT,XUSOAI,.XUSRSLT)
  1. . . S XUSWARN=1
  1. . . Q
  1. . ; If an entity in the same file owns the NPI, it's an error.
  1. . I $P(XUSOU,U)=XUSQID D Q
  1. . . D:XUSFLAG'=1 MSGNEW(XUSNPI,XUSGLOB,XUSOIEN,.XUSCNT,.XUSRSLT,XUSOPT)
  1. . . S XUSERR=1 Q
  1. . ; If an entity in the INSTITUTION file (#4) already owns the NPI, it's an error.
  1. . I $P(XUSOU,U)="Organization_ID" D Q
  1. . . D:XUSFLAG'=1 MSGNEW(XUSNPI,XUSGLOB,XUSOIEN,.XUSCNT,.XUSRSLT,XUSOPT)
  1. . . S XUSERR=1 Q
  1. . ; If new entry being edited is a VA INSTITUTION and any other entity owns the NPI, it's an error
  1. . I XUSQID="Organization_ID" D Q
  1. . . D:XUSFLAG'=1 MSGNEW(XUSNPI,XUSGLOB,XUSOIEN,.XUSCNT,.XUSRSLT,XUSOPT)
  1. . . S XUSERR=1 Q
  1. . ; Providers in file 200 or 355.93 can share an NPI. If NPI in file 355.93 is Active,
  1. . ; issue a warning, if inactive, issue an error
  1. . I XUSFLAG'=1 D MSGNEW(XUSNPI,XUSGLOB,XUSOIEN,.XUSCNT,.XUSRSLT,XUSOPT,XUSOAI)
  1. . I XUSOAI="Inactive" S XUSERR=1 Q
  1. . S XUSWARN=1
  1. . Q
  1. I XUSERR Q 1
  1. I XUSWARN Q 2
  1. Q 0
  1. ;
  1. GETPT(XUSIEN) ; Get provider type for entry in IB NON/OTHER VA BILLING PROVIDER file
  1. N PT
  1. S PT=+$$GET1^DIQ(355.93,XUSIEN_",",.02,"I")
  1. ; Null provider type returned as 3.
  1. I PT=1 S PT="1^the FACILITY/GROUP provider "
  1. E I PT=2 S PT="2^the INDIVIDUAL provider "
  1. E S PT="3^"
  1. K ^TMP("DIERR",$J)
  1. Q PT
  1. ;
  1. GETPER(XUSOWNKY) ; Return names of people who own the security key IB PROVIDER EDIT
  1. N XUSIEN,X
  1. F XUSIEN=0:0 S XUSIEN=$O(^XUSEC("IB PROVIDER EDIT",XUSIEN)) Q:'XUSIEN D
  1. . Q:$G(^VA(200,XUSIEN,0))=""
  1. . ; Don't return TERMINATED or DISUSERed users
  1. . S X=$$ACTIVE^XUSER(XUSIEN)
  1. . I X=""!($P(X,U)=0) Q
  1. . ; Put users IENs into output array
  1. . S XUSOWNKY(XUSIEN)="" Q
  1. Q
  1. ;
  1. MSGOLD(XUSNPI,XUSGLOB,XUSIEN,XUSCNT,XUSOPT,XUSOAI,XUSRSLT) ;
  1. ; Generate warning message to display prior to REPLACE/DELETE NPI prompt, when the current
  1. ; NPI is also used by a non-va provider
  1. N XUSFILE,XUSOWNKY,I,J,X
  1. S XUSFILE=$P(@(XUSGLOB_"0)"),U)
  1. S X=""
  1. S:$G(XUSOPT) X=$P(XUSOPT,U,2)
  1. S XUSCNT=XUSCNT+1,XUSRSLT(XUSCNT)="The NPI of "_XUSNPI_" is also associated with "_X
  1. S XUSCNT=XUSCNT+1,XUSRSLT(XUSCNT)=$P(@(XUSGLOB_XUSIEN_",0)"),U)
  1. I XUSOAI="Inactive" S XUSRSLT(XUSCNT)=XUSRSLT(XUSCNT)_" as INACTIVE"
  1. S XUSRSLT(XUSCNT)=XUSRSLT(XUSCNT)_" in the "_XUSFILE_" file."
  1. S XUSCNT=XUSCNT+2
  1. ; Generate warning message to display after REPLACE NPI, when the current NPI
  1. ; is also used by a non-va provider
  1. ;
  1. S I=$O(XUSRSLT("X",999999999999),-1)
  1. S XUSRSLT("X",I+1)="Warning: NPI "_XUSNPI_" is also associated with provider "_$P(@(XUSGLOB_XUSIEN_",0)"),U)_"."
  1. S XUSRSLT("X",I+2)=""
  1. S XUSRSLT("X",I+3)="A Mailman message has been sent to holders of the ""IB PROVIDER EDIT"""
  1. S XUSRSLT("X",I+4)="security key."
  1. S I=$O(XUSRSLT("XMSG",999999999999),-1)
  1. S XUSRSLT("XMSG",I+1,0)="The NPI "_XUSNPI_" was ^ for ^ in"
  1. S XUSRSLT("XMSG",I+2,0)="the NEW PERSON file. The NPI "_XUSNPI_" is also associated with"
  1. S XUSRSLT("XMSG",I+3,0)=$P(@(XUSGLOB_XUSIEN_",0)"),U)_" in the "_XUSFILE_" file."
  1. S XUSRSLT("XMSG",I+4,0)=" "
  1. S XUSRSLT("XMSG",I+5,0)="The same change may need to be made to the "_XUSFILE
  1. S XUSRSLT("XMSG",I+6,0)="using the PROVIDER ID MAINTENANCE option."
  1. ; Get names of persons to notify
  1. D GETPER(.XUSOWNKY)
  1. S I=$O(XUSRSLT("XRCPT",999999999999),-1)
  1. F J=0:0 S J=$O(XUSOWNKY(J)) Q:'J S I=I+1,XUSRSLT("XRCPT",I)=J
  1. Q
  1. ;
  1. MSGNEW(XUSNPI,XUSGLOB,XUSIEN,XUSCNT,XUSRSLT,XUSOPT,XUSOAI) ;
  1. ; Generate error or warning message when new NPI is in use.
  1. N XUSFILE,X
  1. S XUSFILE=$P(@(XUSGLOB_"0)"),U)
  1. S X=""
  1. S:$G(XUSOPT) X=$P(XUSOPT,U,2)
  1. I $G(XUSOAI)="" D Q
  1. . S XUSRSLT(XUSCNT+1)="The NPI of "_XUSNPI_" is now, or was in the past, associated with"
  1. . S XUSRSLT(XUSCNT+2)=X_$P(@(XUSGLOB_XUSIEN_",0)"),U)_" in the "_XUSFILE_" file."
  1. . S XUSCNT=XUSCNT+2
  1. . Q
  1. S XUSRSLT(XUSCNT+1)="The NPI of "_XUSNPI_" is also associated with "_X
  1. S XUSRSLT(XUSCNT+2)=$P(@(XUSGLOB_XUSIEN_",0)"),U)_" in the "_XUSFILE_" file."
  1. S XUSCNT=XUSCNT+2
  1. I XUSOAI="Inactive" D Q
  1. . S XUSCNT=XUSCNT+1,XUSRSLT(XUSCNT)="This NPI is INACTIVE and may not be used."
  1. . Q
  1. Q
  1. ;
  1. ;