source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORXU004.m@ 1736

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

initial load of WorldVistAEHR

File size: 822 bytes
RevLine 
[613]1RORXU004 ;HCIOFO/SG - REPORT UTILITIES (STATISTICS) ; 9/23/03 10:51am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** CALCULATES THE MEDIAN VALUE OF THE CROSS-REFERENCE
7 ;
8 ; XREFNODE Root node of the old-style cross-reference
9 ; NUM Total number of elements in the array
10 ;
11 ; Return Values:
12 ; "" Error (or an empty array)
13 ; '="" Median Value
14 ;
15XREFMDNV(XREFNODE,NUM) ;
16 Q:NUM'>0 ""
17 N FLT,FLTL,I,MV,N,PI,VPOS
18 S FLTL=$L(XREFNODE)-1,FLT=$E(XREFNODE,1,FLTL)
19 S N=(NUM+1)\2,VPOS=$QL(XREFNODE)+1
20 ;--- Find the median value
21 S PI=XREFNODE
22 F I=1:1:N S PI=$Q(@PI) Q:$E(PI,1,FLTL)'=FLT
23 Q:$E(PI,1,FLTL)'=FLT ""
24 ;--- Calculate median value if NUM is even
25 S MV=$QS(PI,VPOS)
26 I '(NUM#2) D Q:I="" "" S MV=(MV+I)/2
27 . S PI=$Q(@PI),I=$S($E(PI,1,FLTL)=FLT:$QS(PI,VPOS),1:"")
28 Q MV
Note: See TracBrowser for help on using the repository browser.