MAGCFIX ;OIT/ZEB - CVIX Image Ingest Data Fix ; DEC 3, 2024@9:34AM
;;3.0;IMAGING;**376**;Dec 03, 2024;Build 5
;;Per VA Directive 6402, 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
;For IPO2 testing, start with 7/29/24
INGSTFIX(INTER,DEVNAME,STDT) ;Fix Image file (#2005) entries
;INTER (default: ""): whether process is interactive
;DEVNAME (default: "CVIX INGEST"): name of entry to fill into ACQUISITION DEVICE field (#107); if @, field will be cleared
;STDT (default: "3241113"): start date for search (internal FM format)
S INTER=$G(INTER)
S DEVNAME=$G(DEVNAME,"CVIX INGEST")
S STDT=$G(STDT,"3241113")
N DEVIEN,MAGDT,CNT,MAGIEN,MAG100,DIC,X,Y,DIE,DA,DR
;find or create device
S DEVIEN=""
S DEVIEN=$S(DEVNAME="@":"@",1:$O(^MAG(2006.04,"B",DEVNAME,DEVIEN)))
D:DEVIEN=""
. K DO ;FILE^DICN assumes this and we need to prevent a leak from something that didn't clean it up
. S DIC="^MAG(2006.04,",DIC(0)="F",X=DEVNAME,DIC("DR")="1///`"_$P($$SITE^VASITE(),U,1)
. D FILE^DICN
. S DEVIEN=Y
I DEVIEN=-1 D Q
. I INTER=1 D
.. W !,"Unable to find/create "_DEVNAME_" device. Aborting."
;find effected records, set ACQUISITION DEVICE (#107), then delete TRACKING ID (#108); we're deferring setting it until P365
I INTER=1 D
. W !,"Searching for effected records.",!
S CNT=0
S MAGDT=$$FMADD^XLFDT(STDT,-1)
F S MAGDT=$O(^MAG(2005,"AD",MAGDT)) Q:MAGDT="" D
. S MAGIEN=""
. F S MAGIEN=$O(^MAG(2005,"AD",MAGDT,MAGIEN)) Q:MAGIEN="" D
.. S MAG100=^MAG(2005,MAGIEN,100)
.. I $P(MAG100,U,4)="",$P(MAG100,U,5)]"" D
... S CNT=CNT+1
... I INTER=1 D
.... W:CNT#10=0 "."
... S DIE="^MAG(2005,",DA=MAGIEN,DR="107///"_$S(DEVIEN="@":"",1:"`")_DEVIEN_";108///@"
... D ^DIE
I INTER=1 D
. W !,"Fixed "_CNT_" records."
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGCFIX 2775 printed Aug 26, 2025@22:15:27 Page 2
MAGCFIX ;OIT/ZEB - CVIX Image Ingest Data Fix ; DEC 3, 2024@9:34AM
+1 ;;3.0;IMAGING;**376**;Dec 03, 2024;Build 5
+2 ;;Per VA Directive 6402, 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 ;; | |
+11 ;; | The Food and Drug Administration classifies this software as |
+12 ;; | a medical device. As such, it may not be changed in any way. |
+13 ;; | Modifications to this software may result in an adulterated |
+14 ;; | medical device under 21CFR820, the use of which is considered |
+15 ;; | to be a violation of US Federal Statutes. |
+16 ;; +---------------------------------------------------------------+
+17 ;;
+18 QUIT
+19 ;For IPO2 testing, start with 7/29/24
INGSTFIX(INTER,DEVNAME,STDT) ;Fix Image file (#2005) entries
+1 ;INTER (default: ""): whether process is interactive
+2 ;DEVNAME (default: "CVIX INGEST"): name of entry to fill into ACQUISITION DEVICE field (#107); if @, field will be cleared
+3 ;STDT (default: "3241113"): start date for search (internal FM format)
+4 SET INTER=$GET(INTER)
+5 SET DEVNAME=$GET(DEVNAME,"CVIX INGEST")
+6 SET STDT=$GET(STDT,"3241113")
+7 NEW DEVIEN,MAGDT,CNT,MAGIEN,MAG100,DIC,X,Y,DIE,DA,DR
+8 ;find or create device
+9 SET DEVIEN=""
+10 SET DEVIEN=$SELECT(DEVNAME="@":"@",1:$ORDER(^MAG(2006.04,"B",DEVNAME,DEVIEN)))
+11 if DEVIEN=""
Begin DoDot:1
+12 ;FILE^DICN assumes this and we need to prevent a leak from something that didn't clean it up
KILL DO
+13 SET DIC="^MAG(2006.04,"
SET DIC(0)="F"
SET X=DEVNAME
SET DIC("DR")="1///`"_$PIECE($$SITE^VASITE(),U,1)
+14 DO FILE^DICN
+15 SET DEVIEN=Y
End DoDot:1
+16 IF DEVIEN=-1
Begin DoDot:1
+17 IF INTER=1
Begin DoDot:2
+18 WRITE !,"Unable to find/create "_DEVNAME_" device. Aborting."
End DoDot:2
End DoDot:1
QUIT
+19 ;find effected records, set ACQUISITION DEVICE (#107), then delete TRACKING ID (#108); we're deferring setting it until P365
+20 IF INTER=1
Begin DoDot:1
+21 WRITE !,"Searching for effected records.",!
End DoDot:1
+22 SET CNT=0
+23 SET MAGDT=$$FMADD^XLFDT(STDT,-1)
+24 FOR
SET MAGDT=$ORDER(^MAG(2005,"AD",MAGDT))
if MAGDT=""
QUIT
Begin DoDot:1
+25 SET MAGIEN=""
+26 FOR
SET MAGIEN=$ORDER(^MAG(2005,"AD",MAGDT,MAGIEN))
if MAGIEN=""
QUIT
Begin DoDot:2
+27 SET MAG100=^MAG(2005,MAGIEN,100)
+28 IF $PIECE(MAG100,U,4)=""
IF $PIECE(MAG100,U,5)]""
Begin DoDot:3
+29 SET CNT=CNT+1
+30 IF INTER=1
Begin DoDot:4
+31 if CNT#10=0
WRITE "."
End DoDot:4
+32 SET DIE="^MAG(2005,"
SET DA=MAGIEN
SET DR="107///"_$SELECT(DEVIEN="@":"",1:"`")_DEVIEN_";108///@"
+33 DO ^DIE
End DoDot:3
End DoDot:2
End DoDot:1
+34 IF INTER=1
Begin DoDot:1
+35 WRITE !,"Fixed "_CNT_" records."
End DoDot:1
+36 QUIT