source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORLPSRA.m@ 949

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

initial load of WorldVistAEHR

File size: 8.8 KB
Line 
1ORLPSRA ;SLC/RAF - Continuation of ORLPSR ; 3/31/08 6:24am
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**243**;Dec 17, 1997;Build 242
3 ;
4LOOP ;called from ORLPSR
5 ;goes thru the "ALPS" xref in 100 for order dates - called from ORLPSR
6 S RPDT="""Report Date: "",$$FMTE^XLFDT($$NOW^XLFDT),"" Sort Range From: "",SDT,"" To: "",EDT",STOP=0
7 S PAT="" F S PAT=$O(^OR(100,"ALPS",PAT)) Q:'PAT!STOP D
8 .Q:$P(^DPT(+PAT,0),U,21) ;Quit if test patient
9 .S DATE=0 F S DATE=$O(^OR(100,"ALPS",PAT,DATE)) Q:'DATE!STOP I DATE>SDATE,DATE<EDATE D
10 ..S IEN=0 F S IEN=$O(^OR(100,"ALPS",PAT,DATE,IEN)) Q:'IEN!STOP D
11 ...S SUB=0 F S SUB=$O(^OR(100,"ALPS",PAT,DATE,IEN,SUB)) Q:'SUB!STOP D
12 ....I $D(^OR(100,IEN,8,SUB,0)) D
13 .....;W !,DATE
14 .....;I TYPE=1 Q:+$P(^(0),U,15)=11
15 .....;I TYPE=3 Q:+$P(^(0),U,15)'=11
16 .....N LTYPE S LTYPE=$G(^OR(100,"ALPS",PAT,DATE,IEN,SUB))
17 .....I LTYPE="DELAYED ORDER" S LTYPE="DO"
18 .....N LDATE S LDATE=""
19 .....S (LOC,DIV)="**DELAYED ORDER/NOT ENTERED" ;Reset values as delayed orders may not have these values yet
20 .....I $D(^VA(200,+$P(^OR(100,IEN,8,SUB,0),U,3),0)) S PROV=$$USER^ORLPSR(+$P(^OR(100,IEN,8,SUB,0),U,3))
21 .....I $D(^VA(200,+$P(^OR(100,IEN,8,SUB,0),U,3),5)),$L($P(^(5),U)) S SER=$$SER^ORLPSR(+$P(^VA(200,+$P(^OR(100,IEN,8,SUB,0),U,3),5),U))
22 .....E S SER="MISSING from file 200"
23 .....I $D(^VA(200,+$P(^OR(100,IEN,8,SUB,0),U,13))) S WHO=$$USER^ORLPSR(+$P(^OR(100,IEN,8,SUB,0),U,13))
24 .....I $G(^OR(100,IEN,6)) I $P(^(6),U)=9&($P(^(6),U,5)="AUTO DC") S WHO=$$USER^ORLPSR(+$P(^OR(100,IEN,8,1,0),U,13)) ;If DCd nature is auto and text is auto dc set entered by to original entry person
25 .....S DFN=+$P(^OR(100,IEN,0),U,2) D DEM^VADPT S SSN=VA("BID"),PNM=$E(VADM(1),1,24)
26 .....I $D(^OR(100,IEN,3)),$P(^(3),U,3) S STATUS=$$STAT^ORLPSR(+$P(^(3),U,3))
27 .....I $D(^OR(100,IEN,0)),$P(^(0),U,10) S LOC=$$LOC^ORLPSR(+$P(^(0),U,10))
28 .....I $D(^OR(100,IEN,0)),$P(^(0),U,10) S DIV=$$DIV^ORLPSR(+$P(^(0),U,10))
29 .....I $D(^OR(100,IEN,8,SUB,0)),$P(^(0),U) S WHEN=$$FMTE^XLFDT($P($P(^(0),U),"."))
30 .....I $D(^OR(100,IEN,10)),$P(^(10),U) S LDATE=$$FMTE^XLFDT($P($P(^(10),U),"."))
31 .....I $L(LTYPE) S STATUS=STATUS_"("_LTYPE_")"
32 .....I SORT=1 S ^TMP("ORUNS",$J,SER,PROV,IEN)=SER_U_PROV_U_WHO_U_PNM_U_SSN_U_STATUS_U_IEN_U_WHEN_U_LDATE
33 .....I SORT=2 S ^TMP("ORUNS",$J,PROV,PNM,IEN)=PROV_U_WHO_U_PNM_U_SSN_U_STATUS_U_IEN_U_WHEN_U_LDATE
34 .....I SORT=3 S ^TMP("ORUNS",$J,PNM,PROV,IEN)=PNM_U_SSN_U_PROV_U_WHO_U_STATUS_U_IEN_U_WHEN_U_LDATE
35 .....I SORT=4 S ^TMP("ORUNS",$J,LOC,PROV,IEN)=LOC_U_PROV_U_WHO_U_PNM_U_SSN_U_STATUS_U_IEN_U_WHEN_U_LDATE
36 .....I SORT=5 S ^TMP("ORUNS",$J,WHO,PNM,IEN)=WHO_U_PROV_U_PNM_U_SSN_U_STATUS_U_IEN_U_WHEN_U_LDATE
37 .....I SORT=6 S ^TMP("ORUNS",$J,DIV,LOC,PROV,IEN)=DIV_U_LOC_U_PROV_U_WHO_U_PNM_U_SSN_U_STATUS_U_IEN_U_WHEN_U_LDATE
38PROV ;loops thru the TMP global for output sort by provider
39 I SORT=2&('$D(LONER)) D
40 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders by PROVIDER"""
41 .I TYPE=2 S HDR="!!?40,""List of LAPSED orders by PROVIDER"""
42 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders by PROVIDER"""
43 .S HDR1="!!,""PROVIDER"",?25,""ENTERED BY"",?50,""PATIENT"",?75,""SSN"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
44 .S PAGE=0 D HDR^ORLPSR
45 .I '$D(^TMP("ORUNS",$J)) W !,"No lapsed orders found" Q
46 .S PROV="" F S PROV=$O(^TMP("ORUNS",$J,PROV)) Q:PROV=""!STOP D
47 ..S PNM="" F S PNM=$O(^TMP("ORUNS",$J,PROV,PNM)) S CNT=0 Q:PNM=""!STOP D
48 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,PROV,PNM,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
49 ....I 'SUMONLY W $P(^(IEN),U),?25,$P(^(IEN),U,2),?50,$P(^(IEN),U,3),?75,$P(^(IEN),U,4),?81,$P(^(IEN),U,5),?91,$P(^(IEN),U,6),?104,$P(^(IEN),U,7),?118,$P(^(IEN),U,8),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
50 ....S ^TMP("ORSTATS",$J,PROV,PNM)=CNT
51SPROV ;sorts for a single provider
52 I SORT=2&($D(LONER)) S LONER="",PAGE=0 F S LONER=$O(LONER(LONER)) Q:LONER=""!STOP D
53 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders for "",LONER"
54 .I TYPE=2 S HDR="!!?30,""List of LAPSED orders for "",LONER"
55 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders for "",LONER"
56 .S HDR1="!!,""PROVIDER"",?25,""ENTERED BY"",?50,""PATIENT"",?75,""SSN"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
57 .D HDR^ORLPSR
58 .S PROV=LONER I $D(^TMP("ORUNS",$J,PROV)) D
59 ..S PNM="" F S PNM=$O(^TMP("ORUNS",$J,PROV,PNM)) S CNT=0 Q:PNM=""!STOP D
60 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,PROV,PNM,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
61 ....I 'SUMONLY W $P(^(IEN),U),?25,$P(^(IEN),U,2),?50,$P(^(IEN),U,3),?75,$P(^(IEN),U,4),?81,$P(^(IEN),U,5),?91,$P(^(IEN),U,6),?104,$P(^(IEN),U,7),?118,$P(^(IEN),U,8),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
62 ....S ^TMP("ORSTATS",$J,PROV,PNM)=CNT
63 .I '$D(^TMP("ORUNS",$J,PROV)) W !!,"No lapsed orders found for "_LONER
64PAT ;loops thru the TMP global for output sort by patient
65 I SORT=3&('$D(LONER)) D
66 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders by PATIENT"""
67 .I TYPE=2 S HDR="!!?40,""List of LAPSED orders by PATIENT"""
68 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders by PATIENT"""
69 .S HDR1="!!,""PATIENT"",?25,""SSN"",?30,""PROVIDER"",?55,""ENTERED BY"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
70 .S PAGE=0 D HDR^ORLPSR
71 .I '$D(^TMP("ORUNS",$J)) W !,"No lapsed orders found" Q
72 .S PNM="" F S PNM=$O(^TMP("ORUNS",$J,PNM)) Q:PNM=""!STOP D
73 ..S PROV="" F S PROV=$O(^TMP("ORUNS",$J,PNM,PROV)) S CNT=0 Q:PROV=""!STOP D
74 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,PNM,PROV,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
75 ....I 'SUMONLY W $P(^(IEN),U),?25,$P(^(IEN),U,2),?30,$P(^(IEN),U,3),?55,$P(^(IEN),U,4),?81,$P(^(IEN),U,5),?91,$P(^(IEN),U,6),?104,$P(^(IEN),U,7),?118,$P(^(IEN),U,8),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
76 ....S ^TMP("ORSTATS",$J,PNM,PROV)=CNT
77 ....;I $E(IOST)="E",$Y>(IOSL-105) W @IOF,@HDR
78SPAT ;sorts for a single patient
79 I SORT=3&($D(LONER)) S LONER="",PAGE=0 F S LONER=$O(LONER(LONER)) Q:LONER=""!STOP D
80 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders for "",LONER"
81 .I TYPE=2 S HDR="!!?30,""List of LAPSED orders for "",LONER"
82 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders for "",LONER"
83 .S HDR1="!!,""PATIENT"",?25,""SSN"",?30,""PROVIDER"",?55,""ENTERED BY"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
84 .D HDR^ORLPSR
85 .S PNM=LONER I $D(^TMP("ORUNS",$J,PNM)) D
86 ..S PROV="" F S PROV=$O(^TMP("ORUNS",$J,PNM,PROV)) S CNT=0 Q:PROV=""!STOP D
87 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,PNM,PROV,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
88 ....I 'SUMONLY W $P(^(IEN),U),?25,$P(^(IEN),U,2),?30,$P(^(IEN),U,3),?55,$P(^(IEN),U,4),?81,$P(^(IEN),U,5),?91,$P(^(IEN),U,6),?104,$P(^(IEN),U,7),?118,$P(^(IEN),U,8),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
89 ....S ^TMP("ORSTATS",$J,PNM,PROV)=CNT
90 .I '$D(^TMP("ORUNS",$J,PNM)) W !!,"No lapsed orders found for "_LONER
91WARD ;loops thru the TMP global for output sort by location
92 I SORT=4&('$D(LONER)) D
93 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders by LOCATION"""
94 .I TYPE=2 S HDR="!!?30,""List of LAPSED orders by LOCATION"""
95 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders by LOCATION"""
96 .S HDR1="!!,""PROVIDER"",?25,""ENTERED BY"",?50,""PATIENT"",?75,""SSN"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
97 .S PAGE=0 D HDR^ORLPSR
98 .I '$D(^TMP("ORUNS",$J)) W !,"No lapsed orders found" Q
99 .S LOC="" F S LOC=$O(^TMP("ORUNS",$J,LOC)) Q:LOC=""!STOP W:'SUMONLY "Location: ",LOC,! D
100 ..S PROV="" F S PROV=$O(^TMP("ORUNS",$J,LOC,PROV)) S CNT=0 Q:PROV=""!STOP D
101 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,LOC,PROV,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
102 ....I 'SUMONLY W $P(^TMP("ORUNS",$J,LOC,PROV,IEN),U,2),?25,$P(^(IEN),U,3),?50,$P(^(IEN),U,4),?75,$P(^(IEN),U,5),?81,$P(^(IEN),U,6),?91,$P(^(IEN),U,7),?104,$P(^(IEN),U,8),?118,$P(^(IEN),U,9),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
103 ....S ^TMP("ORSTATS",$J,LOC,PROV)=CNT
104 ..W !
105 ;
106SWARD ;sorts for a single location
107 I SORT=4&($D(LONER)) S LONER="",PAGE=0 F S LONER=$O(LONER(LONER)) Q:LONER=""!STOP D
108 .I TYPE=1 S HDR="!!?30,""List of RELEASED but UNSIGNED orders for "",LONER"
109 .I TYPE=2 S HDR="!!?30,""List of LAPSED orders for "",LONER"
110 .I TYPE=3 S HDR="!!?30,""List of UNSIGNED/UNRELEASED orders for "",LONER"
111 .S HDR1="!!,""PROVIDER"",?25,""ENTERED BY"",?50,""PATIENT"",?75,""SSN"",?81,""STATUS"",?91,""ORDER #"",?104,""ORDER DATE"",?118,""LAPSE DATE"""
112 .D HDR^ORLPSR
113 .S LOC=LONER I $D(^TMP("ORUNS",$J,LOC)) D
114 ..S PROV="" F S PROV=$O(^TMP("ORUNS",$J,LOC,PROV)) S CNT=0 Q:PROV=""!STOP D
115 ...S IEN=0 F S IEN=$O(^TMP("ORUNS",$J,LOC,PROV,IEN)) S CNT=CNT+1 Q:'IEN!STOP D
116 ....I 'SUMONLY W $P(^TMP("ORUNS",$J,LOC,PROV,IEN),U,2),?25,$P(^(IEN),U,3),?50,$P(^(IEN),U,4),?75,$P(^(IEN),U,5),?81,$P(^(IEN),U,6),?91,$P(^(IEN),U,7),?104,$P(^(IEN),U,8),?118,$P(^(IEN),U,9),! D:$Y>(IOSL-4) HDR^ORLPSR Q:STOP
117 ....S ^TMP("ORSTATS",$J,LOC,PROV)=CNT
118 .I '$D(^TMP("ORUNS",$J,LOC)) W !!,"No lapsed orders found for "_LONER
119 I SORT=1 D SERV^ORLPSRB
120 I SORT=5 D WHO^ORLPSRB
121 I SORT=6 D DIV^ORLPSRB
122 I 'STOP D STATS^ORLPSR
123EXIT K ^TMP("ORUNS",$J),^TMP("ORSTATS",$J)
124 D ^%ZISC
125 Q
Note: See TracBrowser for help on using the repository browser.