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

MAGVIM03.m

Go to the documentation of this file.
  1. MAGVIM03 ;WOIFO/MAT,MLH,BT,DAC - RPCs for DICOM Importer II ; Nov 10, 2020@13:55:05
  1. ;;3.0;IMAGING;**118,283**;Mar 19, 2002;Build 5;May 01, 2013
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. ;+++ Importer II Log Reports: Populate MAGV IMPORT STUDY LOG File (#2006.9421)
  1. ;
  1. ; RPC: MAGV IMPORT STUDY LOG STORE
  1. ;
  1. ; Inputs:
  1. ; =======
  1. ;
  1. ; MAGVRET .... Variable for returned message.
  1. ; MAGVDUZ .... User DUZ.
  1. ; MAGVDUZ2 ... User Login Division.
  1. ; MAGVPDFN ... Associated Patient DFN.
  1. ; MAGVSACN ... Associated Study Accession Number.
  1. ; MAGVSUID ... Study Instance UID.
  1. ; MAGVSLOC ... Study performed location.
  1. ; MAGVSTYP ... Associated Study Type.
  1. ; MAGVSCNT ... Imported Series Count.
  1. ; MODLST ..... Array of NAME|VALUE PAIRS for MODALITY|COUNT.
  1. ; MEDGIEN .... IEN in the MAGV IMPORT MEDIA LOG file (#2006.9422)
  1. ; OBJFAIL .... Count of requested objects which failed to be imported.
  1. ;
  1. ; Outputs:
  1. ; ========
  1. ;
  1. ; 0`"IMPORT STUDY LOG UPDATED."
  1. ; -1`"Unable to lock MAGV IMPORT STUDY LOG File (#2006.9421)."
  1. ; -1`##_"Validator error message lines returned."
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ;
  1. IMPLOGIN(MAGVRET,MAGVDUZ,MAGVDUZ2,MAGVPDFN,MAGVSACN,MAGVSUID,MAGVSLOC,MAGVSTYP,MAGVSCNT,MODLIST,MEDGIEN,OBJFAIL) ;
  1. ;
  1. ;--- Initialize. Set output separators per p34 convention.
  1. K FDA,FDAIEN,MAGVRET
  1. N SEPOUTP,SEPSTAT D ZRUSEPIN
  1. N MAGVERR,MAGVMSG S MAGVERR=0
  1. N FILE S FILE=2006.9421
  1. N SUBFILE S SUBFILE=2006.94211
  1. N SFIEN,LOCIEN ; P283 DAC - Added Location/Instution IEN for Station # conversion
  1. ;
  1. ;--- Set FDA entries for literal parameters.
  1. S FDA(0,FILE,"+1,",3)=MAGVPDFN ;PAT_DFN
  1. S:MAGVSACN'="" FDA(0,FILE,"+1,",4)=MAGVSACN ;Associated_Study_Accession_Number
  1. S:MAGVSUID'="" FDA(0,FILE,"+1,",5)=MAGVSUID ;Study_Instance_UID
  1. S:MAGVSLOC'="" FDA(0,FILE,"+1,",6)=MAGVSLOC ;Study_Performed_Location
  1. S FDA(0,FILE,"+1,",7)=MAGVSTYP ;Associated_Study_Type
  1. S FDA(0,FILE,"+1,",8)=MAGVSCNT ;Series_Count
  1. S FDA(0,FILE,"+1,",11)=OBJFAIL ;Object_Failed_Count
  1. S FDA(0,FILE,"+1,",12)=MEDGIEN ;IEN in the MAGV IMPORT MEDIA LOG file (#2006.9422)
  1. ;
  1. ;--- Lock MAGV IMPORT STUDY LOG file (#2006.9421)
  1. L +^MAGV(FILE):5 I $T D
  1. . ;
  1. . ;--- Set internal FDA entries for .01 field. IA #10103
  1. . S FDA(0,FILE,"+1,",.01)=$$NOW^XLFDT
  1. . S FDA(0,FILE,"+1,",1)=MAGVDUZ ;USER_DUZ
  1. . S LOCIEN=$$IEN^XUAF4(MAGVDUZ2) ; P283 DAC - Convert Station # to Institution IEN before filing
  1. . S FDA(0,FILE,"+1,",2)=LOCIEN ; P283 DAC - File Institution IEN instead of Station #
  1. . ;
  1. . ;--- Post top-level transaction data. IA# 2053.
  1. . D UPDATE^DIE("","FDA(0)","SFIEN")
  1. . ;
  1. . ;--- Set FDA entries for array parameter MODLST.
  1. . N CT,CTMOD S CT="",CTMOD=0 F S CT=$O(MODLIST(CT)) Q:CT="" D
  1. . . N MODLTY S MODLTY=$P(MODLIST(CT),"|",1)
  1. . . N VALUE S VALUE=$P(MODLIST(CT),"|",2)
  1. . . S FDA(1,SUBFILE,"+"_CT_","_SFIEN(1)_",",.01)=MODLTY
  1. . . S FDA(1,SUBFILE,"+"_CT_","_SFIEN(1)_",",.02)=VALUE
  1. . . S CTMOD=CTMOD+VALUE
  1. . . Q
  1. . ;
  1. . D:(CTMOD*SFIEN(1))>0
  1. . . ;--- Set FDA entry for total modality object count.
  1. . . S FDA(1,FILE,SFIEN(1)_",",9)=$G(CTMOD)
  1. . . ;--- Post sub-file transaction data. IA# 2053.
  1. . . D UPDATE^DIE("","FDA(1)")
  1. . L -^MAGV(FILE)
  1. . Q
  1. ;
  1. E D
  1. . ;
  1. . S MAGVERR=1,MAGVMSG="Could not lock MAGV IMPORT STUDY LOG File."
  1. . Q
  1. ;
  1. ;--- Return.
  1. I MAGVERR S MAGVRET(0)="-1"_SEPSTAT_MAGVMSG Q
  1. S MAGVRET(0)="0"_SEPSTAT_"IMPORT STUDY LOG UPDATED."
  1. Q
  1. ;+++ Importer II Log Reports from MAGV IMPORT STUDY LOG file (#2006.9421)
  1. ;
  1. ; RPC: MAGV IMPORT STUDY LOG REPORT
  1. ;
  1. ; Inputs:
  1. ; =======
  1. ;
  1. ; MAGVARY .... Variable for returned message.
  1. ; REPORT ..... Report identifier as:
  1. ;
  1. ; 0 ... Initialization Request
  1. ; 1 ... Report Data for Each Date in Range
  1. ; 2 ... Report Data for Each Study Location
  1. ; 3 ... Report Data for Modality Counts
  1. ;
  1. ; STARTDT .... Inclusive lower bound of date range as YYYYMMDD.
  1. ; STOPDT ..... Inclusive upper bound of date range.
  1. ;
  1. ; Outputs:
  1. ; ========
  1. ;
  1. ; 0`## [report lines returned]
  1. ; -1`Error message.
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; Calls MAGVIM04 for processing.
  1. ;
  1. IMPLOGEX(MAGVARY,REPORT,STARTDT,STOPDT) ;
  1. ;
  1. N SEPOUTP,SEPSTAT D ZRUSEPIN
  1. N MAGVERR S MAGVERR=0
  1. N FILE S FILE=2006.9421
  1. ;
  1. ;--- Convert incoming HL7 dates to FileMan. IA #
  1. S STARTDT=$$HL7TFM^XLFDT(STARTDT)
  1. S STOPDT=$$HL7TFM^XLFDT(STOPDT)
  1. ;
  1. S MAGVARY=$NA(^TMP("MAGVIM",$J))
  1. K @MAGVARY
  1. D I MAGVERR S @MAGVARY@(0)="-1"_SEPSTAT_MAGVERR Q
  1. . ;
  1. . I '$D(REPORT) S MAGVERR="REPORT TYPE NOT SPECIFIED." Q
  1. . ;
  1. . ;--- Set report types validator string.
  1. . I "0,1,2,3,"'[REPORT_"," S MAGVERR="REPORT TYPE"_""_REPORT_""_"UNDEFINED." Q
  1. ;
  1. ;--- Report window initialization request.
  1. I REPORT=0 D Q
  1. . ;
  1. . ;--- Detect file contains no data & return -1
  1. . I '$D(^MAGV(FILE,"B")) S @MAGVARY@(0)="-1" Q
  1. . ;
  1. . ;--- Return "0'STARTDT" for earliest date in file.
  1. . N FIRSTDT S FIRSTDT=+$P($O(^MAGV(FILE,"B","")),".")
  1. . S @MAGVARY@(0)="0"_"`"_$$FMTHL7^XLFDT(FIRSTDT)
  1. ;
  1. ;--- Call the processor.
  1. D MAGVQRY^MAGVIM04(MAGVARY,FILE,REPORT,STARTDT,STOPDT)
  1. ;
  1. ;--- Return.
  1. N LNTOT S LNTOT=$O(@MAGVARY@("Z"),-1)
  1. S @MAGVARY@(0)=0_SEPSTAT_LNTOT
  1. Q
  1. ;
  1. ; +++++ Importer II Log Reports: Populate MAGV IMPORT MEDIA LOG (#2006.9422)
  1. ;
  1. ; RPC: MAGV IMPORT MEDIA LOG STORE
  1. ;
  1. ; Inputs:
  1. ; =======
  1. ;
  1. ; MAGVRET .... Variable for returned message.
  1. ; MAGVDUZ .... User DUZ.
  1. ; MAGVWKST ... Workstation running the Importer II application.
  1. ; MEDTYPE .... Import event media type (DIRect, STaGed,NETwork, DiCoM correct).
  1. ; MEDVALID ... Media Validation Status (0=valid; 1=invalid).
  1. ; MEDVMSG .... Media Validation Message extending MEDVALID.
  1. ;
  1. ; Outputs:
  1. ; ========
  1. ;
  1. ; 0`"IMPORT MEDIA LOG UPDATED."
  1. ; -1`"Unable to lock MAGV IMPORT MEDIA LOG File."
  1. ; -1`##_"Validator error message lines returned."
  1. ;
  1. IMPMEDIA(MAGVRET,MAGVDUZ,MAGVWKST,MEDTYPE,MEDVALID,MEDVMSG) ;
  1. ;
  1. K MAGVRET
  1. N SEPOUTP,SEPSTAT D ZRUSEPIN
  1. N MAGVERR,MAGVMSG S MAGVERR=0
  1. ;
  1. N FILE S FILE=2006.9422
  1. D
  1. . K FDA
  1. . ;--- Set FDA entries for literal parameters.
  1. . S FDA(1,FILE,"+1,",.01)=$$NOW^XLFDT ;Media Import Timestamp
  1. . S FDA(1,FILE,"+1,",2)=MAGVDUZ ;Import II User DUZ
  1. . S FDA(1,FILE,"+1,",3)=MAGVWKST ;Import II Workstation ID
  1. . S FDA(1,FILE,"+1,",4)=MEDTYPE ;Media Type
  1. . S FDA(1,FILE,"+1,",100)=MEDVALID ;Media Validation Status
  1. . S FDA(1,FILE,"+1,",101)=$G(MEDVMSG) ;Media Validation Status Message
  1. . Q
  1. ;
  1. ;--- Lock MAGV IMPORT MEDIA LOG file (#2006.9422)
  1. L +^MAGV(FILE):5 I $T D
  1. . ;
  1. . K MAGVIEN
  1. . ;--- Post the transaction. IA# 2053.
  1. . D UPDATE^DIE("","FDA(1)","MAGVIEN")
  1. . L -^MAGV(FILE)
  1. . Q
  1. ;
  1. E D
  1. . ;
  1. . S MAGVERR=1,MAGVMSG="Could not lock MAGV IMPORT MEDIA LOG File."
  1. . Q
  1. ;
  1. ;--- Return.
  1. I MAGVERR S MAGVRET(0)="-1"_SEPSTAT_MAGVMSG Q
  1. S MAGVRET(0)="0"_SEPSTAT_MAGVIEN(1)
  1. Q
  1. ;
  1. ;+++ Routine Utility: Initialize Separators
  1. ZRUSEPIN ;
  1. S SEPOUTP=$$OUTSEP^MAGVIM01
  1. S SEPSTAT=$$STATSEP^MAGVIM01
  1. Q
  1. ;
  1. ; MAGVIM03