source: FOIAVistA/tag/r/CLINICAL_CASE_REGISTRIES-ROR/RORRP029.m@ 628

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

initial load of FOIAVistA 6/30/08 version

File size: 3.5 KB
Line 
1RORRP029 ;HCIOFO/SG - RPC: ADDRESS UTILITIES ; 4/16/03 9:35am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 ; This routine uses the following IAs:
5 ;
6 ; #10056 Read access to the STATE file (#5)
7 ;
8 Q
9 ;
10 ;***** RETURNS THE LIST OF STATES
11 ; RPC: [ROR LIST STATES]
12 ;
13 ; .RESULTS Reference to a local variable where the results
14 ; are returned to.
15 ;
16 ; PART The search pattern (partial match restriction)
17 ;
18 ; [FLAGS] Flags that control the execution (can be combined):
19 ; A Enable abbreviation search (if PART contains 2
20 ; character abbreviation, the corresponding state
21 ; is returned. Otherwise, the regular search is
22 ; performed).
23 ; B Backwards. Traverses the index in the opposite
24 ; direction of normal traversal.
25 ;
26 ; [NUMBER] Maximum number of entries to return. A value of "*"
27 ; or no value in this parameter designates all entries.
28 ;
29 ; [FROM] The index entry(s) from which to begin the list.
30 ; You should use the pieces of the @RESULTS@(0) node
31 ; (starting from the second one) to continue the
32 ; listing in the subsequent procedure calls.
33 ;
34 ; NOTE: The FROM value itself is not included in
35 ; the resulting list.
36 ;
37 ; The ^TMP("DILIST",$J) global node is used by the procedure.
38 ;
39 ; See description of the LIST^DIC for more details about the
40 ; PART, NUMBER and FROM parameters.
41 ;
42 ; Return Values:
43 ;
44 ; A negative value of the first "^"-piece of the @RESULTS@(0)
45 ; indicates an error (see the RPCSTK^RORERR procedure for more
46 ; details).
47 ;
48 ; Otherwise, number of states and the value of the FROM
49 ; parameter for the next procedure call are returned in the
50 ; @RESULTS@(0) and the subsequent nodes of the global array
51 ; contain the states.
52 ;
53 ; @RESULTS@(0) Result Descriptor
54 ; ^01: Number of states
55 ; ^02: Values that comprise the FROM
56 ; ^nn: parameter for the subsequent call
57 ;
58 ; @RESULTS@(i) State
59 ; ^01: IEN
60 ; ^02: Name
61 ; ^03: Abbreviation
62 ; ^04: VA State Code
63 ;
64STATELST(RESULTS,PART,FLAGS,NUMBER,FROM) ;
65 N BUF,FIELDS,I,RC,RORERRDL,TMP
66 D CLEAR^RORERR("STATELST^RORRP029",1)
67 K RESULTS S RESULTS=$NA(^TMP("DILIST",$J)) K @RESULTS
68 S FIELDS="@;.01;1;2"
69 ;--- Check the parameters
70 S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
71 . ;--- Flags
72 . S FLAGS=$$UP^XLFSTR($G(FLAGS))
73 . ;--- Others
74 . S PART=$G(PART),FROM=$G(FROM)
75 . S NUMBER=$S($G(NUMBER)>0:+NUMBER,1:"*")
76 ;--- Setup the start point
77 F I=1:1 S TMP=$P(FROM,U,I) Q:TMP="" S FROM(I)=TMP
78 S FROM=$G(FROM(1))
79 ;--- Check for the abbreviation
80 S RC=0
81 I FLAGS["A",$L(PART)=2 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
82 . D LIST^DIC(5,,FIELDS,"P",2,,PART,"C",,,,"RORMSG")
83 . I $G(DIERR) S RC=$$DBS^RORERR("RORMSG",-9,,,5) Q
84 . S:+$G(^TMP("DILIST",$J,0))=1 RC=1
85 ;--- Query the file
86 I 'RC D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
87 . S TMP="P"_$S(FLAGS["B":"B",1:"")
88 . D LIST^DIC(5,,FIELDS,TMP,NUMBER,.FROM,PART,"B",,,,"RORMSG")
89 . I $G(DIERR) S RC=$$DBS^RORERR("RORMSG",-9,,,5) Q
90 ;--- Success
91 S TMP=$G(^TMP("DILIST",$J,0)),BUF=+$P(TMP,U)
92 K ^TMP("DILIST",$J,0)
93 I $P(TMP,U,3) S I=0 D
94 . F S I=$O(FROM(I)) Q:I'>0 S TMP=FROM(I) S:TMP'="" BUF=BUF_U_TMP
95 S @RESULTS@(0)=BUF
96 Q
Note: See TracBrowser for help on using the repository browser.