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

MAGUTL01.m

Go to the documentation of this file.
  1. MAGUTL01 ;WOIFO/SG - PARAMETERS AND VALIDATION UTILITIES ; 3/9/09 12:53pm
  1. ;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
  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. ;; | |
  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. ;##### DELETES THE PARAMETER FROM THE DEFINITION TREE
  1. ;
  1. ; .MAGMSPSDEFS Reference to a local variable that stores the
  1. ; parameter definition tree generated by the
  1. ; $$LDMPDEFS^MAGUTL01.
  1. ;
  1. ; PNAME Full name of the parameter: list of names separated
  1. ; by the '/' that form the path to the parameter
  1. ; descriptor in the definition tree.
  1. ;
  1. DELMPAR(MAGMSPSDEFS,PNAME) ;
  1. N I,NAME,PNODE
  1. S NAME=$P(PNAME,"/") Q:NAME=""
  1. S PNODE="MAGMSPSDEFS"
  1. F I=2:1 S TMP=$P(PNAME,"/",I) Q:TMP="" D
  1. . S PNODE=$NA(@PNODE@("N",NAME)),NAME=TMP
  1. . Q
  1. K @PNODE@("N",NAME),@PNODE@("Q",NAME)
  1. Q
  1. ;
  1. ;+++++ RETURNS THE LINE OF THE PARAMETER DEFINITIONS TABLE
  1. ;
  1. ; OFFSET Offset of the line from the tag
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGRTN, MAGTAG
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; This is an internal entry point. Do not call it from outside
  1. ; of this routine.
  1. ;
  1. GETPDEF(OFFSET) ;
  1. Q $P($T(@(MAGTAG_"+"_OFFSET_"^"_MAGRTN)),";;",2)
  1. ;
  1. ;##### LOADS DEFINITIONS OF MISCELLANEOUS PARAMETERS
  1. ;
  1. ; .MAGMSPSDEFS( Reference to a local variable where descriptors
  1. ; of the miscellaneous parameters are loaded to.
  1. ; "N",
  1. ; Name, Parameter descriptor
  1. ; ^01: (Sub)file number
  1. ; ^02: Field number
  1. ; ^03: Parameter type
  1. ; ^04: Custom flags
  1. ; "N",
  1. ; Name) Parameter descriptor (record field)
  1. ; ...
  1. ; "Q", List of required parameters (record fields)
  1. ; Name) ""
  1. ; "Q", List of required parameters
  1. ; Name) ""
  1. ;
  1. ; See the MSPTBL^MAGUTL01 for details.
  1. ;
  1. ; TAGRTN Tag^Routine pair that references the table of
  1. ; parameter definitions. See the MSPTBL^MAGUTL01
  1. ; for a sample/template.
  1. ;
  1. ; [MAGLDFLAGS] Custom flags (characters) defined by the programmer.
  1. ; If this parameter is defined and not empty, then
  1. ; only those definitions that have at least one flag
  1. ; included in the value of this parameter are loaded.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see $$ERROR^MAGUERR)
  1. ; 0 Success
  1. ;
  1. LDMPDEFS(MAGMSPSDEFS,TAGRTN,MAGLDFLAGS) ;
  1. N MAGRTN,MAGSRCI,MAGTAG,RC
  1. S MAGTAG=$P(TAGRTN,"^"),MAGRTN=$P(TAGRTN,"^",2)
  1. S MAGLDFLAGS=$G(MAGLDFLAGS),MAGSRCI=3
  1. K MAGMSPSDEFS S RC=$$LDMPDEFZ("MAGMSPSDEFS")
  1. Q $S(RC<0:RC,1:0)
  1. ;
  1. ;+++++ RECURSIVE PARSER OF PARAMETER DEFINITIONS
  1. ;
  1. ; DSTNODE Node of the MAGMSPSDEFS where parameter definitions
  1. ; are stored to.
  1. ;
  1. ; [RECNAME] Name of the current record. It is used to detect
  1. ; the record boundaries.
  1. ;
  1. ; Input Variables
  1. ; ===============
  1. ; MAGRTN, MAGSRCI, MAGTAG
  1. ;
  1. ; Output Variables
  1. ; ================
  1. ; MAGSRCI
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see $$ERROR^MAGUERR)
  1. ; 0 Success
  1. ; 1 End of the table
  1. ;
  1. ; Notes
  1. ; =====
  1. ;
  1. ; This is an internal entry point. Do not call it from outside
  1. ; of this routine.
  1. ;
  1. LDMPDEFZ(DSTNODE,RECNAME) ;
  1. N BUF,NAME,PNODE,RC,TMP,TYPE
  1. S RC=0
  1. F S MAGSRCI=MAGSRCI+1,BUF=$$GETPDEF(MAGSRCI) Q:BUF="" D Q:RC
  1. . S BUF=$TR(BUF,"| ",U),NAME=$P(BUF,U,2) Q:NAME=""
  1. . ;=== Check custom flags
  1. . I MAGLDFLAGS'="" Q:$TR(MAGLDFLAGS,$P(BUF,U,6))=MAGLDFLAGS
  1. . ;=== If the name is the same as that of the current
  1. . ;=== record, then this is the end of the record.
  1. . I NAME=$G(RECNAME) S RC=2 Q
  1. . S PNODE=$NA(@DSTNODE@("N",NAME))
  1. . ;=== Determine the parameter type
  1. . S TYPE=$P(BUF,U,5)
  1. . I TYPE["X" D Q:RC<0 S $P(BUF,U,5)=TYPE
  1. . . N DDTYPE,FIELD,FILE,MAGMSG
  1. . . ;--- Get the field type from the DD
  1. . . S FILE=$P(BUF,U,3),FIELD=$P(BUF,U,4)
  1. . . I (FILE'>0)!(FIELD'>0) S RC=$$ERROR^MAGUERR(-23,,"X") Q
  1. . . S DDTYPE=$$GET1^DID(FILE,FIELD,,"TYPE",,"MAGMSG")
  1. . . I $G(DIERR) S RC=$$DBS^MAGUERR("MAGMSG") Q
  1. . . ;--- Update the parameter type
  1. . . S TYPE=$TR(TYPE,"DPSWX")
  1. . . I DDTYPE="DATE/TIME" S TYPE=TYPE_"D" Q
  1. . . I DDTYPE="POINTER" S TYPE=TYPE_"P" Q
  1. . . I DDTYPE="SET" S TYPE=TYPE_"S" Q
  1. . . I DDTYPE="WORD-PROCESSING" S TYPE=TYPE_"W" Q
  1. . . Q
  1. . ;=== Store the parameter descriptor
  1. . S @PNODE=$P(BUF,U,3,6)
  1. . S:TYPE["Q" @DSTNODE@("Q",NAME)=""
  1. . ;=== Process definitions of a record
  1. . I TYPE["R" S RC=$$LDMPDEFZ(PNODE,NAME) Q
  1. . Q
  1. ;===
  1. Q $S(RC>1:0,'RC:1,1:RC)
  1. ;
  1. MSPTBL ;+++++ SAMPLE/TEMPLATE OF THE PARAMETER DEFINITONS TABLE
  1. ;;==================================================================
  1. ;;| Parameter | File |Field|Type |Flags| Comment |
  1. ;;|------------+-------+-----+-----+-----+-------------------------|
  1. ;;|DTIS |2005 | 7 | DHQ | | DATE/TIME IMAGE SAVED |
  1. ;;|DESCR | | | W | | |
  1. ;;|OBJGROUP | | | RM | | |
  1. ;;| GROUP |2005.04| .01 | PQ | | |
  1. ;;| IMGNUM |2005.04| 2 | | | |
  1. ;;|OBJGROUP | | | | | |
  1. ;;|ORIGIN |2005 | 45 | M | | |
  1. ;;==================================================================
  1. ;
  1. ; Parameter Parameter name. It must be unique on the top level
  1. ; or inside each record definition (e.g. OBJGROUP) and
  1. ; must not contain spaces.
  1. ;
  1. ; File If the file and field numbers are defined, then
  1. ; Field values of the parameter are validated according to
  1. ; the field data dictionary (using the CHK^DIE).
  1. ;
  1. ; NOTE: This simple validation will not work for those
  1. ; fields that have input transform that depend
  1. ; on other fields and/or records.
  1. ;
  1. ; Type Parameter type:
  1. ; D - Date/time, P - Pointer,
  1. ; R - Record, S - Set of codes
  1. ; W - Word processing
  1. ; X - Set the type according to the field type from
  1. ; the DD (the File and Field must be provided).
  1. ; The 'X' itself is removed from the descriptor.
  1. ; and modifiers:
  1. ; H - Date/time in HL7 format (TS)
  1. ; M - Multi-value parameter
  1. ; Q - Required parameter
  1. ;
  1. ; Flags Custom flags defined by the programmer. Use them to
  1. ; control what definitions are loaded by the
  1. ; $$LDMPDEFS^MAGUTL01 function (see the MAGLDFLAGS
  1. ; parameter of the function for more details).
  1. ;
  1. Q