source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORAPI01.m@ 861

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1RORAPI01 ;HCIOFO/SG - CLINICAL REGISTRIES API ; 5/12/05 1:59pm
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 ;***** EXAMPLE
5 ;
6 N BUF,IPD,IRD,PATIEN,RC,REGIEN
7 W !," Patient Registries"
8 W !," ------- ----------"
9 ;--- Initialize the patient iterator
10 S RC=$$PATITER^RORAPI01(.IPD,"VA HEPC")
11 I RC<0 W "RC= ",RC,! Q
12 ;--- Browse through the registry patients
13 F S PATIEN=$$NEXTPAT^RORAPI01(.IPD) Q:PATIEN'>0 D
14 . W !,$J(PATIEN,10)," "
15 . ;--- Initialize the registry iterator
16 . S RC=$$REGITER^RORAPI01(.IRD,PATIEN)
17 . I RC<0 W "RC= ",RC Q
18 . ;--- Browse through the patient's registry records
19 . S BUF=""
20 . F S REGIEN=$$NEXTREG^RORAPI01(.IRD) Q:REGIEN'>0 D
21 . . S BUF=BUF_","_REGIEN
22 . W $P(BUF,",",2,999)
23 ;---
24 W !
25 Q
26 ;
27 ;***** RETURNS THE NEXT PATIENT IN THE REGISTRY
28 ;
29 ; .IDESC Reference to the iterator descriptor created
30 ; by PATITER^RORAPI01
31 ;
32 ; Return Values:
33 ; <0 Error code
34 ; "" No more patients in the registry
35 ; >0 Patient IEN^empty
36 ;
37NEXTPAT(IDESC) ;
38 N RC
39 F D Q:$G(RC)
40 . ;--- Get IEN of the next registry record
41 . S IDESC("IEN")=$O(^RORDATA(798,"AC",IDESC("REGIEN"),IDESC("IEN")))
42 . I IDESC("IEN")'>0 S RC="1^END" Q
43 . Q:'$$ACTIVE^RORDD(IDESC("IEN"))
44 . ;--- Load the patient IEN (DFN)
45 . S RC=$P($G(^RORDATA(798,IDESC("IEN"),0)),U)
46 Q $S(RC="1^END":"",1:RC)
47 ;
48 ;***** RETURNS THE NEXT REGISTRY FOR THE PATIENT
49 ;
50 ; .IDESC Reference to the iterator descriptor created
51 ; by REGITER^RORAPI01
52 ;
53 ; Return Values:
54 ; <0 Error code
55 ; "" No more registries for the patient
56 ; >0 Registry IEN^empty
57 ;
58NEXTREG(IDESC) ;
59 N RC
60 F D Q:$G(RC)
61 . ;--- Get IEN of the next registry record
62 . S IDESC("IEN")=$O(^RORDATA(798,"B",IDESC("PATIEN"),IDESC("IEN")))
63 . I IDESC("IEN")'>0 S RC="1^END" Q
64 . Q:'$$ACTIVE^RORDD(IDESC("IEN"))
65 . ;--- Load the registry IEN
66 . S RC=$P($G(^RORDATA(798,IDESC("IEN"),0)),U,2)
67 Q $S(RC="1^END":"",1:RC)
68 ;
69 ;***** CREATES AN ITERATOR OF PATIENTS IN THE REGISTRY
70 ;
71 ; .IDESC Reference to a local variable where an iterator
72 ; descriptor will be created
73 ; REGNAME Registry name
74 ; [MODE] Bit flags that define iteration mode (3 by default)
75 ; 1 Active patients
76 ; 2 Reserved
77 ;
78 ; Return Values:
79 ; <0 Error code
80 ; 0 Ok
81 ;
82PATITER(IDESC,REGNAME,MODE) ;
83 N REGIEN K IDESC
84 ;--- Get an IEN of the Registry Parameters
85 S REGIEN=$$REGIEN^RORUTL02(REGNAME)
86 Q:REGIEN<0 REGIEN
87 ;--- Setup the descriptor
88 S MODE=$S($G(MODE):MODE,1:3)
89 S IDESC("REGNAME")=REGNAME
90 S IDESC("REGIEN")=REGIEN
91 S IDESC("ACT")=MODE#2
92 S IDESC("ROOT")=$$ROOT^DILFD(798,"",1)
93 S IDESC("IEN")=0
94 Q 0
95 ;
96 ;***** CREATES AN ITERATOR OF THE PATIENT REGISTRIES
97 ;
98 ; .IDESC Reference to a local variable where an iterator
99 ; descriptor will be created
100 ; PATIEN Patient IEN
101 ; [MODE] Bit flags that define iteration mode (3 by default)
102 ; 1 Registries where the patient is active
103 ; 2 Reserved
104 ;
105 ; Return Values:
106 ; <0 Error code
107 ; 0 Ok
108 ;
109REGITER(IDESC,PATIEN,MODE) ;
110 K IDESC
111 ;--- Setup the descriptor
112 S MODE=$S($G(MODE):MODE,1:3)
113 S IDESC("PATIEN")=PATIEN
114 S IDESC("ACT")=MODE#2
115 S IDESC("ROOT")=$$ROOT^DILFD(798,"",1)
116 S IDESC("IEN")=0
117 Q 0
Note: See TracBrowser for help on using the repository browser.