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

INHMSR20.m

Go to the documentation of this file.
  1. INHMSR20 ;KN; 27 Nov 95 09:56; Statistical Report-Utility
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. ; DESCRIPTION:
  1. ; The processing of this routine is used to collect for
  1. ; utility functions to support INHMSR2 Statistical Report
  1. ; Display module.
  1. ;
  1. Q
  1. GNDP(INFL,INFD) ; Get node and piece
  1. ;
  1. ; Description: The function GNDP is used to get node and piece
  1. ; where data are at.
  1. ; Return: Node#^Piece#
  1. ; Parameters:
  1. ; INFL = File ien (internal entry number)
  1. ; INFD = Field ien
  1. ; Code begins:
  1. Q $P($P($G(^DD(INFL,INFD,0)),U,4),";",1,2)
  1. ;
  1. GLN(INFL) ; Get global name
  1. ;
  1. ; Description: The function GLN is used to get global name.
  1. ; Return: Global name (ex. ^INTHU)
  1. ; Parameters:
  1. ; INFL = File ien ( internal entry number )
  1. ; Code begins:
  1. Q $G(^DIC(INFL,0,"GL"))
  1. ;
  1. PRVF(CF,AR) ; Previous field
  1. ;
  1. ; Description: The function PRVF is used to return previous
  1. ; field ien, given current field ien CF.
  1. ; Return: Field ien for previous field of CF
  1. ; Parameters:
  1. ; CF = current field ien
  1. ; AR = Name of array which contains an array of field ien
  1. ; Code begins:
  1. N TMP
  1. ; No range selected, keep current field the same
  1. I $G(CF)="" S TMP=$G(CF) Q TMP
  1. ; For date, and number back up a litle bit (-.0000001)
  1. I (@AR["N")!(@AR["D") S TMP=CF-.0000001
  1. ; For pointer or free text keep the same
  1. I (@AR["P")!(@AR["F")!(@AR["S") S TMP=CF
  1. Q TMP
  1. ;
  1. NXTF(CF,AR) ; Next field ien
  1. ;
  1. ; Description: The function NXTF is used to return next field
  1. ; ien, given current field ien CF
  1. ; Return: Field ien for next field of CF
  1. ; Parameters:
  1. ; CF = current field ien
  1. ; AR = Name of array which contains an array of field ien
  1. ; Code begins:
  1. N TMP
  1. I $G(CF)="" S TMP=$G(CF) Q TMP
  1. ; For DATE, and Number jack it up a a little bit (+.0000001)
  1. I (@AR["D")!(@AR["N") S TMP=CF+.0000001
  1. ; For pointer or free text, use ~ for compare
  1. I (@AR["P")!(@AR["F")!(@AR["S") S TMP=CF_"~"
  1. Q TMP
  1. ;
  1. CMP(S,IINA,TML,TMU) ; Compare
  1. ;
  1. ;
  1. ; Description: The function CMP is used to compare if S is
  1. ; in the range from TML to TMU, and determine
  1. ; any type of data date, numeric, or string in a
  1. ; specific range.
  1. ; Return: 1 = True
  1. ; 0 = False
  1. ; Parameters:
  1. ; S = Selected items to compare
  1. ; IINA = Contains type of field
  1. ; TML = Lower limit
  1. ; TMU = Upper limit
  1. ; Code begins:
  1. N INTMP
  1. S INTMP=0
  1. ; No FROM and TO, count this field
  1. I (TML="")&(TMU="")&(S]"") Q 1
  1. ; No TO, compare from TML and on
  1. I (TMU="") D Q INTMP
  1. .I ((IINA["N")!(IINA["D"))&(S'<TML) S INTMP=1 Q
  1. .I ((IINA["P")!(IINA["S")!(IINA["F"))&(TML']S) S INTMP=1 Q
  1. ; No FROM
  1. I (TML="") D Q INTMP
  1. .I ((IINA["N")!(IINA["D"))&(S'>TMU) S INTMP=1 Q
  1. .I ((IINA["P")!(IINA["S")!(IINA["F"))&(S']TMU) S INTMP=1 Q
  1. ; Both FROM and TO, compare to lower limit and upper limit
  1. I (TML'="")&(TMU'="") D Q INTMP
  1. .I ((IINA["N")!(IINA["D"))&(S'<TML)&(S'>TMU) S INTMP=1 Q
  1. .I ((IINA["P")!(IINA["S")!(IINA["F"))&(TML']S)&(S']TMU) S INTMP=1 Q
  1. ;nothing match, return 0
  1. Q INTMP
  1. ;
  1. FILL(INC,REF) ; Fill up incount array
  1. ;
  1. ; Description: The function FILL is used to fill an array with
  1. ; all the subtotals (count) and totals.
  1. ; Return: none
  1. ; Parameters:
  1. ; INC = The counter array
  1. ; REF = Name of INC array
  1. ; Code begins:
  1. N LEV,TREF,ZLEV S LEV=""
  1. ; Go through the current level of the array, LEV is the current subscript
  1. F S LEV=$O(@REF@(LEV)) Q:LEV="" D
  1. .; if the subscript is not a number, concat "" to make it a string
  1. . S ZLEV=LEV S:LEV'=(+LEV) ZLEV=""""_LEV_""""
  1. .; construct the indirect value for next level of the array TREF
  1. . S:REF[")" TREF=$E(REF,1,$L(REF)-1)_","_ZLEV_")"
  1. . S:REF'[")" TREF=REF_"("_ZLEV_")"
  1. .; Recursively calling this same routine
  1. . D FILL(.INC,TREF)
  1. .; Accumulating the count
  1. . S @REF=$G(@REF)+$G(@TREF)
  1. Q
  1. ;
  1. FILL1(INC,REF) ; Display the output of the Statistical Report
  1. ;
  1. ; Description: The function FILL1 is used to perform the display
  1. ; routine (using recursive).
  1. ;
  1. ; - upon entry set LEVEL=0
  1. ; - INSFLG flag to disable field type display in second line & on
  1. ; - INL is the length of field type, if > 20 then go to new line
  1. ; ex. in case of the ORIGINAL TRANSACTION TYPE.
  1. ; Return: none
  1. ; Parameters:
  1. ; INC = The counter array
  1. ; REF = Name of INC array
  1. ; Code begins:
  1. N CSUB,TREF,ZSUB,DFLG S CSUB="",INSFLG=0
  1. Q:$G(DUOUT)
  1. F S CSUB=$O(@REF@(CSUB)) Q:CSUB="" D Q:$G(DUOUT)
  1. . S ZSUB=CSUB S:CSUB'=(+CSUB) ZSUB=""""_CSUB_""""
  1. . S:REF[")" TREF=$E(REF,1,$L(REF)-1)_","_ZSUB_")"
  1. . S:REF'[")" TREF=REF_"("_ZSUB_")"
  1. .; Set level of the subscript
  1. . S LEVEL=$G(LEVEL)+1
  1. .; If only six lines left in the page, then go to the new page
  1. . I $Y+6>IOSL D HEAD^INHMSR21(INIEN,.INA,INTYPE) Q:$G(DUOUT)
  1. .;display field type only on the first line of a new type
  1. .I '$G(INSFLG) W !?(LEVEL*3),$G(INDP(LEVEL))," : " D INLN^INHMSR21(CSUB,LEVEL*3) S INL(LEVEL)=$L($G(INDP(LEVEL)))
  1. .I ($G(INSFLG)&($G(INL(LEVEL))>20)) W !?(5+(LEVEL*3)),CSUB
  1. .I ($G(INSFLG)&($G(INL(LEVEL))'>20)) W !?($G(INL(LEVEL))+3+(LEVEL*3)),CSUB
  1. . D FILL1(.INC,TREF) Q:$G(DUOUT)
  1. .; check if this is the last level, then this is the count
  1. . I $G(INSEL)=$G(LEVEL) D ADJ^INHMSR21($G(@TREF)) S INSFLG=1
  1. .; otherwise it must be the subtotal
  1. . I $Y+7>IOSL D HEAD^INHMSR21(INIEN,.INA,INTYPE) Q:$G(DUOUT)
  1. . I $G(INSEL)=($G(LEVEL)+1) D INDASH^INHMSR21
  1. . I ($G(LEVEL)'=$G(INSEL)) W !?(LEVEL*3),$G(INDP(LEVEL))," SUBTOTAL : " D INLN^INHMSR21(CSUB,LEVEL*3+5) D ADJ^INHMSR21($G(@TREF)) S INSFLG=0 W !
  1. . S LEVEL=$G(LEVEL)-1
  1. Q