MAGSPID ;WOIFO/SF,DAC,JSL - PATIENT DATA UTILITIES ; 22 Jul 2021 12:00 PM
 ;;3.0;IMAGING;**122,123,301**;Mar 19, 2002;Build 2;Oct 10, 2020
 ;; Per VHA Directive 2004-038, this routine should not be modified.
 ;; +---------------------------------------------------------------+
 ;; | Property of the US Government.                                |
 ;; | No permission to copy or redistribute this software is given. |
 ;; | Use of unreleased versions of this software requires the user |
 ;; | to execute a written test agreement with the VistA Imaging    |
 ;; | Development Office of the Department of Veterans Affairs,     |
 ;; | telephone (301) 734-0100.                                     |
 ;; | The Food and Drug Administration classifies this software as  |
 ;; | a medical device.  As such, it may not be changed in any way. |
 ;; | Modifications to this software may result in an adulterated   |
 ;; | medical device under 21CFR820, the use of which is considered |
 ;; | to be a violation of US Federal Statutes.                     |
 ;; +---------------------------------------------------------------+
 ;;
 Q
 ; This routine is used on both VistA and the DICOM Gateway
PIDLABEL() ;
 Q $S($$ISIHS():"HRN",1:"SSN")
 ;
DEM(LOC) ;For IHS, call DEM^VADPT but reset DUZ(2) to the instrument division
 ;this is because in IHS, patients have different chart numbers in each division
 ;this procedure can only be called on VistA or RPMs.  It cannot be called on a DICOM GW
 I $G(LOC)="" S LOC=DUZ(2)
 S TMPDUZ2=DUZ(2),DUZ(2)=LOC
 D DEM^VADPT ; Supported IA (#10061)
 S DUZ(2)=TMPDUZ2 K TMPDUZ2
 Q
 ;
ISIHS() ;Is this IHS site? (P123)
 ; This function is used on both VistA and the DICOM gateway
 ; In VistA DUZ("AG") will be used to determine if a site is an IHS site
 ; On the DICOM gateway the DICOM GATEWAY PARAMETER (#2006.563) file will be checked
 Q $S($G(DUZ("AG"))="I":1,$G(^MAGDICOM(2006.563,1,"AGENCY"))="I":1,1:0)
 ;
PROD(FORCE) ;;Check if it is the PRODUCTION TYPE - MAG WORK ITEM (field#4, Input Transform)
 N VERSION,LC,SID,SITE,Y,X
 ;
 I $$ISIHS=0 Q 0  ;VA site follows VA screen rule
 ; 
 I $$PROD^XUPROD($G(FORCE)) Q 1  ; IA #4440 
 ;
 S SITE=$S($G(DUZ(2)):DUZ(2),1:+$$SITE^VASITE)
 D BMES^XPDUTL("Imaging SITE is not the production, must run PROD^MAGSPID(1) for TEST account: "_SITE)
 ;
CHKNMSPC ;check IHS test/production account setting
 N MAGPL,NWNAME,NAME,MAGDA,FN,DIR
 S MAGPL=$$PLACE^MAGBAPI(SITE)  ;PLACE#2006.1
 I 'MAGPL D LNOIS^MAGUSIT Q 0   ;Need set the MAG site #2006.1 for SITE
 S NWNAME=$P(^MAG(2006.1,+MAGPL,0),U,2)  ;current namespace
 S NAME=$$KSP^XUPARAM("WHERE"),MAGDA=$O(^MAG(2006.19,"B",NAME,""))
 S FN=$S('MAGDA:$$UNDEF^MAGUSIT(NAME),1:$P($G(^MAG(2006.19,MAGDA,0)),U,4))
 I FN="ZZT" D                   ;user specified TEST account, add namespace over real one
 . S DIR(0)="Y",DIR("B")="YES",DIR("A")="Accept the defaults Namespace: "_FN D ^DIR
 . I 'Y K DIR S DIR(0)="F:1:3",DIR("A")="Enter your Test namespace " D ^DIR
 . I ($L(Y)=3),(FN'=NWNAME) S FN=Y  ;new namespace
 . Q
 I (FN="")!($G(Y)="^") D LNOIS^MAGUSIT Q 0  ;; Error issue
 D:NWNAME'=FN PNMSP^MAGUSIT(MAGPL,FN)       ;; add new namespace
 S $P(^XTV(8989.3,1,"SID"),U,1)=1 Q 1       ;; Allow IHS site for MAG WORK ITEM (TEST/PRO) 
 Q 0
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGSPID   3308     printed  Sep 23, 2025@19:44:43                                                                                                                                                                                                     Page 2
MAGSPID   ;WOIFO/SF,DAC,JSL - PATIENT DATA UTILITIES ; 22 Jul 2021 12:00 PM
 +1       ;;3.0;IMAGING;**122,123,301**;Mar 19, 2002;Build 2;Oct 10, 2020
 +2       ;; Per VHA Directive 2004-038, this routine should not be modified.
 +3       ;; +---------------------------------------------------------------+
 +4       ;; | Property of the US Government.                                |
 +5       ;; | No permission to copy or redistribute this software is given. |
 +6       ;; | Use of unreleased versions of this software requires the user |
 +7       ;; | to execute a written test agreement with the VistA Imaging    |
 +8       ;; | Development Office of the Department of Veterans Affairs,     |
 +9       ;; | telephone (301) 734-0100.                                     |
 +10      ;; | The Food and Drug Administration classifies this software as  |
 +11      ;; | a medical device.  As such, it may not be changed in any way. |
 +12      ;; | Modifications to this software may result in an adulterated   |
 +13      ;; | medical device under 21CFR820, the use of which is considered |
 +14      ;; | to be a violation of US Federal Statutes.                     |
 +15      ;; +---------------------------------------------------------------+
 +16      ;;
 +17       QUIT 
 +18      ; This routine is used on both VistA and the DICOM Gateway
PIDLABEL() ;
 +1        QUIT $SELECT($$ISIHS():"HRN",1:"SSN")
 +2       ;
DEM(LOC)  ;For IHS, call DEM^VADPT but reset DUZ(2) to the instrument division
 +1       ;this is because in IHS, patients have different chart numbers in each division
 +2       ;this procedure can only be called on VistA or RPMs.  It cannot be called on a DICOM GW
 +3        IF $GET(LOC)=""
               SET LOC=DUZ(2)
 +4        SET TMPDUZ2=DUZ(2)
           SET DUZ(2)=LOC
 +5       ; Supported IA (#10061)
           DO DEM^VADPT
 +6        SET DUZ(2)=TMPDUZ2
           KILL TMPDUZ2
 +7        QUIT 
 +8       ;
ISIHS()   ;Is this IHS site? (P123)
 +1       ; This function is used on both VistA and the DICOM gateway
 +2       ; In VistA DUZ("AG") will be used to determine if a site is an IHS site
 +3       ; On the DICOM gateway the DICOM GATEWAY PARAMETER (#2006.563) file will be checked
 +4        QUIT $SELECT($GET(DUZ("AG"))="I":1,$GET(^MAGDICOM(2006.563,1,"AGENCY"))="I":1,1:0)
 +5       ;
PROD(FORCE) ;;Check if it is the PRODUCTION TYPE - MAG WORK ITEM (field#4, Input Transform)
 +1        NEW VERSION,LC,SID,SITE,Y,X
 +2       ;
 +3       ;VA site follows VA screen rule
           IF $$ISIHS=0
               QUIT 0
 +4       ; 
 +5       ; IA #4440 
           IF $$PROD^XUPROD($GET(FORCE))
               QUIT 1
 +6       ;
 +7        SET SITE=$SELECT($GET(DUZ(2)):DUZ(2),1:+$$SITE^VASITE)
 +8        DO BMES^XPDUTL("Imaging SITE is not the production, must run PROD^MAGSPID(1) for TEST account: "_SITE)
 +9       ;
CHKNMSPC  ;check IHS test/production account setting
 +1        NEW MAGPL,NWNAME,NAME,MAGDA,FN,DIR
 +2       ;PLACE#2006.1
           SET MAGPL=$$PLACE^MAGBAPI(SITE)
 +3       ;Need set the MAG site #2006.1 for SITE
           IF 'MAGPL
               DO LNOIS^MAGUSIT
               QUIT 0
 +4       ;current namespace
           SET NWNAME=$PIECE(^MAG(2006.1,+MAGPL,0),U,2)
 +5        SET NAME=$$KSP^XUPARAM("WHERE")
           SET MAGDA=$ORDER(^MAG(2006.19,"B",NAME,""))
 +6        SET FN=$SELECT('MAGDA:$$UNDEF^MAGUSIT(NAME),1:$PIECE($GET(^MAG(2006.19,MAGDA,0)),U,4))
 +7       ;user specified TEST account, add namespace over real one
           IF FN="ZZT"
               Begin DoDot:1
 +8                SET DIR(0)="Y"
                   SET DIR("B")="YES"
                   SET DIR("A")="Accept the defaults Namespace: "_FN
                   DO ^DIR
 +9                IF 'Y
                       KILL DIR
                       SET DIR(0)="F:1:3"
                       SET DIR("A")="Enter your Test namespace "
                       DO ^DIR
 +10      ;new namespace
                   IF ($LENGTH(Y)=3)
                       IF (FN'=NWNAME)
                           SET FN=Y
 +11               QUIT 
               End DoDot:1
 +12      ;; Error issue
           IF (FN="")!($GET(Y)="^")
               DO LNOIS^MAGUSIT
               QUIT 0
 +13      ;; add new namespace
           if NWNAME'=FN
               DO PNMSP^MAGUSIT(MAGPL,FN)
 +14      ;; Allow IHS site for MAG WORK ITEM (TEST/PRO) 
           SET $PIECE(^XTV(8989.3,1,"SID"),U,1)=1
           QUIT 1
 +15       QUIT 0