source: FOIAVistA/trunk/r/NOIS-FSC/FSCRPCOS.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: 1.8 KB
Line 
1FSCRPCOS ;SLC/STAFF-NOIS RPC Sort ;2/10/97 14:47
2 ;;1.1;NOIS;;Sep 06, 1998
3 ;
4SORT(IN,OUT) ; from FSCRPX (RPCSort)
5 ; SORT(seq #) = zero node of field
6 ; SORT(sort seq #,"D") = "" (exists if field is to be sorted in descending order)
7 N CALL,CHECK,CNT,DA,DESCEND,DIC,DIQ,DR,FLD,GBL,LASTCNT,LEN,LINE,LNUM,NUM,SORT,TMPSORT,TYPE,VAL,VALUE K DIQ,SORT,VALUE
8 S NUM=0 F S NUM=$O(^TMP("FSCRPC",$J,"INPUT",NUM)) Q:NUM<1 S LINE=^(NUM) D
9 .S SORT(NUM)=$P(LINE,U,2,99)
10 .I $P(LINE,U)="D" S SORT(NUM,"D")=""
11 I '$O(SORT(0)) Q
12 S DESCEND="" K ^TMP("FSC SORT",$J)
13 F CNT=1:1 Q:'$D(SORT(CNT)) S LASTCNT=CNT I $D(SORT(CNT,"D")) S DESCEND=DESCEND_CNT_","
14 S LEN=60\LASTCNT
15 S DR="",CNT=0 F S CNT=$O(SORT(CNT)) Q:CNT<1 S DR=DR_$P(SORT(CNT),U,8)_";"
16 S DIC=7100,DIQ="VALUE",DIQ(0)="IE"
17 S CALL=0 F S CALL=$O(^TMP("FSC CURRENT LIST",$J,"C",CALL)) Q:CALL<1 D
18 .S DA=CALL K VALUE D EN^DIQ1
19 .S GBL="^TMP(""FSC SORT"",$J",CNT=0 F S CNT=$O(SORT(CNT)) Q:CNT<1 D
20 ..S FLD=$P(SORT(CNT),U,8),TYPE=$P(SORT(CNT),U,3)
21 ..S VAL=VALUE(7100,CALL,FLD,$S(TYPE["D":"I",1:"E"))
22 ..D
23 ...I TYPE["D"!(TYPE["N") S VAL=$S(VAL'<1:+VAL,$E(VAL)'=".":+VAL,VAL?1P1N.N:"0"_VAL,1:+VAL) I DESCEND[(CNT_",") S VAL=9999999-VAL Q
24 ...S VAL=$$UP^XLFSTR(VAL) I DESCEND[(CNT_",") S VAL=$TR(VAL,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ","9876543210ZYXWVUTSRQPONMLKJIHGFEDCBA")
25 ..S VAL=""""_$S(DESCEND[(CNT_",")&'$L(VAL):"Z",1:" ")_$E(VAL,1,LEN)_""""
26 ..S GBL=GBL_","_VAL
27 ..I '$O(SORT(CNT)) S GBL=GBL_","_CALL_")" S @GBL=CALL
28 K ^TMP("FSC CURRENT LIST",$J),DIC,DIQ,VALUE
29 S LNUM=0
30 S TMPSORT="^TMP(""FSC SORT"",$J)",CHECK="^TMP(""FSC SORT"","_$J_",""z"""
31 F S TMPSORT=$Q(@TMPSORT) Q:TMPSORT]CHECK S CALL=@TMPSORT D
32 .S LNUM=LNUM+1
33 .S (^TMP("FSCRPC",$J,"OUTPUT",LNUM),^TMP("FSC CURRENT LIST",$J,LNUM+1000))=CALL_U_$$SHORT^FSCRPXUS(CALL,DUZ)
34 .S ^TMP("FSC CURRENT LIST",$J,"C",CALL)=LNUM+1000
35 K ^TMP("FSC SORT",$J)
36 Q
Note: See TracBrowser for help on using the repository browser.