source: FOIAVistA/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORX016B.m@ 1203

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

initial load of FOIAVistA 6/30/08 version

File size: 2.3 KB
Line 
1RORX016B ;HCIOFO/BH,SG - OUTPATIENT UTILIZATION (SORT) ; 9/14/05 10:08am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** SORTS THE RESULTS AND COMPILES THE TOTALS
7 ;
8 ; Return Values:
9 ; <0 Error code
10 ; 0 Ok
11 ;
12SORT() ;
13 N I,NDSC,NAME,NODE,NSC,NV,RC,RORBUF,RORMSG,STOP,TMP
14 S NODE=$NA(^TMP("RORX016",$J)) Q:$D(@NODE)<10 0
15 ;--- Outpatient stop codes
16 S RC=$$LOOP^RORTSK01(0) Q:RC<0 RC
17 S STOP="",(NDSC,NSC)=0
18 F S STOP=$O(@NODE@("OPS",STOP)) Q:STOP="" D
19 . S NSC=NSC+$G(@NODE@("OPS",STOP,"S")),NDSC=NDSC+1
20 . D FIND^DIC(40.7,,"@;.01","UX",STOP,1,"C",,,"RORBUF","RORMSG")
21 . D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,40.7)
22 . S NAME=$G(RORBUF("DILIST","ID",1,.01)) K RORBUF
23 . S @NODE@("OPS",STOP)=$S(NAME'="":NAME,1:"Unknown")
24 S @NODE@("OPS")=NSC_U_NDSC
25 ;---
26 Q 0
27 ;
28 ;***** CALCULATES THE INTERMEDIATE TOTALS
29 ;
30 ; PATIEN Patient IEN (DFN)
31 ; CATSUB Category subscript in the temporary global
32 ;
33 ; Return Values:
34 ; <0 Error code
35 ; 0 Ok
36 ;
37TOTALS(PATIEN) ;
38 N NODE,TMP
39 S NODE=$NA(^TMP("RORX016",$J))
40 ;
41 ;=== Outpatient data
42 D:$D(@NODE@("OP",PATIEN))>1
43 . N DATE,NDSC,NPSC,NSC,NV,NVSC,SCLST,STOP
44 . S @NODE@("OP")=$G(@NODE@("OP"))+1
45 . ;---
46 . S (DATE,NPSC,NV)=0
47 . F S DATE=$O(@NODE@("OP",PATIEN,DATE)) Q:DATE'>0 D
48 . . S NV=NV+1 ; Number of visits
49 . . S NVSC=@NODE@("OP",PATIEN,DATE) ; Number of visist's stops
50 . . ;--- Count the patient's stops
51 . . S STOP=""
52 . . F S STOP=$O(@NODE@("OP",PATIEN,DATE,STOP)) Q:STOP="" D
53 . . . S NSC=@NODE@("OP",PATIEN,DATE,STOP) ; Number of stops
54 . . . S @NODE@("OPS",STOP,"S")=$G(@NODE@("OPS",STOP,"S"))+NSC
55 . . . S @NODE@("OPS",STOP,"V")=$G(@NODE@("OPS",STOP,"V"))+(NSC/NVSC)
56 . . . S SCLST(STOP)=""
57 . . S NPSC=NPSC+NVSC ; Total number of stops
58 . K @NODE@("OP",PATIEN)
59 . ;--- Count the different stops and patients
60 . S STOP="",NDSC=0
61 . F S STOP=$O(SCLST(STOP)) Q:STOP="" D
62 . . S @NODE@("OPS",STOP,"P")=$G(@NODE@("OPS",STOP,"P"))+1
63 . . S NDSC=NDSC+1 ; Number of diff. stops
64 . ;--- Count the visits
65 . S:NV>0 @NODE@("OPV")=$G(@NODE@("OPV"))+NV
66 . ;--- Count the stop codes
67 . D:NPSC>0
68 . . S @NODE@("OP",PATIEN)=NPSC_U_NDSC_U_$G(VA("BID"))_U_NV
69 . . S @NODE@("OPS1",NPSC)=$G(@NODE@("OPS1",NPSC))+1
70 . . S @NODE@("OPS1",NPSC,RORPNAME,PATIEN)=""
71 Q 0
Note: See TracBrowser for help on using the repository browser.