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

MAGNAN01.m

Go to the documentation of this file.
  1. MAGNAN01 ;WOIFO/NST - IMAGING ANNOTATION UTILITY RPCS ; 07 May 2018 11:43 AM
  1. ;;3.0;IMAGING;**185,201**;Mar 19, 2002;Build 92;Aug 02, 2012
  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. ;***** STORES THE DETAIL OF STUDY ANNOTATION
  1. ;
  1. ; RPC: MAGN ANNOT STORE STUDY
  1. ;
  1. ; .MAGOUT Reference to a local variable where the results are returned to
  1. ; .MAGPARAM
  1. ; MAGPARAM("STUDY UID")
  1. ; MAGPARAM("PSTATE UID")
  1. ; MAGPARAM("NAME")
  1. ; MAGPARAM("SOURCE")
  1. ; MAGPARAM("TOOL VERSION")
  1. ; MAGPARAM(1..n) Annotation Data (XML/JSON)
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; MAGOUT(0) is defined and its 1st '^'-piece is 0, then an error
  1. ; occurred during execution of the procedure.
  1. ; MAGOUT(0) = Success status - success
  1. ; Failure status - error
  1. STORE(MAGOUT,MAGPARAM) ;RPC [MAGN ANNOT STORE STUDY]
  1. N MAGNFDA,MAGNXE,IENS,STUDYIEN,STUDYID,PSTATIEN,PSTATUID,EXIT
  1. ;
  1. ; Set input variables
  1. S STUDYID=$G(MAGPARAM("STUDY UID"))
  1. S PSTATUID=$G(MAGPARAM("PSTATE UID"))
  1. ;
  1. K MAGOUT
  1. S MAGOUT(0)=$$SETERROR^MAGNU002("")
  1. I '$G(DUZ) S MAGOUT(0)=$$SETERROR^MAGNU002("No DUZ defined") Q
  1. I STUDYID="" S MAGOUT(0)=$$SETERROR^MAGNU002("No STUDYID") Q
  1. I PSTATUID="" S MAGOUT(0)=$$SETERROR^MAGNU002("No PSTATEUID") Q
  1. S STUDYIEN=$$FIND1^DIC(2005.003,"","X",STUDYID,"","","MAGNXE")
  1. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q ; Set MAGOUT and quit if error exists
  1. I 'STUDYIEN D ; Create Study record
  1. . S IENS="+1,"
  1. . S MAGNFDA(2005.003,IENS,.01)=STUDYID
  1. . D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
  1. . I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q
  1. . ; What is the Image IEN D ENTRY^MAGLOG("MAG ANNOT",$G(DUZ),IEN,"MAG IMAGE ANNOTATION","","1",$G(SOURCE,"CLINIC")) ;log annotation
  1. . S STUDYIEN=MAGNIEN(1)
  1. . Q
  1. ;
  1. I $D(MAGNXE) Q ; MAGOUT is aleady set with the error
  1. ;
  1. S PSTATIEN=$$FIND1^DIC(2005.0031,","_STUDYIEN_",","X",PSTATUID,"","","MAGNXE")
  1. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q ; Set MAGOUT and quit if error exists
  1. ;
  1. I 'PSTATIEN D Q ; Create a new annotation record for the study and quit
  1. . S PSTATIEN=$$UPDATE(.MAGOUT,STUDYIEN,"+2",.MAGPARAM)
  1. . Q
  1. ;
  1. I $G(MAGPARAM("DELETED")) D Q
  1. . S EXIT=$$DELANNOT(.MAGOUT,STUDYIEN,PSTATIEN)
  1. . Q
  1. ;
  1. S EXIT=$$UPDATE(.MAGOUT,STUDYIEN,PSTATIEN,.MAGPARAM)
  1. ; MAGOUT is set at this point
  1. Q
  1. ;
  1. UPDATE(MAGOUT,IEN0,IEN1,MAGPARAM) ; Add new annotation data node w/ DUZ, version, data ...
  1. N ANNOT,ANSITE,ANSERV,STUDYID,PSTATUID,NAME,SOURCE,VER
  1. N I,MAGNFDA,MAGNIEN,MAGNXE
  1. ;
  1. ; Set input variables
  1. S PSTATUID=$G(MAGPARAM("PSTATE UID"))
  1. S NAME=$G(MAGPARAM("NAME"))
  1. S SOURCE=$G(MAGPARAM("SOURCE"))
  1. S VER=$G(MAGPARAM("TOOL VERSION"))
  1. S I=0
  1. F S I=$O(MAGPARAM(I)) Q:'I D
  1. . S ANNOT(I)=MAGPARAM(I)
  1. . Q
  1. ;
  1. S ANSITE=$G(DUZ(2)) ; Annotation Site
  1. S ANSERV=$$GET1^DIQ(200,DUZ,29,"I") ; Annotation service
  1. ;
  1. S IENS=IEN1_","_IEN0_","
  1. S:$E(IEN0)'="+" MAGNIEN(1)=IEN0
  1. S:$E(IEN1)'="+" MAGNIEN(2)=IEN1
  1. K MAGNFDA
  1. S MAGNFDA(2005.0031,IENS,.01)=$G(MAGPARAM("PSTATE UID"))
  1. S MAGNFDA(2005.0031,IENS,1)=DUZ ;ANNOTATOR
  1. S:$D(ANNOT) MAGNFDA(2005.0031,IENS,2)=$$NOW^XLFDT() ;SAVE D/T
  1. S:VER'="" MAGNFDA(2005.0031,IENS,3)=VER ;VERSION
  1. S MAGNFDA(2005.0031,IENS,4)=$G(SOURCE,"CLINIC")
  1. S MAGNFDA(2005.0031,IENS,7)=ANSERV ;SERVICE/SECTION
  1. S MAGNFDA(2005.0031,IENS,8)=ANSITE ;SITE
  1. S:NAME'="" MAGNFDA(2005.0031,IENS,9)=NAME ;Annotation name
  1. D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
  1. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q 0
  1. ;
  1. I '$D(ANNOT) Q MAGNIEN(2)
  1. S IENS=MAGNIEN(2)_","_IEN0_","
  1. ; Annotation data 2005.003 field #6
  1. D WP^DIE(2005.0031,IENS,6,"","ANNOT","MAGNXE")
  1. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) D Q 0
  1. . N DA,DIK
  1. . ; clean up data
  1. . S DIK="^MAG(2005.003,"_IEN0_",1,",DA=IEN1,DA(1)=IEN0
  1. . D ^DIK
  1. . Q
  1. ;
  1. Q MAGNIEN(2)
  1. ;
  1. DELANNOT(MAGOUT,IEN0,IEN1) ; Set Deleted flag
  1. N IENS,MAGNFDA,MAGNIEN,MAGNXE
  1. ;
  1. S IENS=IEN1_","_IEN0_","
  1. K MAGNFDA
  1. S MAGNFDA(2005.0031,IENS,5)=1
  1. D UPDATE^DIE("","MAGNFDA","MAGNIEN","MAGNXE")
  1. I $$ISERROR^MAGNU002(.MAGOUT,.MAGNXE) Q 0
  1. ;
  1. Q 1