source: WorldVistAEHR/trunk/r/PCE_PATIENT_CARE_ENCOUNTER-AUTN-EFDP-PX-VSIT--PXRM/PXRRLCHP.m@ 1430

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

initial load of WorldVistAEHR

File size: 3.4 KB
Line 
1PXRRLCHP ;ISL/PKR - encounter by hospital location print. ;5/27/97
2 ;;1.0;PCE PATIENT CARE ENCOUNTER;**3,10,12,18,72**;Aug 12, 1996
3 ;
4 N BMARG,C2S,C3S,C3E,C3HS,CMAX,HEAD,INDENT,MID,PAGE
5 N CLASSNAM,DATE,DONE,IC,GTOTAL,HLOC,HLOCMAX
6 N IC,FACILITY,FACPNAME,FTOTAL
7 N LOCLIST,LOCNAME,NLOCLIST,PNAME,SC,VIEN
8 N TEMP
9 ;
10 ;Allow the task to be cleaned up upon successful completion.
11 S ZTREQ="@"
12 ;
13 U IO
14 ;
15 ;Setup the formatting parameters.
16 S HLOCMAX=^XTMP(PXRRXTMP,"HLOCMAX")
17 S INDENT=3
18 S C2S=INDENT+HLOCMAX+1
19 S C3HS=INDENT+38
20 ;We assume that the counts will never be longer than six digits.
21 S MID=C3HS+6
22 S BMARG=2
23 ;
24 S DONE=0
25 S GTOTAL=0
26 ;
27 S PAGE=1
28 D HDR^PXRRGPRT(PAGE)
29 W !!,"Criteria for Hospital Location Encounter Count Report"
30 D OLRCRIT^PXRRGPRT(3)
31 ;
32SET ;Set up print fields
33 S FACILITY=0
34FAC S FACILITY=$O(^XTMP(PXRRXTMP,FACILITY))
35 I +FACILITY=0&(FACILITY'="*") G END
36 ;Mark the facility as being found.
37 F IC=1:1:NFAC I $P(PXRRFAC(IC),U,1)=FACILITY D Q
38 . S $P(PXRRFAC(IC),U,4)="M"
39 K LOCLIST
40 K ^TMP(PXRRXTMP,$J,"PXRRLOC")
41 S HEAD=1
42 S FTOTAL=0
43 S FACPNAME=$P(PXRRFACN(FACILITY),U,1)_" "_$P(PXRRFACN(FACILITY),U,2)
44 ;
45 S PNAME=""
46PRV S PNAME=$O(^XTMP(PXRRXTMP,FACILITY,PNAME))
47 I PNAME="" G TOTAL
48 ;
49 ;Check for a user request to stop the task.
50 I $$S^%ZTLOAD S ZTSTOP=1 D EXIT^PXRRGUT
51 ;
52 S CLASSNAM=""
53CLASS ;
54 S CLASSNAM=$O(^XTMP(PXRRXTMP,FACILITY,PNAME,CLASSNAM))
55 I CLASSNAM="" G PRV
56 ;
57 S DATE=""
58DATE S DATE=$O(^XTMP(PXRRXTMP,FACILITY,PNAME,CLASSNAM,DATE))
59 I DATE="" G CLASS
60 ;
61 S HLOC=""
62HLO S HLOC=$O(^XTMP(PXRRXTMP,FACILITY,PNAME,CLASSNAM,DATE,HLOC))
63 I HLOC="" G DATE
64 ;
65 S VIEN=""
66 F S VIEN=$O(^XTMP(PXRRXTMP,FACILITY,PNAME,CLASSNAM,DATE,HLOC,VIEN)) Q:VIEN="" D
67 . S ^TMP(PXRRXTMP,$J,"PXRRLOC",HLOC,VIEN)=""
68 ;
69 G HLO
70 ;
71TOTAL ;Total up the encounters.
72 S NLOCLIST=0
73 S CMAX=0
74 S HLOC=""
75NLOC S HLOC=$O(^TMP(PXRRXTMP,$J,"PXRRLOC",HLOC))
76 I HLOC="" G OUTPUT
77 S TEMP=$$LOCCNT^PXRRLCHP(HLOC)
78 S CMAX=$$MAX^XLFMTH(CMAX,TEMP)
79 S LOCLIST(HLOC)=TEMP
80 S NLOCLIST=NLOCLIST+1
81 G NLOC
82 ;
83OUTPUT ;Print the data.
84 S HEAD=1
85 S C3E=MID+($L(CMAX)/2)
86 S HLOC=""
87 S NLOCLIST=0
88NEXTP S HLOC=$O(LOCLIST(HLOC))
89 I HLOC="" S GTOTAL=GTOTAL+FTOTAL G FINAL
90 S TEMP=$$LOCCNT^PXRRLCHP(HLOC)
91 S NLOCLIST=NLOCLIST+1
92 S FTOTAL=FTOTAL+TEMP
93 S LOCNAME=$P(HLOC,U,1)
94 S SC=""
95 I $P(HLOC,U,3)'="" S SC="("_$P(HLOC,U,3)_")"
96 D HEAD
97 I DONE G EXIT
98 S C3S=C3E-$L(TEMP)
99 W !,?INDENT,LOCNAME,?C2S,SC,?C3S,TEMP
100 G NEXTP
101 ;
102FINAL ;Print facility total.
103 I $Y>(IOSL-BMARG-3) D PAGE^PXRRGPRT
104 I DONE G EXIT
105 D PTOTAL^PXRRGPRT("Total facility encounters ",FTOTAL,C3E,1)
106 G FAC
107END ;
108 I $Y>(IOSL-BMARG-3) D PAGE^PXRRGPRT
109 I DONE G EXIT
110 I GTOTAL>0 D PTOTAL^PXRRGPRT("Total encounters ",GTOTAL,C3E,0)
111 I $Y>(IOSL-BMARG-3) D PAGE^PXRRGPRT
112 I DONE G EXIT
113 D FACNE^PXRRGPRT(INDENT)
114EXIT ;
115 D EXIT^PXRRGUT
116 D EOR^PXRRGUT
117 Q
118 ;
119 ;=======================================================================
120HEAD ;If necesary, write the header.
121 I HEAD D
122 . I $Y>(IOSL-BMARG-6) D PAGE^PXRRGPRT
123 . I DONE Q
124 . W !!,"Facility: ",FACPNAME
125 . W !!,?INDENT,"Hospital Location (Stop Code)",?C3HS,"Encounters"
126 . W !,?INDENT,"-----------------------------------",?C3HS,"----------"
127 . S HEAD=0
128 Q
129 ;
130 ;=======================================================================
131LOCCNT(HLOC) ;Return the number of encounters at this location.
132 ;
133 N TOTAL,VIEN
134 S TOTAL=0
135 S VIEN=""
136 F S VIEN=$O(^TMP(PXRRXTMP,$J,"PXRRLOC",HLOC,VIEN)) Q:VIEN="" D
137 . I VIEN>0 S TOTAL=TOTAL+1
138 Q TOTAL
139 ;
Note: See TracBrowser for help on using the repository browser.