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

MAGNAU03.m

Go to the documentation of this file.
  1. MAGNAU03 ;WOIFO/NST - Utilities for RPC calls ; 29 Jun 2017 4:16 PM
  1. ;;3.0;IMAGING;**185**;Mar 19, 2002;Build 92;Aug 02, 2012
  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. ;
  1. ; **** Get a record from a file by IEN
  1. ;
  1. ; Input parameters
  1. ; ================
  1. ;
  1. ; FILE = FileMan number of the file (e.g. 2005.003)
  1. ; PK = IEN in the file
  1. ; FLAGS
  1. ; D - exclude deleted annotations
  1. ; U - include all user's annotations
  1. ; W - include word processing fields
  1. ; CNT = First node in output array
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; if error found during execution
  1. ; MAGRY(0) = Failure status^Error getting values
  1. ; if success
  1. ; MAGRY(0) = Success status^^Total lines
  1. ; MAGRY(1) = header with name of the fields
  1. ; MAGRY(3) = "^" delimited pairs with internal and external values of the fields listed in MAGRY(1)
  1. ; MAGRY(n) = "WordProcesingFieldxxx^line value"
  1. ; MAGRY(m) = "MultipleField000^fields header"
  1. ; MAGRY(m..m+1) = "MultipleField001^fields values listed in MAGRY(m)"
  1. ;
  1. GRECBYPK(MAGRY,FILE,PK,FLAGS,CNT) ;
  1. N FIELDS,FLDSARR,FLDSARRW
  1. N OUT,ERR,TMPOUT,IENS,CNTSTART
  1. N I,J,WPTYPE,SUBFILE
  1. N RESDEL
  1. S RESDEL=$$RESDEL^MAGNU002()
  1. S FIELDS=$$GETFLDS^MAGNU001(.FLDSARR,.FLDSARRW,FILE,"") ; file fields names
  1. S IENS=PK_","
  1. D GETS^DIQ(FILE,PK_",","**","IE","OUT","ERR")
  1. ;
  1. I $$ISERROR^MAGNU002(.MAGRY,.ERR) Q ; Set MAGOUT and quit if error exists
  1. ;
  1. ; Output the data
  1. S CNT=CNT+2 ; 1 is for the header, 2 is the first record with values
  1. S CNTSTART=CNT
  1. S MAGRY(CNT)=PK
  1. S J=""
  1. F S J=$O(FLDSARR(J)) Q:J="" D
  1. . S MAGRY(CNT)=MAGRY(CNT)_RESDEL_OUT(FILE,IENS,J,"I")_RESDEL_OUT(FILE,IENS,J,"E")
  1. . Q
  1. ; Now get the word-processing and multiple fields
  1. S J=""
  1. F S J=$O(FLDSARRW(J)) Q:J="" D
  1. . I $$ISFLDWP^MAGNU001(.WPTYPE,FILE,J) D Q
  1. . . Q:'$F(FLAGS,"W") ; Exclude word-processing fields
  1. . . K TMPOUT
  1. . . M TMPOUT=OUT(FILE,IENS,J)
  1. . . D WORDPROC(.MAGRY,.CNT,.TMPOUT,FLDSARRW(J)) ; get word-processing field value
  1. . . Q
  1. . ; multi field
  1. . D MULTI(.MAGRY,.CNT,.OUT,FILE,FLDSARRW(J),FLAGS)
  1. . Q
  1. ;
  1. ; write the header
  1. S MAGRY(CNTSTART-1)="IEN"
  1. S I=""
  1. F S I=$O(FLDSARR(I)) Q:I="" S MAGRY(CNTSTART-1)=MAGRY(CNTSTART-1)_RESDEL_FLDSARR(I)
  1. S MAGRY(0)=$$SETOKVAL^MAGNU002(CNT)
  1. Q
  1. ;
  1. WORDPROC(MAGRY,CNT,WP,FLDNAME) ; add word-processing field values to the result
  1. N L,RESDEL
  1. S RESDEL=$$RESDEL^MAGNU002()
  1. S L=""
  1. F S L=$O(WP(L)) Q:'L D
  1. . S CNT=CNT+1,MAGRY(CNT)=FLDNAME_$TR($J(L,3)," ",0)_RESDEL_WP(L)
  1. . Q
  1. Q
  1. ;
  1. MULTI(MAGRY,CNT,OUT,FILE,FLDNAME,FLAGS) ; add word-processing field values to the result
  1. N IEN,J,L,RESDEL
  1. N SUBFILE,FIELDS,FLDSARR,FLDSARRW
  1. ;
  1. S RESDEL=$$RESDEL^MAGNU002()
  1. S SUBFILE=$$GSUBFILE^MAGNU001(FILE,FLDNAME) ; get sub-file number
  1. S FIELDS=$$GETFLDS^MAGNU001(.FLDSARR,.FLDSARRW,SUBFILE,"")
  1. ; write header of multiple record
  1. S CNT=CNT+1,MAGRY(CNT)=FLDNAME_"000"_RESDEL_"IEN"
  1. S J=""
  1. F S J=$O(FLDSARR(J)) Q:J="" S MAGRY(CNT)=MAGRY(CNT)_RESDEL_FLDSARR(J)
  1. ;
  1. ; write the values of the multiple record
  1. S L=""
  1. F S L=$O(OUT(SUBFILE,L)) Q:L="" D
  1. . I '$F(FLAGS,"D") Q:$G(OUT(SUBFILE,L,5,"I")) ; Skip deleted annotations
  1. . I '$F(FLAGS,"U") Q:OUT(SUBFILE,L,1,"I")'=DUZ ; Skip deleted annotations
  1. . S IEN=$P(L,",") ; IEN of the mutliple record
  1. . S CNT=CNT+1,MAGRY(CNT)=FLDNAME_$TR($J(IEN,3)," ",0)_RESDEL_IEN
  1. . S J=""
  1. . F S J=$O(FLDSARR(J)) Q:J="" D
  1. . . S MAGRY(CNT)=MAGRY(CNT)_RESDEL_OUT(SUBFILE,L,J,"I")_RESDEL_OUT(SUBFILE,L,J,"E")
  1. . . Q
  1. . S J=""
  1. . F S J=$O(FLDSARRW(J)) Q:J="" D
  1. . . I $$ISFLDWP^MAGNU001(.WPTYPE,SUBFILE,J) D Q
  1. . . . Q:'$F(FLAGS,"W") ; skip word processing field
  1. . . . K TMPOUT
  1. . . . M TMPOUT=OUT(SUBFILE,L,J)
  1. . . . D WORDPROC(.MAGRY,.CNT,.TMPOUT,FLDSARRW(J)) ; get word-processing field value
  1. . . . Q
  1. . . ; multi field
  1. . . D MULTI(.MAGRY,.CNT,.OUT,SUBFILE,FLDSARRW(J),FLAGS)
  1. . . Q
  1. . Q
  1. Q