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

MAGIP118.m

Go to the documentation of this file.
MAGIP118 ;WOIFO/NST,DAC - Install code for MAG*3.0*118 ; 6 Mar 2013  4:35 PM
 ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
 ;; 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.                     |
 ;; +---------------------------------------------------------------+
 ;;
 ;***** Environment Check
 N IEN
 S IEN=0
 S IEN=$O(^MAGD(2006.575,IEN))
 I +IEN'="0" S XPDQUIT=2 W !,"You must resolve all failed image entries via the Correct RAD-DICOM File option before installation.",!
 S IEN=0
 S IEN=$O(^MAGD(2006.5752,IEN))
 I +IEN'="0" S XPDQUIT=2 W !,"You must resolve all IMPORTABLE DICOM OBJECTS (#2006.5752) file entries before installation.",!
 I $G(XPDQUIT)=2 W !,"Installation aborted."
 Q
 ;
 ;+++++ INSTALLATION ERROR HANDLING
ERROR ;
 S:$D(XPDNM) XPDABORT=1
 ;--- Display the messages and store them to the INSTALL file
 D DUMP^MAGUERR1(),ABTMSG^MAGKIDS()
 Q
 ;
 ;***** POST-INSTALL CODE
POS ;
 N CALLBACK
 D CLEAR^MAGUERR(1)
 ;
 N MAGKIDS1,MENU
 ;
 ; Execute post install for patch 34
 D ADDAD^MAGIP118 ; Update Artifact Descriptor file (#2006.915)
 D STORAGE^MAGIP118
 D CLEAN ; Clean up DDs and DICOM UID SPECIFIC ACTION file (#2006.539)
 D UPDATE^MAGVSOPU ; Update DICOM UID SPECIFIC ACTION file (#2006.539)
 D UPDATE^MAGVSOPC ; Update DICOM SOP CLASS file (#2006.532)
 D CLEANUP^MAGFXQRS ; clean up headers on QUERY/RETRIEVE STATISTICS file (#2006.5733)
 S MENU=$$ADD^XPDMENU("MAG SYS MENU","MAGV AE SEC MX SETTINGS") ; Add Edit AE Security Matrix option 
 S MENU=$$ADD^XPDMENU("MAG SYS MENU","MAG SYS-DELETE STUDY") ; Delete study by Accession number
 S MENU=$$ADD^XPDMENU("MAG SYS MENU","MAGD DICOM MENU")
 S MENU=$$ADD^XPDMENU("MAG SYS MENU","MAGV HDIG MENU")
 S MENU=$$ADD^XPDMENU("MAGV HDIG MENU","MAGVA ASYNC STORAGE ERR QURY")
 S MENU=$$ADD^XPDMENU("MAGV HDIG MENU","MAGVA ASYNC STORAGE ERR LIST")
 S MENU=$$ADD^XPDMENU("MAGV HDIG MENU","MAGVA ASYNC STORAGE ERR REQU")
 ;
 ;
 ;--- Link new remote procedures to context option MAG DICOM VISA.
 S CALLBACK="$$ADDRPCS^"_$NA(MAGKIDS1("RPCL34V^"_$T(+0),"MAG DICOM VISA"))
 I $$CP^MAGKIDS("MAG ATTACH RPCS P34",CALLBACK)<0  D ERROR  Q
 ;
 S CALLBACK="$$ADDRPCS^"_$NA(MAGKIDS1("RPCL116V^"_$T(+0),"MAG DICOM VISA"))
 I $$CP^MAGKIDS("MAG ATTACH RPCS P116",CALLBACK)<0  D ERROR  Q
 ;
 S CALLBACK="$$ADDRPCS^"_$NA(MAGKIDS1("RPCL118V^"_$T(+0),"MAG DICOM VISA"))
 I $$CP^MAGKIDS("MAG ATTACH RPCS P118",CALLBACK)<0  D ERROR  Q
 ;
 ;--- Link new remote procedures to the Broker context option.
 S CALLBACK="$$ADDRPCS^"_$NA(MAGKIDS1("RPCL118W^"_$T(+0),"MAG WINDOWS"))
 I $$CP^MAGKIDS("MAG ATTACH RPCS P118 WIN",CALLBACK)<0  D ERROR  Q
 ;
 ;--- Add IMPORTER entry to DICOM AE Security Matrix
 I $$CP^MAGKIDS("MAG IMPORTER AE ENTRY","$$ADDIMPAE^"_$T(+0))<0  D ERROR Q
 ;
 ;--- Add IMAGING EVENT ACTION file (#2006.931) entries
 I $$CP^MAGKIDS("MAG EVENT ACTIONS","$$ADDEVENT^"_$T(+0))<0  D ERROR Q
 ;
 ;--- Send the notification e-mail
 D BMES^XPDUTL("Post Install Mail Message: "_$$FMTE^XLFDT($$NOW^XLFDT))
 D INS^MAGQBUT4(XPDNM,DUZ,$$NOW^XLFDT,XPDA)
 Q
 ;
 ;***** PRE-INSTALL CODE
PRE ;
 ;--- Delete the FORCE RECONCILIATION field (#1.3)
 D DELFLDS^MAGKIDS(2006.9192,"1.3")
 Q
 ;+++++ LIST OF NEW REMOTE PROCEDURES
 ; have a list in format ;;MAG4 IMAGE LIST
RPCL34V ;
 ;;MAGV ATTACH IMAGE INSTANCE
 ;;MAGV ATTACH PAT PROC REF
 ;;MAGV ATTACH SERIES
 ;;MAGV ATTACH SOP
 ;;MAGV ATTACH STUDY
 ;;MAGV CREATE DICOM FAILED IMAGE
 ;;MAGV CREATE PAT REF
 ;;MAGV DELETE DICOM FAILED IMAGE
 ;;MAGV DGW ACTION UID LIST
 ;;MAGV DGW INSTRUMENT LIST
 ;;MAGV DGW MODALITY LIST
 ;;MAGV DICOM GET COUNT
 ;;MAGV DICOM SET INSTRUMENT LIST
 ;;MAGV DICOM SET MODALITY LIST
 ;;MAGV FIND PAT REF
 ;;MAGV FIND PROC REF
 ;;MAGV FIND SERIES BY REFERENCE
 ;;MAGV FIND SERIES BY UID
 ;;MAGV FIND SOP BY UID
 ;;MAGV FIND STUDY BY UID
 ;;MAGV GET ACCESSION NUM
 ;;MAGV GET DGW CONFIG
 ;;MAGV GET DICOM FAILED IMAGE
 ;;MAGV GET IMAGE FILE
 ;;MAGV GET ORIG IMAGE FILE
 ;;MAGV GET PAT INFO
 ;;MAGV GET PAT REF ATTS
 ;;MAGV GET PROC REF ATTS
 ;;MAGV GET PROCEDURE INFO
 ;;MAGV GET REPORT
 ;;MAGV GET SERIES
 ;;MAGV GET SOP DATA
 ;;MAGV GET STUDY
 ;;MAGV INACTIVATE INSTANCE FILE
 ;;MAGV INACTIVATE PAT REF
 ;;MAGV INACTIVATE PROC REF
 ;;MAGV INACTIVATE SERIES
 ;;MAGV INACTIVATE SOP
 ;;MAGV INACTIVATE STUDY
 ;;MAGV SERIES UID CHECK
 ;;MAGV SET DGW CONFIG
 ;;MAGV SET DICOM FAILED IMAGE
 ;;MAGV SOP UID CHECK
 ;;MAGV STUDY LOOKUP
 ;;MAGV STUDY UID CHECK
 ;;MAGV TRAVERSE IMAGE FILE
 ;;MAGV TRAVERSE PROC REF
 ;;MAGV TRAVERSE SERIES
 ;;MAGV TRAVERSE SOP
 ;;MAGV TRAVERSE STUDY
 ;;MAGV UPDATE IMAGE FILE
 ;;MAGV UPDATE PAT PROC REF
 ;;MAGV UPDATE PAT REF
 ;;MAGV UPDATE SERIES
 ;;MAGV UPDATE SOP
 ;;MAGV UPDATE STUDY
 ;;MAGVA CREATE AD
 ;;MAGVA CREATE AINSTANCE
 ;;MAGVA CREATE ARETPOL
 ;;MAGVA CREATE ARTIFACT W KL
 ;;MAGVA CREATE KEYLIST
 ;;MAGVA CREATE PROVAVAILTY
 ;;MAGVA CREATE PROVIDER
 ;;MAGVA CREATE QUEUE
 ;;MAGVA CREATE RETPOL
 ;;MAGVA CREATE RETPOL PROV MAP
 ;;MAGVA CREATE RETPOLFF
 ;;MAGVA CREATE STORAGE TA
 ;;MAGVA CREATE TRF STATS
 ;;MAGVA DELETE KEYLIST
 ;;MAGVA DELETE PROVAVAILTY
 ;;MAGVA DELETE RETPOL PROV MAP
 ;;MAGVA DEQUEUE Q MSG
 ;;MAGVA ENQUEUE Q MSG
 ;;MAGVA FIND KEYLIST
 ;;MAGVA GET A AIS ARPS AND RPFFS
 ;;MAGVA GET A W KL AND AIS
 ;;MAGVA GET A W KL AND AIS BY KL
 ;;MAGVA GET A W KL AND AIS BY PK
 ;;MAGVA GET ALL ADS
 ;;MAGVA GET ALL PROVAVAILS
 ;;MAGVA GET ALL PROVIDERS
 ;;MAGVA GET ALL QUEUES
 ;;MAGVA GET ALL RETPOL PROV MAPS
 ;;MAGVA GET ALL RETPOLS
 ;;MAGVA GET ALL SITE PARAM IDS
 ;;MAGVA GET ARTIFACT W KL
 ;;MAGVA GET CWL
 ;;MAGVA GET JUKEBOX WL
 ;;MAGVA GET KEYLIST
 ;;MAGVA GET NET LOC DETAILS
 ;;MAGVA PEEK Q MSG
 ;;MAGVA SET AD RETPOL
 ;;MAGVA UPDATE ARETPOL
 ;;MAGVA UPDATE ARTIFACT
 ;;MAGVA UPDATE LAST ACCESS DT
 ;;MAGVA UPDATE PROVAVAILTY
 ;;MAGVA UPDATE PROVIDER
 ;;MAGVA UPDATE RETPOL PROV MAP
 ;;MAG DICOM CHECK AE TITLE
 ;;MAG DICOM VISTA AE TITLE
 ;;MAG DICOM GET GATEWAY INFO
 Q 0
 ;
RPCL116V ;
 ;;MAG EVENT AUDIT
 Q 0
 ;
RPCL118V ;
 ;;MAG CFIND QUERY
 ;;MAG DICOM GET HOSP LOCATION
 ;;MAG DICOM RADIOLOGY MODIFIERS
 ;;MAG DICOM RADIOLOGY PROCEDURES
 ;;MAG EVENT AUDIT
 ;;MAG IMAGE CURRENT INFO
 ;;MAG STUDY UID QUERY
 ;;MAG4 INDEX GET ORIGIN
 ;;MAGG INSTALL
 ;;MAGV ADD WORK ITEM TAGS
 ;;MAGV CONFIRM RAD ORDER
 ;;MAGV CREATE WORK ITEM
 ;;MAGV DELETE WORK ITEM
 ;;MAGV FIND WORK ITEM
 ;;MAGV GET NEXT WORK ITEM
 ;;MAGV GET PAT ORDERS
 ;;MAGV GET RADIOLOGY PROCEDURES
 ;;MAGV GET WORK ITEM
 ;;MAGV GET WORKLISTS
 ;;MAGV IMPORT STATUS
 ;;MAGV UPDATE WORK ITEM
 ;;MAGV IMPORT MEDIA LOG STORE
 ;;MAGV IMPORT STUDY LOG REPORT
 ;;MAGV IMPORT STUDY LOG STORE
 ;;MAGV RAD EXAM ORDER
 ;;MAGV RAD EXAM REGISTER
 ;;MAGV RAD STAT COMPLETE
 ;;MAGV RAD STAT EXAMINED
 ;;MAGV WORK ITEMS COUNT
 ;;PSB GETPROVIDER
 Q 0
 ;
RPCL118W ;
 ;;MAG FILEMAN FIELD ATTS
 ;;MAG FILEMAN FIELD LIST
 ;;MAGV SEARCH BY ATTRIBUTE
 ;;XUS DIVISION GET
 Q 0
 ;
 ;--- Add an import entry to the AE Security Matrix
 ;
ADDIMPAE() ;
 N FDA1,FDA2,FDA3,SMIEN
 I $D(^MAGV(2006.9192,"B","IMPORTER")) Q 0
 S FDA1(2006.9192,"+1,",.01)="IMPORTER"
 S FDA1(2006.9192,"+1,",1)="VISTA_STORAGE"
 S FDA1(2006.9192,"+1,",1.1)="IMPORTER"
 S FDA1(2006.9192,"+1,",1.3)=1
 S FDA1(2006.9192,"+1,",2)=$G(DUZ(2))
 S FDA1(2006.9192,"+1,",6)=1
 S FDA1(2006.9192,"+1,",7)=1
 S FDA1(2006.9192,"+1,",8)=1
 S FDA1(2006.9192,"+1,",9)=1
 S FDA1(2006.9192,"+1,",10)=1
 S FDA1(2006.9192,"+1,",11)="RAD"
 D UPDATE^DIE("","FDA1","SMIEN")
 S FDA2(2006.919212,"+1,"_SMIEN(1)_",",.01)=1
 S FDA2(2006.919212,"+1,"_SMIEN(1)_",",1)=1
 D UPDATE^DIE("","FDA2")
 Q 0
 ;
 ;--- Add new entries to the IMAGING EVENT ACTION file (#2006.931).
 ;
ADDEVENT() ;
 N CT,FDA1,FILE,NAME S CT=0,FILE=2006.931
 F NAME="CLIENT LOGIN","IMPORTER AE SECURITY SUCCESS","IMPORTER AE SECURITY FAILURE" D
 . I '$D(^MAGV(FILE,"B",NAME)) S CT=CT+1,FDA1(FILE,"+"_CT_",",.01)=NAME
 D:CT UPDATE^DIE("","FDA1")
 Q 0
 ;
STORAGE ; Loop through IMAGE (#2006.1) file and update STORAGE PROVIDER (#2006.917) file
 N IEN
 S IEN=0
 F  S IEN=$O(^MAG(2006.1,IEN)) Q:+IEN=0  D
 . D ADDP(IEN)
 . Q
 Q 
ADDP(IEN) ; Add STORAGE PROVIDER file (#2006.917)
 I $D(^MAGV(2006.917,"B",IEN)) Q
 N MAGPARAM,MAGRY,RESDEL,PIEN1,PIEN2
 S RESDEL=$$RESDEL^MAGVAF02
 S MAGPARAM("STORAGE PROVIDER TYPE")="RAID"
 S MAGPARAM("STORAGE PLACE")=IEN
 S MAGPARAM("ARCHIVE")=0
 S MAGPARAM("PRIMARY STORAGE")=1
 S MAGPARAM("WRITABLE")=1
 D ADDPRV^MAGVAC01(.MAGRY,.MAGPARAM)
 S PIEN1=$P(MAGRY,RESDEL,3)
 K MAGRY,MAGPARAM
 S MAGPARAM("STORAGE PROVIDER TYPE")="JUKEBOX"
 S MAGPARAM("STORAGE PLACE")=IEN
 S MAGPARAM("ARCHIVE")=1
 S MAGPARAM("PRIMARY STORAGE")=0
 S MAGPARAM("WRITABLE")=1
 D ADDPRV^MAGVAC01(.MAGRY,.MAGPARAM)
 S PIEN2=$P(MAGRY,RESDEL,3)
 D ADDRE(IEN,PIEN1,1),ADDRE(IEN,PIEN2,0)
 D ADDPA(IEN,PIEN1),ADDPA(IEN,PIEN2)
 Q
ADDRE(IEN,PIEN,RAID) ; Add Retention - 2006.923
 N MAGPARAM,MAGRY
 S MAGPARAM("RETENTION POLICY")=1
 S MAGPARAM("STORAGE PROVIDER")=PIEN
 S MAGPARAM("SOURCE PLACE")=IEN
 S MAGPARAM("SYNCHRONOUS")=$S(RAID=1:1,1:0)
 S MAGPARAM("OFFSITE")=$S(RAID=1:0,1:0)
 D ADDRPPM^MAGVAC01(.MAGRY,.MAGPARAM)
 Q
ADDPA(IEN,PIEN) ; Add Storage Provider Availability file (#2006.924)
 N MAGPARAM,MAGRY
 S MAGPARAM("STORAGE PROVIDER")=PIEN
 S MAGPARAM("SOURCE PLACE")=IEN
 S MAGPARAM("START TIME")="20000101.0001"
 S MAGPARAM("END TIME")="20000101.0001"
 D ADDPA^MAGVAC01(.MAGRY,.MAGPARAM)
 Q
ADDAD ; Add Artifact Descriptor file (#2006.915)
 N RES,MAGPARAM,I,J,DA,DIK
 S DIK="^MAGV(2006.915,"
 ; Delete the data first
 S (I,J)=""
 F  S I=$O(^MAGV(2006.915,"B",I)) Q:I=""  D
 . F  S J=$O(^MAGV(2006.915,"B",I,J)) Q:J=""  D
 . . S DA=J
 . . D ^DIK
 . . Q
 . Q
 ; Add new records
 S MAGPARAM("ARTIFACT FORMAT")="DICOM"
 S MAGPARAM("ARTIFACT TYPE")="MedicalImage"
 S MAGPARAM("FILE EXTENSION")="dcm"
 S MAGPARAM("ACTIVE")=1
 S MAGPARAM("RETENTION POLICY")=1
 D ADDAD^MAGVAC01(.RES,.MAGPARAM)
 ;
 K MAGPARAM
 S MAGPARAM("ARTIFACT FORMAT")="JPEG"
 S MAGPARAM("ARTIFACT TYPE")="MedicalImageAbstract"
 S MAGPARAM("FILE EXTENSION")="jpg"
 S MAGPARAM("ACTIVE")=1
 S MAGPARAM("RETENTION POLICY")="1"
 D ADDAD^MAGVAC01(.RES,.MAGPARAM)
 Q
CLEAN ; Clean up DDs
 D CLEANAE
 D CLEANISP
 D UIDS
 D CLEANDDS
 D WHISTORY
 D CLEANQ(4,"",$$FMADD^XLFDT($$NOW^XLFDT(),-30)) ; Clean up QUEUE MESSAGE file (#2006.928)
 Q
CLEANQ(QUEUEIEN,MAGBDT,MAGEDT) ; Clean up QUEUE MESSAGE file (#2006.928)
 ; QUEUEIEN -- Queue IEN in QUEUE file (#2006.924) - e.g., 4 - Email Queue
 ; MAGBDT -- From Date
 ; MAGEDT -- Through Date
 N FDA,IEN,MAGDT
 S MAGDT=$O(^MAGV(2006.928,"ENQDT",QUEUEIEN,MAGBDT-1))
 F  S MAGDT=$O(^MAGV(2006.928,"ENQDT",QUEUEIEN,MAGDT)) Q:MAGDT=""!(MAGDT>MAGEDT)  D
 . S IEN=""
 . F  S IEN=$O(^MAGV(2006.928,"ENQDT",QUEUEIEN,MAGDT,IEN)) Q:IEN=""  D
 . . K FDA
 . . S FDA(2006.928,IEN_",",.01)="@"
 . . D FILE^DIE("","FDA")
 . . Q
 . Q
 Q
CLEANAE ; Remove user data from DICOM AE Security Matrix (#2006.9192) file  
 N AEIEN,FDA
 S AEIEN=0
 F  S AEIEN=$O(^MAGV(2006.9192,AEIEN)) Q:+AEIEN=0  D
 . I $P(^MAGV(2006.9192,AEIEN,0),U,7)'="" S FDA(2006.9192,AEIEN_",",2.1)="@"
 . Q
 I $D(FDA) D FILE^DIE("","FDA")
 Q
CLEANISP ; Remove user data from Imaging Site Paramaters (#2006.1) file
 N ISPIEN,FDA
 S ISPIEN=0
 F  S ISPIEN=$O(^MAG(2006.1,ISPIEN)) Q:+ISPIEN=0  D
 . I $P($G(^MAG(2006.1,ISPIEN,5)),U,1)'="" S FDA(2006.1,ISPIEN_",",104)="@"
 . Q
 I $D(FDA) D FILE^DIE("","FDA")
 Q
CLEANDDS ; Remove user fields from DD entries in file 2006.1 and 2006.9192
 I $$GET1^DID(2006.1,104,,"LABEL")="DEFAULT DICOM AE USER" D DELFLDS^MAGKIDS(2006.1,"104")
 I $$GET1^DID(2006.9192,2.1,,"LABEL")="USER" D DELFLDS^MAGKIDS(2006.9192,"2.1")
 Q
UIDS ; Clean up duplicate entries in the DICOM UID Specific Action (#2006.539) file
 N FDA,FIRST,UID,UIDIEN
 S UID=""
 F  S UID=$O(^MAGDICOM(2006.539,"B",UID)) Q:UID=""  D 
 . S FIRST=1
 . S UIDIEN=""
 . F  S UIDIEN=$O(^MAGDICOM(2006.539,"B",UID,UIDIEN)) Q:UIDIEN=""  D
 . . I 'FIRST S FDA(2006.539,UIDIEN_",",.01)="@"
 . . S FIRST=0
 . . Q
 . Q
 I $D(FDA) D FILE^DIE("","FDA","ERR")
 Q
WHISTORY ; Remove Work Item History (#2006.9411) file and file entries
 D DELFILE^MAGKIDS(2006.9411,"DE")
 Q