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

MAGGNLKP.m

Go to the documentation of this file.
  1. MAGGNLKP ;WOIFO/GEK - Lookup from delphi into any file ; [ 06/20/2001 08:56 ]
  1. ;;3.0;IMAGING;**8,92,46,59,151**;Mar 19, 2002;Build 21;Dec 19, 2016
  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. LKP(MAGRY,MAGIN,DATA) ;RPC [MAG3 LOOKUP ANY]
  1. ; Generic lookup using FIND^DIC
  1. ; MAGRY is the Array to return.
  1. ; MAGIN is parameter sent by calling app (Delphi)
  1. ; FILE NUM ^ NUM TO RETURN ^ TEXT TO MATCH ^ FIELDS ^ SCREEN ($P 5-99)
  1. ;
  1. ; DATA :
  1. ; LVIEW =Piece 1
  1. ; +LVIEW = 1 :
  1. ; result array is formatted for a magListView control
  1. ; i.e. ^ delimiter for data and "|" delimiter for IEN
  1. ; +LVIEW = 0 :
  1. ; old way, " " delim for data and '^' delim for IEN
  1. ; INDEX = Piece 2 ;151T4 corrected spelling, from INDX
  1. ; This is the index to search
  1. ; Defaults to "B"
  1. ;
  1. N $ETRAP,$ESTACK S $ETRAP="D ERRA^MAGGTERR"
  1. ;
  1. N Y,XI,Z,FI,MAGIEN,INFO,LVIEW ;151T4 Deleted the INDX variable.
  1. N FILE,IENS,FLDS,FLAGS,VAL,NUM,INDEX,SCR,IDENT,TROOT
  1. S (FILE,IENS,FLDS,FLAGS,VAL,NUM,INDEX,SCR,IDENT,TROOT)=""
  1. S MAGIN=$G(MAGIN)
  1. S DATA=$G(DATA)
  1. ;
  1. S FILE=+$P(MAGIN,U,1)
  1. S NUM=$S(+$P(MAGIN,U,2):+$P(MAGIN,U,2),1:200)
  1. S VAL=$P(MAGIN,U,3)
  1. S FLDS=$P(MAGIN,U,4)
  1. S SCR=$P(MAGIN,U,5,99)
  1. ;
  1. S LVIEW=+$P(DATA,"^",1)
  1. S INDEX=$S($L($P(DATA,"^",2)):$P(DATA,"^",2),1:"B")
  1. ;
  1. I 'FILE S MAGRY(1)="0^ERROR - Invalid Parameter: File Number ? " Q
  1. I '$$VFILE^DILFD(FILE) S MAGRY(1)="0^ERROR - Invalid File # - "_FILE Q
  1. ; Number of entries to return, If 0 we'll stop at 200
  1. ;
  1. K ^TMP("DILIST",$J)
  1. K ^TMP("DIERR",$J)
  1. ; VAL is the initial value to search for. i.e. the user input.
  1. ; Next line is to stop the FM Infinite Error Trap problem.
  1. I $L(VAL)>30 S MAGRY(0)="0^Invalid Input: '"_$E(VAL,1,40)_"...' is too long. "_$L(VAL)_" characters." Q
  1. D FIND^DIC(FILE,IENS,FLDS,FLAGS,VAL,NUM,INDEX,SCR,IDENT,TROOT)
  1. ;
  1. I '$D(^TMP("DILIST",$J,1)) S XI=1 D Q
  1. . I $D(^TMP("DIERR",$J)) D FINDERR(XI) Q
  1. . S MAGRY(XI)="0^NO MATCH for lookup on """_$P(MAGIN,"^",3)_""""
  1. ; so we have some matches, (BUT we could still have an error)
  1. ; so first list all matches, then the ERROR
  1. ; Next lines were Q&D but old .EXE's expect return string with
  1. ; this syntax, when all T11 code is gone, this can be rewritten
  1. I LVIEW S XI="" F S XI=$O(^TMP("DILIST",$J,1,XI)) Q:XI="" S X=^(XI) D
  1. . S MAGIEN=^TMP("DILIST",$J,2,XI)
  1. . S Z=".01",FLD="NAME"
  1. . F S Z=$O(^TMP("DILIST",$J,"ID",XI,Z)) Q:Z="" S X=X_"^"_^(Z),FLD=FLD_"^"_$$GET1^DID(FILE,Z,"","LABEL","MAGFLD")
  1. . S MAGRY(.05)=FLD
  1. . S MAGRY(XI)=X_"^|"_MAGIEN
  1. . Q
  1. I 'LVIEW S XI="" F S XI=$O(^TMP("DILIST",$J,1,XI)) Q:XI="" S X=^(XI) D
  1. . S MAGIEN=^TMP("DILIST",$J,2,XI)
  1. . S Z=""
  1. . F S Z=$O(^TMP("DILIST",$J,"ID",XI,Z)) Q:Z="" S X=X_" "_^(Z)
  1. . S MAGRY(XI)=X_"^"_MAGIEN
  1. . Q
  1. I $D(^TMP("DIERR",$J)) D FINDERR() Q
  1. I $D(^TMP("DILIST",$J,0)) S INFO=^(0) D
  1. . S MAGRY(0)=$P(INFO,"^")_U_"Found "_$P(INFO,"^")_" entr"_$S((+INFO=1):"y",1:"ies")_" matching """_$P(MAGIN,"^",3)_""""
  1. . I $P(INFO,"^",3)>0 S MAGRY(0)=MAGRY(0)_" there are more"
  1. . Q
  1. Q
  1. FINDERR(XI) ;
  1. ;
  1. I '+$G(XI) S XI=$O(MAGRY(""),-1)+1
  1. S MAGRY(XI)="ERROR^"_^TMP("DIERR",$J,1,"TEXT",1)
  1. Q