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

MAGVAF05.m

Go to the documentation of this file.
  1. MAGVAF05 ;WOIFO/NST - Utilities for RPC calls ; 14 Sep 2011 1:55 PM
  1. ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;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. ; +++++ Return IEN of the record with .01 field equals VALUE
  1. ; If record is not found a new record will be added if a add flag is set to true
  1. ;
  1. ; Input parameters
  1. ; ================
  1. ; FILE = FileMan file number (e.g. 2006.9193)
  1. ; VALUE = External or internal value of .01 field
  1. ; ADD = Add a new record if the VALUE is not found (e.g. 0/1)
  1. GETIEN(FILE,VALUE,ADD) ; Return IEN of the record with .01 field equals VALUE
  1. N MAGNFDA,MAGNIEN,MAGNXE,IEN,MAGRY
  1. I (VALUE=0)!(VALUE<0) Q $$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Unexpected value of #"_FILE_".01 :"_VALUE ; Error
  1. ; Do we have IEN?
  1. I +VALUE=VALUE D SETOKVAL^MAGVAF02(.MAGRY,VALUE) Q MAGRY
  1. ; Find the IEN by VALUE
  1. S IEN=$$FIND1^DIC(FILE,"","BX",VALUE,"","","MAGNXE") ; Find the IEN for VALUE
  1. I $D(MAGNXE("DIERR")) Q $$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_$G(MAGNXE("DIERR",1,"TEXT",1))
  1. I IEN>0 D SETOKVAL^MAGVAF02(.MAGRY,IEN) Q MAGRY
  1. ; Return error if we don't need to add a new record
  1. I 'ADD Q $$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_"Record "_VALUE_" is not found in file #"_FILE
  1. ; Add a new record to FILE and return IEN of the new record
  1. S MAGNFDA(FILE,"+1,",.01)=VALUE
  1. D UPDATE^DIE("S","MAGNFDA","MAGNIEN","MAGNXE")
  1. I $D(MAGNXE("DIERR","E")) Q $$FAILED^MAGVAF02()_$$RESDEL^MAGVAF02()_$G(MAGNXE("DIERR",1,"TEXT",1))
  1. D SETOKVAL^MAGVAF02(.MAGRY,MAGNIEN(1))
  1. Q MAGRY
  1. ;
  1. ; Input parameters
  1. ; ================
  1. ; FILE = FileMan file number (e.g. 2006.916)
  1. ; FIELD = Field number or name (e.g. "CREATING APPLICATION" or 6)
  1. ;
  1. GETFILEP(FILE,FIELD) ; Returns the file that a FIELD in file FILE points to
  1. Q $P($$GET1^DID(FILE,FIELD,"","SPECIFIER"),"P",2)