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

MAGUTL06.m

Go to the documentation of this file.
  1. MAGUTL06 ;WOIFO/SG,NST - VALIDATION OF MULTI-VALUE PARAMETERS ; OCT 18, 2018@12:53pm
  1. ;;3.0;IMAGING;**93,221**;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. ;##### VALIDATES THE LIST OF NAMES/CODES
  1. ;
  1. ; CDNMLIST List of internal and/or external values of a 'set
  1. ; of codes' field defined by the FILE and FIELD
  1. ; parameters. Items should be separated by the '^'
  1. ; (see also the FLAGS parameter).
  1. ;
  1. ; FILE File/Subfile number
  1. ; FIELD Field number
  1. ;
  1. ; MAG8NODE Closed reference to a node where the results are
  1. ; returned to:
  1. ;
  1. ; @MAG8NODE@( The list of external names is returned here. Items
  1. ; are separated with the same delimiter as those in
  1. ; the source list.
  1. ;
  1. ; Code) Name
  1. ;
  1. ; [FLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; C "Capitalize" the external names
  1. ;
  1. ; , Use comma as item separator instead of '^'
  1. ; (not recommended).
  1. ;
  1. ; Z Treat 0 (zero) as valid code regardles of
  1. ; the field definition.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see the $$ERROR^MAGUERR)
  1. ; 0 Success
  1. ; >0 Number of the piece of the source list that
  1. ; contains an invalid code or name.
  1. ;
  1. VALCNLST(CDNMLIST,FILE,FIELD,MAG8NODE,FLAGS) ;
  1. N ERR,I,ICNT,ITEM,LS,MAG8MSG,MAG8RES,MAGI,NAME,RC
  1. S FLAGS=$G(FLAGS),LS=$S(FLAGS[",":",",1:"^")
  1. Q:$TR(FLAGS,"C,Z")'="" $$IPVE^MAGUERR("FLAGS")
  1. K @MAG8NODE S (ICNT,RC)=0
  1. ;
  1. ;=== Process items of the list
  1. F MAGI=1:1:$L(CDNMLIST,LS) D Q:RC
  1. . ;--- Get item name or code
  1. . S ITEM=$$TRIM^XLFSTR($P(CDNMLIST,LS,MAGI)) Q:ITEM=""
  1. . ;--- Special check for zero
  1. . I ITEM=0,FLAGS["Z" D Q
  1. . . S ICNT=ICNT+1,NAME="<empty>"
  1. . . S $P(@MAG8NODE,LS,ICNT)=NAME ; External name
  1. . . S @MAG8NODE@(0)=NAME ; Internal code
  1. . . Q
  1. . ;--- Validate the item
  1. . D CHK^DIE(FILE,FIELD,"E",ITEM,.MAG8RES,"MAG8MSG")
  1. . I MAG8RES="^" S RC=MAGI,ERR=$G(MAG8MSG("DIERR",1)) D:ERR'=701 Q
  1. . . I ERR=401 S RC=$$IPVE^MAGUERR("FILE") Q
  1. . . I ERR=501 S RC=$$IPVE^MAGUERR("FIELD") Q
  1. . ;--- Store external and internal values
  1. . S ICNT=ICNT+1
  1. . S NAME=$S(FLAGS["C":$$SNTC^MAGUTL05(MAG8RES(0)),1:MAG8RES(0))
  1. . S $P(@MAG8NODE,LS,ICNT)=NAME ; External name
  1. . S @MAG8NODE@(MAG8RES)=NAME ; Internal code
  1. . Q
  1. ;
  1. ;=== Cleanup
  1. I RC K @MAG8NODE Q RC
  1. Q 0
  1. ;
  1. ;##### VALIDATES THE LIST OF NAMES/POINTERS
  1. ;
  1. ; PTNMLIST Reference to a local variable that stores a list of
  1. ; IENs and/or values of the .01 field from the file
  1. ; defined by the FILE parameter. Items should be
  1. ; separated by the '^' (see also the FLAGS parameter).
  1. ;
  1. ; FILE File number. The file must have the standard
  1. ; "B" cross-reference for the .01 field.
  1. ;
  1. ;
  1. ; MAG8NODE Closed reference to a node where the results are
  1. ; returned to:
  1. ;
  1. ; @MAG8NODE@( The list of names (.01 values) is returned here.
  1. ; Items are separated with the same delimiter as those
  1. ; in the source list.
  1. ;
  1. ; IEN) Name
  1. ;
  1. ; [FLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; C "Capitalize" the names
  1. ;
  1. ; , Use comma as item separator instead of '^'.
  1. ; (not recommended).
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; <0 Error descriptor (see the $$ERROR^MAGUERR)
  1. ; 0 Success
  1. ; >0 Number of the piece of the source list that
  1. ; contains an invalid code or name.
  1. ;
  1. VALPNLST(PTNMLIST,FILE,MAG8NODE,FLAGS) ;
  1. N MAGI,ICNT,IEN,ITEM,LS,MAGMSG,NAME,RC,ROOT,TMP,DIERR
  1. S FLAGS=$G(FLAGS),LS=$S(FLAGS[",":",",1:"^")
  1. Q:$TR(FLAGS,"C,")'="" $$IPVE^MAGUERR("FLAGS")
  1. K @MAG8NODE S (ICNT,RC)=0,ROOT=$$ROOT^DILFD(FILE,,1)
  1. Q:ROOT="" $$IPVE^MAGUERR("FILE")
  1. ;
  1. ;=== Process items of the list
  1. F MAGI=1:1:$L(PTNMLIST,LS) D Q:RC
  1. . ;--- Get name or IEN
  1. . S ITEM=$$TRIM^XLFSTR($P(PTNMLIST,LS,MAGI)) Q:ITEM=""
  1. . ;--- IEN
  1. . I +ITEM=ITEM,$D(@ROOT@(ITEM)) D Q
  1. . . S NAME=$$GET1^DIQ(FILE,ITEM_",",.01,,,"MAGMSG")
  1. . . I $G(DIERR) S RC=$$DBS^MAGUERR("MAGMSG",FILE,ITEM_",") Q
  1. . . S ICNT=ICNT+1
  1. . . S:FLAGS["C" NAME=$$SNTC^MAGUTL05(NAME)
  1. . . S $P(@MAG8NODE,LS,ICNT)=NAME ; Name
  1. . . S @MAG8NODE@(ITEM)=NAME ; IEN
  1. . . Q
  1. . ;--- Name
  1. . I $D(@ROOT@("B",ITEM))<10 S RC=MAGI Q
  1. . S ICNT=ICNT+1
  1. . S NAME=$S(FLAGS["C":$$SNTC^MAGUTL05(ITEM),1:ITEM)
  1. . S $P(@MAG8NODE,LS,ICNT)=NAME
  1. . S IEN=""
  1. . F S IEN=$O(@ROOT@("B",ITEM,IEN)) Q:IEN="" D
  1. . . S @MAG8NODE@(IEN)=NAME
  1. . . Q
  1. . Q
  1. ;
  1. ;=== Cleanup
  1. I RC K @MAG8NODE Q RC
  1. Q 0