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

MAGGSIV1.m

Go to the documentation of this file.
  1. MAGGSIV1 ;WOIFO/GEK - Imaging Validate Data ; [ 08/15/2004 08:57 ]
  1. ;;3.0;IMAGING;**8,20,59**;Nov 27, 2007;Build 20
  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. VALID(MAGF,MAGL,MAGD,MAGRES) ; call to validate value for field in a FM file.
  1. ; Function is boolean. Returns:
  1. ; 0 - Invalid
  1. ; 1 - Valid
  1. ; "" - Error
  1. ; Call this function before you set the FDA Array.
  1. ; MAGD - sent by reference because it could be Internal or External
  1. ; and if it is external and valid, it is changed to Internal.
  1. ;
  1. ; MAGF : File Number
  1. ; MAGL : Field Number
  1. ; MAGD : (sent by reference) data value of field
  1. ; MAGRES: (sent by reference) Result message
  1. ;
  1. N $ETRAP,$ESTACK S $ETRAP="D ERR^"_$T(+0)
  1. N MAGR,MAGMSG,MAGSP,MAGRESA,MAGE,MAGPT
  1. ;if a BAD field number
  1. I '$$VFIELD^DILFD(MAGF,MAGL) D Q 0
  1. . S MAGRES="The field number: "_MAGL_", in File: "_MAGF_", is invalid."
  1. D FIELD^DID(MAGF,MAGL,"","SPECIFIER","MAGSP")
  1. ; If it is a pointer field
  1. ; If an integer - We assume it is a pointer and validate that and Quit.
  1. ; If not integer - We assume it is external value, proceed to let CHK do validate
  1. I (MAGSP("SPECIFIER")["P"),(+MAGD=MAGD) D Q MAGPT
  1. . I $$EXTERNAL^DILFD(MAGF,MAGL,"",MAGD)'="" S MAGPT=1,MAGRES="Valid pointer" Q
  1. . S MAGPT=0,MAGRES="The value: "_MAGD_" for field: "_MAGL_" in File: "_MAGF_" is an invalid Pointer."
  1. . Q
  1. ;
  1. D CHK^DIE(MAGF,MAGL,"E",MAGD,.MAGR,"MAGMSG")
  1. ; If success, Quit. We changed External to Internal. Internal is in MAGR
  1. I MAGR'="^" S MAGD=MAGR Q 1
  1. ; If not success Get the error text and Quit 0
  1. D MSG^DIALOG("A",.MAGRESA,245,5,"MAGMSG")
  1. S MAGRES=MAGRESA(1)
  1. Q 0
  1. VALINDEX(MAGRY,TYPE,SPEC,PROC) ; Validate the interdependency of Index Terms.
  1. ; MAGRY is the return array
  1. ; MAGRY(0)="1^Okay" or "0^error message"
  1. ; MAGRY(1..n) Information about the Type,Spec and Proc
  1. ;
  1. ; Validate the Procedure/Event <-> Specialty/SubSpecialty interdependency
  1. ; Assure the TYPE is a Clinical TYPE.
  1. ; Assure all are Active.
  1. N CLS,RES,ARR,TYX,PRX,SPX,OK
  1. K MAGRY
  1. S TYPE=$G(TYPE),PROC=$G(PROC),SPEC=$G(SPEC)
  1. I TYPE=0 S TYPE=""
  1. I PROC=0 S PROC=""
  1. I SPEC=0 S SPEC=""
  1. I ((PROC]"")!(SPEC]"")) I TYPE="" S MAGRY(0)="0^Type is required." Q 0
  1. ; TYPE is required, but not enforcing yet. All vendors are not sending
  1. ; index values.
  1. ; VALID will accept External or Internal and return Internal if Valid
  1. I $L(TYPE) I '$$VALID(2005,42,.TYPE,.RES) S MAGRY(0)="0^"_RES Q 0
  1. I $L(PROC) I '$$VALID(2005,43,.PROC,.RES) S MAGRY(0)="0^"_RES Q 0
  1. I $L(SPEC) I '$$VALID(2005,44,.SPEC,.RES) S MAGRY(0)="0^"_RES Q 0
  1. ;
  1. I TYPE D I 'OK S MAGRY(0)=OK Q 0
  1. . S OK=1,TYX=TYPE_","
  1. . K ARR D GETS^DIQ(2005.83,TYX,".01;1;2","EI","ARR")
  1. . S MAGRY(1)="Type - Class : "_ARR(2005.83,TYX,.01,"E")_" - "_ARR(2005.83,TYX,1,"E")
  1. . I $L(ARR(2005.83,TYX,2,"E")) S MAGRY(1)=MAGRY(1)_" - "_ARR(2005.83,TYX,2,"E")
  1. . I ARR(2005.83,TYX,2,"I")="I" S OK="0^Type is Inactive"
  1. . Q
  1. ;
  1. I SPEC D I 'OK S MAGRY(0)=OK Q 0
  1. . S OK=1,SPX=SPEC_","
  1. . K ARR D GETS^DIQ(2005.84,SPX,".01;2;4","EI","ARR")
  1. . S MAGRY(2)="Specialty/SubSpecialty: "_ARR(2005.84,SPX,.01,"E")
  1. . I $L(ARR(2005.84,SPX,4,"E")) S MAGRY(2)=MAGRY(2)_" - "_ARR(2005.84,SPX,4,"E")
  1. . I $L(ARR(2005.84,SPX,2,"E")) S MAGRY(2)=MAGRY(2)_" <"_ARR(2005.84,SPX,2,"E")_">"
  1. . I ARR(2005.84,SPX,4,"I")="I" S OK="0^Specialty is Inactive"
  1. . Q
  1. ;
  1. I PROC D I 'OK S MAGRY(0)=OK Q 0
  1. . S OK=1,PRX=PROC_","
  1. . K ARR D GETS^DIQ(2005.85,PRX,".01;4","EI","ARR")
  1. . S MAGRY(4)="Procedure/Event : "_$$GET1^DIQ(2005.85,PROC,.01)
  1. . I $L(ARR(2005.85,PRX,4,"E")) S MAGRY(4)=MAGRY(4)_" - "_ARR(2005.85,PRX,4,"E")
  1. . I ARR(2005.85,PRX,4,"I")="I" S OK="0^Procedure is Inactive"
  1. . Q
  1. ;
  1. ; If PROC and SPEC are "", then Quit, any TYPE by itself is valid
  1. I (PROC=""),(SPEC="") S MAGRY(0)="1^Okay" Q 1
  1. ; Here, TYPE has to be Clin.
  1. S CLS=$$GET1^DIQ(2005.83,TYPE,1,"","MAGTAR") I $E(CLS,1,5)="ADMIN" D Q 0
  1. . S MAGRY(0)="0^The Type Index is Administrative, it has to be Clinical."
  1. I (PROC="")!(SPEC="") S MAGRY(0)="1^Okay" Q 1
  1. ; we get here, we have to validate the interdependency of SPEC <-> PROC.
  1. I '$O(^MAG(2005.85,PROC,1,0)) S MAGRY(0)="1^Okay" Q 1
  1. I '$D(^MAG(2005.85,PROC,1,"B",SPEC)) D Q 0
  1. . S MAGRY(0)="0^Invalid Association between Spec/SubSpec and Proc/Event"
  1. . Q
  1. S MAGRY(0)="1^Okay"
  1. Q 1
  1. ERR ;
  1. N ERR
  1. S ERR=$$EC^%ZOSV
  1. S MAGRES="0^Error during data validation: "_ERR
  1. D LOGERR^MAGGTERR(ERR)
  1. D @^%ZOSF("ERRTN")
  1. D CLEAN^DILF
  1. Q