MAGNUTL4 ;HIE/ZEB - Automatic updates to Imaging Site Parameters (#2006.1) ; 11 JUL 2024@13:39
;;3.0;IMAGING;**365**;July 11, 2024;Build 19
;; 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
SERVER ;entry point from MAG CACHE SETTINGS UPDATE option
;Update message must have a subject containing MAG CACHE SETTINGS UPDATE^<Station Number>
;The station number must correspond to the INSTITUTION (#4) entry linked to the IMAGING SITE PARAMETERS (#2006.1) entry to be updated
; - Example: MAG CACHE SETTINGS UPDATE^756
;Each line in the message will be applied to a row in the PRECACHE SETTINGS multiple
;There are three valid formats for a line in this message:
; - Add/Edit settings for a CPT Code
; - If there's already a row for this code, the settings will be replaced. Otherwise, a new row is created.
; - <CPT code>^<Cache at Order Signed Y/N>^<Cache at Exam Registered Y/N>
; - Example: 76091^Y^N
; - Delete settings for a CPT Code
; - Removes settings for a CPT code. This has the effect of disabling caching for that code.
; - <CPT code>^@
; - Example: 76091^@
; - Add/Edit settings for ALL CPT Codes
; - As of patch 365, functionality for All CPT Codes is only available for Exam Reg, but the messaging spec includes both.
; - *ALL^<Cache at Order Signed Y/N (currently unsupported)>^<Cache at Exam Registered Y/N>
; - Example: *ALL^^Y
;ZEXCEPT: XMZ ;ID of triggering message
;Call to XMXAPI covered by IA #2729
;Call to XMXUTIL2 covered by IA #2736
N MAGXMZ,SUBJ,STN,INSTIEN,ISPIEN,CPTCODE,ORDSIGN,EXAMREG,CPTIEN,LN
S MAGXMZ=$G(XMZ)
Q:MAGXMZ="" ;Message unknown
S SUBJ=$$SUBJ^XMXUTIL2($G(^XMB(3.9,MAGXMZ,0)))
D:SUBJ["MAG CACHE SETTINGS UPDATE"
. ;Abort if no valid station number or no corresponding IMAGING SITE PARAMETERS entry
. S STN=$P(SUBJ,U,2)
. Q:STN=""
. S INSTIEN=$O(^DIC(4,"D",STN,""))
. Q:INSTIEN=""
. S ISPIEN=$O(^MAG(2006.1,"B",INSTIEN,""))
. Q:ISPIEN=""
. ;Process each line in the message
. N XMZ,XMER,DIK,DA,DIE,DR,DIC,X
. S XMZ=MAGXMZ
. F S MESSAGE=$$READ^XMGAPI1() Q:XMER<0 D
.. S CPTCODE=$P(MESSAGE,U,1)
.. S ORDSIGN=$P(MESSAGE,U,2)
.. S EXAMREG=$P(MESSAGE,U,3)
.. Q:CPTCODE="" ;invalid row if no code specified
.. I CPTCODE="*ALL" D Q ;process All CPT Codes settings
... S DIE="^MAG(2006.1,"
... S DA=ISPIEN
... S DR="351///"_$S(EXAMREG="Y":1,1:"@")
... D ^DIE
.. Q:"^Y^N^@^"'[(U_ORDSIGN_U) ;invalid row if no Y/N or @
.. I ORDSIGN="@" D I 1 ;deleting settings for a code
... ;find IEN from CPT code
... S CPTIEN=$O(^ICPT("B",CPTCODE,""))
... ;abort if no record of CPT code
... Q:CPTIEN=""
... ;find row in settings for CPT code
... S LN=$$CPTLNNUM(CPTIEN,ISPIEN)
... ;if row exists, delete it
... I LN>0 S DIK="^MAG(2006.1,1,""PRECACHE"",",DA=LN,DA(1)=ISPIEN D ^DIK
.. E D ;add/edit settings for a code
... Q:"^Y^N^"'[(U_EXAMREG_U) ;invalid row if no Y/N
... ;find IEN from CPT code
... S CPTIEN=$O(^ICPT("B",CPTCODE,""))
... ;abort if no record of CPT code
... Q:CPTIEN=""
... ;find row in settings for CPT code
... S LN=$$CPTLNNUM(CPTIEN,ISPIEN)
... ;if row exists, update On Order Signed and On Exam Registered
... I LN>0 D I 1
.... S DIE="^MAG(2006.1,"_ISPIEN_",""PRECACHE"","
.... S DA=LN,DA(1)=ISPIEN
.... S DR="1///"_$S(ORDSIGN="Y":1,1:"@")
.... S DR=DR_";2///"_$S(EXAMREG="Y":1,1:"@")
.... D ^DIE
... E D ;otherwise add new row
.... K DO,DA
.... S DIC="^MAG(2006.1,"_ISPIEN_",""PRECACHE"","
.... S DIC(0)="FL"
.... S DA(1)=ISPIEN
.... S X=CPTIEN
.... S DIC("DR")=""
.... S:ORDSIGN="Y" DIC("DR")="1///1"
.... S:EXAMREG="Y" DIC("DR")=$S(DIC("DR")]"":DIC("DR")_";",1:"")_"2///1"
.... D FILE^DICN
N ZTREQ
D ZAPSERV^XMXAPI("S.MAG CACHE SETTINGS UPDATE",MAGXMZ)
S ZTREQ="@"
Q
;
CPTLNNUM(CPTIEN,ISPIEN) ;Return the line number in the PRECACHE SETTINGS multiple for a CPT code
;will return -1 if a line was not found
N LN
S LN=$O(^MAG(2006.1,ISPIEN,"PRECACHE","B",CPTIEN,""))
Q:LN]"" LN
Q -1
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNUTL4 5063 printed May 25, 2026@12:11:40 Page 2
MAGNUTL4 ;HIE/ZEB - Automatic updates to Imaging Site Parameters (#2006.1) ; 11 JUL 2024@13:39
+1 ;;3.0;IMAGING;**365**;July 11, 2024;Build 19
+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
SERVER ;entry point from MAG CACHE SETTINGS UPDATE option
+1 ;Update message must have a subject containing MAG CACHE SETTINGS UPDATE^<Station Number>
+2 ;The station number must correspond to the INSTITUTION (#4) entry linked to the IMAGING SITE PARAMETERS (#2006.1) entry to be updated
+3 ; - Example: MAG CACHE SETTINGS UPDATE^756
+4 ;Each line in the message will be applied to a row in the PRECACHE SETTINGS multiple
+5 ;There are three valid formats for a line in this message:
+6 ; - Add/Edit settings for a CPT Code
+7 ; - If there's already a row for this code, the settings will be replaced. Otherwise, a new row is created.
+8 ; - <CPT code>^<Cache at Order Signed Y/N>^<Cache at Exam Registered Y/N>
+9 ; - Example: 76091^Y^N
+10 ; - Delete settings for a CPT Code
+11 ; - Removes settings for a CPT code. This has the effect of disabling caching for that code.
+12 ; - <CPT code>^@
+13 ; - Example: 76091^@
+14 ; - Add/Edit settings for ALL CPT Codes
+15 ; - As of patch 365, functionality for All CPT Codes is only available for Exam Reg, but the messaging spec includes both.
+16 ; - *ALL^<Cache at Order Signed Y/N (currently unsupported)>^<Cache at Exam Registered Y/N>
+17 ; - Example: *ALL^^Y
+18 ;ZEXCEPT: XMZ ;ID of triggering message
+19 ;Call to XMXAPI covered by IA #2729
+20 ;Call to XMXUTIL2 covered by IA #2736
+21 NEW MAGXMZ,SUBJ,STN,INSTIEN,ISPIEN,CPTCODE,ORDSIGN,EXAMREG,CPTIEN,LN
+22 SET MAGXMZ=$GET(XMZ)
+23 ;Message unknown
if MAGXMZ=""
QUIT
+24 SET SUBJ=$$SUBJ^XMXUTIL2($GET(^XMB(3.9,MAGXMZ,0)))
+25 if SUBJ["MAG CACHE SETTINGS UPDATE"
Begin DoDot:1
+26 ;Abort if no valid station number or no corresponding IMAGING SITE PARAMETERS entry
+27 SET STN=$PIECE(SUBJ,U,2)
+28 if STN=""
QUIT
+29 SET INSTIEN=$ORDER(^DIC(4,"D",STN,""))
+30 if INSTIEN=""
QUIT
+31 SET ISPIEN=$ORDER(^MAG(2006.1,"B",INSTIEN,""))
+32 if ISPIEN=""
QUIT
+33 ;Process each line in the message
+34 NEW XMZ,XMER,DIK,DA,DIE,DR,DIC,X
+35 SET XMZ=MAGXMZ
+36 FOR
SET MESSAGE=$$READ^XMGAPI1()
if XMER<0
QUIT
Begin DoDot:2
+37 SET CPTCODE=$PIECE(MESSAGE,U,1)
+38 SET ORDSIGN=$PIECE(MESSAGE,U,2)
+39 SET EXAMREG=$PIECE(MESSAGE,U,3)
+40 ;invalid row if no code specified
if CPTCODE=""
QUIT
+41 ;process All CPT Codes settings
IF CPTCODE="*ALL"
Begin DoDot:3
+42 SET DIE="^MAG(2006.1,"
+43 SET DA=ISPIEN
+44 SET DR="351///"_$SELECT(EXAMREG="Y":1,1:"@")
+45 DO ^DIE
End DoDot:3
QUIT
+46 ;invalid row if no Y/N or @
if "^Y^N^@^"'[(U_ORDSIGN_U)
QUIT
+47 ;deleting settings for a code
IF ORDSIGN="@"
Begin DoDot:3
+48 ;find IEN from CPT code
+49 SET CPTIEN=$ORDER(^ICPT("B",CPTCODE,""))
+50 ;abort if no record of CPT code
+51 if CPTIEN=""
QUIT
+52 ;find row in settings for CPT code
+53 SET LN=$$CPTLNNUM(CPTIEN,ISPIEN)
+54 ;if row exists, delete it
+55 IF LN>0
SET DIK="^MAG(2006.1,1,""PRECACHE"","
SET DA=LN
SET DA(1)=ISPIEN
DO ^DIK
End DoDot:3
IF 1
+56 ;add/edit settings for a code
IF '$TEST
Begin DoDot:3
+57 ;invalid row if no Y/N
if "^Y^N^"'[(U_EXAMREG_U)
QUIT
+58 ;find IEN from CPT code
+59 SET CPTIEN=$ORDER(^ICPT("B",CPTCODE,""))
+60 ;abort if no record of CPT code
+61 if CPTIEN=""
QUIT
+62 ;find row in settings for CPT code
+63 SET LN=$$CPTLNNUM(CPTIEN,ISPIEN)
+64 ;if row exists, update On Order Signed and On Exam Registered
+65 IF LN>0
Begin DoDot:4
+66 SET DIE="^MAG(2006.1,"_ISPIEN_",""PRECACHE"","
+67 SET DA=LN
SET DA(1)=ISPIEN
+68 SET DR="1///"_$SELECT(ORDSIGN="Y":1,1:"@")
+69 SET DR=DR_";2///"_$SELECT(EXAMREG="Y":1,1:"@")
+70 DO ^DIE
End DoDot:4
IF 1
+71 ;otherwise add new row
IF '$TEST
Begin DoDot:4
+72 KILL DO,DA
+73 SET DIC="^MAG(2006.1,"_ISPIEN_",""PRECACHE"","
+74 SET DIC(0)="FL"
+75 SET DA(1)=ISPIEN
+76 SET X=CPTIEN
+77 SET DIC("DR")=""
+78 if ORDSIGN="Y"
SET DIC("DR")="1///1"
+79 if EXAMREG="Y"
SET DIC("DR")=$SELECT(DIC("DR")]"":DIC("DR")_";",1:"")_"2///1"
+80 DO FILE^DICN
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+81 NEW ZTREQ
+82 DO ZAPSERV^XMXAPI("S.MAG CACHE SETTINGS UPDATE",MAGXMZ)
+83 SET ZTREQ="@"
+84 QUIT
+85 ;
CPTLNNUM(CPTIEN,ISPIEN) ;Return the line number in the PRECACHE SETTINGS multiple for a CPT code
+1 ;will return -1 if a line was not found
+2 NEW LN
+3 SET LN=$ORDER(^MAG(2006.1,ISPIEN,"PRECACHE","B",CPTIEN,""))
+4 if LN]""
QUIT LN
+5 QUIT -1
+6 ;