source: FOIAVistA/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNLRU.m@ 1611

Last change on this file since 1611 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.1 KB
Line 
1SPNLRU ;ISC-SF/GB-SCD UTILITIES FOR REPORT PRINTING ;6/23/95 12:04
2 ;;2.0;Spinal Cord Dysfunction;;01/02/1997
3MEDIAN(TOTITEMS,ARRAY) ; Function returns median value of array. Info at end.
4 N EVEN,TARGET,NUMITEMS,MEDIAN,VALUE
5 Q:'TOTITEMS 0
6 S EVEN='(TOTITEMS#2) ; Is number of items even or odd?
7 S TARGET=(TOTITEMS+1)\2 ; Which item do we want to reach?
8 S VALUE=-1,NUMITEMS=0 ; Step thru array, looking for target.
9 F S @("VALUE=$O("_ARRAY_VALUE_"))") D Q:NUMITEMS'<TARGET
10 . S @("NUMITEMS=NUMITEMS+$G("_ARRAY_VALUE_"))")
11 I VALUE="" W !,"MEDIAN: We hit the end of the array, but shouldn't have" Q 0
12 S MEDIAN=VALUE
13 I EVEN,(NUMITEMS=TARGET) D ; May need to get next value and average.
14 . S @("VALUE=$O("_ARRAY_VALUE_"))")
15 . S MEDIAN=(MEDIAN+VALUE)/2
16 Q MEDIAN
17 ; The median value in an array of an odd number of items is
18 ; the value of the middle item. (If there are 5 items, the 3rd is
19 ; the median.)
20 ; The median value in an array of an even number of items is the
21 ; average of the two middle items. (If there are 6 items, the median
22 ; is the average of the 3rd and 4th items.)
23 ; Example:
24 ; values number of items per value
25 ; | |
26 ; S GBTEST(1,"CT","IP",30)=3
27 ; S GBTEST(1,"CT","IP",148)=1
28 ; S GBTEST(1,"CT","IP",160)=1
29 ; S GBTEST(1,"CT","IP",365)=1
30 ; So we've got 3 items with a value of 30, and 1 item each at 148,
31 ; 160, and 365.
32 ; S TOTITEMS=6 (That's 3+1+1+1)
33 ; Now invoke the function. The first arg is the total number of items.
34 ; The second arg is the 'root' of the array up to, but not including
35 ; the values. The root must be in quotes.
36 ; S MEDVAL=$$MEDIAN(TOTITEMS,"GBTEST(1,""CT"",""IP"",")
37 ; (MEDVAL should be 89)
38GETNAME(DFN,NAME,SSN) ;
39 N VADM,VA,I ; I need to do this because DEM^VADPT kills I, which is
40 ; used as a looping variable by many routines which call GETNAME.
41 I $D(^DPT(DFN,0)) D
42 . ; If the user has the correct key...
43 . I $D(^XUSEC("SPNL SCD PTS",DUZ)) D
44 . . D DEM^VADPT
45 . . S NAME=$E(VADM(1),1,30)
46 . . S SSN=VA("PID")
47 . E D
48 . . S NAME="Not Revealed"
49 . . S SSN=""
50 E D
51 . S NAME="Not in PATIENT FILE!"
52 . S SSN=""
53 Q
54CENTER(STRING,LINELEN) ; Function centers a string
55 N POSN,LBLANKS
56 I '$D(LINELEN) S LINELEN=IOM
57 S POSN=(LINELEN-$L(STRING))\2
58 I POSN<2 Q STRING
59 S LBLANKS="",$P(LBLANKS," ",POSN-1)=""
60 Q LBLANKS_STRING
61PAD(STRING,LINELEN) ; Function pads a string with spaces on the right
62 N BLANKS,NUMBLANK
63 I '$D(LINELEN) S LINELEN=IOM
64 S NUMBLANK=LINELEN-$L(STRING)
65 I NUMBLANK<1 Q STRING
66 S BLANKS="",$P(BLANKS," ",NUMBLANK)=""
67 Q STRING_BLANKS
68HEADER(TITLE,ABORT) ;
69 N DIR,DIRUT,I,TODAY,LENTITLE
70 ; If we are printing to the screen and we are not printing the
71 ; first page of the report, "Press return to continue..."
72 S SPNPAGE=SPNPAGE+1
73 I $G(IOST)["C-"&(SPNPAGE'=1) D Q:ABORT
74 . S DIR(0)="E"
75 . D ^DIR
76 . I $D(DIRUT) S ABORT=1
77 W @IOF
78 I $G(IOST)'["C-" D
79 . S TODAY=$E(DT,4,5)_"/"_$E(DT,6,7)_"/"_$E(DT,2,3)
80 . S TITLE(1)=TODAY_$E(TITLE(1),$L(TODAY)+1,999)
81 . S LENTITLE=$L(TITLE(1))
82 . S TITLE(1)=TITLE(1)_$J("Page "_SPNPAGE,IOM-LENTITLE)
83 S I="" F S I=$O(TITLE(I)) Q:I="" W !,TITLE(I)
84 W !
85 I IOST'["C-" S TITLE(1)=$E(TITLE(1),1,LENTITLE)
86 Q
Note: See TracBrowser for help on using the repository browser.