source: WorldVistAEHR/trunk/r/CLINICAL_CASE_REGISTRIES-ROR/RORX005B.m@ 1177

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

initial load of WorldVistAEHR

File size: 2.3 KB
Line 
1RORX005B ;HCIOFO/BH,SG - INPATIENT UTILIZATION (SORT) ; 9/14/05 9:30am
2 ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
3 ;
4 Q
5 ;
6 ;***** CALCULATES MEDIAN LENGTHS OF STAY
7 ;
8 ; NODE Closed root of the category section
9 ; in the temporary global
10 ;
11 ; FSUM Update the summary data (0/1)
12 ;
13MLOS(NODE) ;
14 N BSID,TMP,XREFNODE
15 ;--- Median length of the whole stays
16 S XREFNODE=$NA(@NODE@("IPMLOS",0))
17 S TMP=$$XREFMDNV^RORXU004(XREFNODE,+$G(@NODE@("IPS")))
18 S (@NODE@("IPMLOS"),@NODE@("IPMLOS",0))=TMP
19 ;--- Median lengths of the bed section stays
20 S BSID=""
21 F S BSID=$O(@NODE@("IPMLOS",BSID)) Q:BSID="" D:BSID
22 . S XREFNODE=$NA(@NODE@("IPMLOS",BSID))
23 . S TMP=+$G(@NODE@("IPB",BSID,"S"))
24 . S @NODE@("IPMLOS",BSID)=$$XREFMDNV^RORXU004(XREFNODE,TMP)
25 Q
26 ;
27 ;***** SORTS THE RESULTS AND COMPILES THE TOTALS
28 ;
29 ; Return Values:
30 ; <0 Error code
31 ; 0 Ok
32 ;
33SORT() ;
34 N BSID,FILE,IENS,NAME,NODE,RC,RORMSG,TMP
35 S NODE=$NA(^TMP("RORX005",$J)) Q:$D(@NODE)<10 0
36 ;--- Bed sections
37 S RC=$$LOOP^RORTSK01(0) Q:RC<0 RC
38 S BSID=""
39 F S BSID=$O(@NODE@("IPB",BSID)) Q:'BSID D
40 . D:BSID>0
41 . . S IENS=(+BSID)_",",FILE=+$P(BSID,";",2)
42 . . S NAME=$$GET1^DIQ(FILE,IENS,.01,,,"RORMSG")
43 . . D:$G(DIERR) DBS^RORERR("RORMSG",-9,,,FILE,IENS)
44 . . S:NAME?." " NAME="Unknown ("_BSID_")"
45 . . S @NODE@("IPB","B",NAME,BSID)=""
46 ;--- Median length of stay
47 S RC=$$LOOP^RORTSK01(0.5) Q:RC<0 RC
48 D MLOS(NODE)
49 ;---
50 Q 0
51 ;
52 ;***** CALCULATES THE INTERMEDIATE TOTALS
53 ;
54 ; PATIEN Patient IEN (DFN)
55 ;
56 ; Return Values:
57 ; <0 Error code
58 ; 0 Ok
59 ;
60TOTALS(PATIEN) ;
61 N NODE,TMP
62 S NODE=$NA(^TMP("RORX005",$J))
63 ;
64 ;=== Inpatient data
65 D:$D(@NODE@("IP",PATIEN))>1
66 . N DAYS,STAYS,VISITS
67 . S @NODE@("IP",PATIEN)=RORLAST4
68 . S @NODE@("IP")=$G(@NODE@("IP"))+1
69 . S STAYS=+$G(@NODE@("IP",PATIEN,"S"))
70 . S DAYS=+$G(@NODE@("IP",PATIEN,"D"))
71 . S VISITS=+$G(@NODE@("IP",PATIEN,"V"))
72 . ;--- Number of stays
73 . D:(STAYS>0)!(VISITS>0)
74 . . S @NODE@("IPS")=$G(@NODE@("IPS"))+STAYS
75 . . S @NODE@("IPS",STAYS)=$G(@NODE@("IPS",STAYS))+1
76 . . S @NODE@("IPS",STAYS,RORPNAME,PATIEN)=""
77 . ;--- Number of days
78 . D:(DAYS>0)!(VISITS>0)
79 . . S @NODE@("IPD")=$G(@NODE@("IPD"))+DAYS
80 . . S @NODE@("IPD",DAYS)=$G(@NODE@("IPD",DAYS))+1
81 . . S @NODE@("IPD",DAYS,RORPNAME,PATIEN)=""
82 . ;--- Number of short stays (visits)
83 . D:VISITS>0
84 . . S @NODE@("IPV")=$G(@NODE@("IPV"))+VISITS
85 Q 0
Note: See TracBrowser for help on using the repository browser.