source: WorldVistAEHR/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORDV07.m@ 824

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

initial load of WorldVistAEHR

File size: 8.3 KB
RevLine 
[613]1ORDV07 ;SLC/DAN/KER - OE/RR Report extracts ; 01/09/2003
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,120,159**;Dec 17,1997
3 ;
4 ; External References
5 ; DBIA 10112 $$SITE^VASITE
6 ; DBIA 10061 4^VADPT
7 ; DBIA 10061 OAD^VADPT
8 ; DBIA 10145 ALL^IBCNS1
9 ; DBIA 767 ^DGSL(38.1,
10 ; DBIA 1407 ^FHWHEA
11 ; DBIA 3818 ICDS^GMTSDGP
12 ; DBIA 3818 ICDP^GMTSDGP
13 ; DBIA 418 ^DGPT("B"
14 ; DBIA 794 ^DIC(36,
15 ; DBIA 951 ^IBE(355.1,
16 ;
17 ;Dietetics components
18DIETA(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;All diet
19 N ORTYPE S ORTYPE="DI" D DIET Q
20DIETN(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Nutritional Status
21 N ORTYPE S ORTYPE="NS" D DIET Q
22DIETS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Supplemental Feedings
23 N ORTYPE S ORTYPE="SF" D DIET Q
24DIETT(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Tube feedings
25 N ORTYPE S ORTYPE="TF" D DIET Q
26 ;
27DIET ;Main diet entry point
28 ;External calls to FHWHEA and SITE^VASITE
29 ;Data returned in ^TMP("ORDATA",$J) by type:
30 ; ALL=Facility^Start Date^End Date^Diet^Comment^Service(tray,dining room, etc)
31 ; Nutritional Status=Facility^Status Date^Status
32 ; Supplemental Feeding=Facility^Date Ordered^Date Canceled^10am feeding^2pm feeding^8pm feeding
33 ; Tubefeeding=Facility^Date Ordered^Date Canceled^Product^Strength^Quantity^Daily CCs^Daily KCal^Comment
34 ;
35 N GMTS1,GMTS2,GMTSNDM,ORSITE,SITE,ORDT
36 S GMTS1=OROMEGA-.24,GMTS2=ORALPHA,GMTSNDM=ORMAX
37 K ^TMP("ORDATA",$J)
38 D ^FHWHEA ;get all diet information. Returned in ^UTILITY($J)
39 Q:'$D(^UTILITY($J,ORTYPE)) ;no data to report for type selected
40 S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
41 S ORDT=0
42 F S ORDT=$O(^UTILITY($J,ORTYPE,ORDT)) Q:ORDT="" D
43 . S SITE=$S($L($G(^UTILITY($J,ORTYPE,ORDT,"facility"))):^("facility"),1:ORSITE)
44 . S ^TMP("ORDATA",$J,ORDT,"WP",1)="1^"_SITE ;Station ID
45 . S ^TMP("ORDATA",$J,ORDT,"WP",2)="2^"_$$DATE^ORDVU($P(^UTILITY($J,ORTYPE,ORDT,0),"^")) ;date
46 . S ^TMP("ORDATA",$J,ORDT,"WP",3)="3^"_$S(ORTYPE="NS":$P(^UTILITY($J,ORTYPE,ORDT,0),"^",2),1:$$DATE^ORDVU($P(^UTILITY($J,ORTYPE,ORDT,0),"^",2)))
47 . Q:ORTYPE="NS" ;no more data required for NS
48 . S ^TMP("ORDATA",$J,ORDT,"WP",4)="4^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",3)
49 . S ^TMP("ORDATA",$J,ORDT,"WP",5)="5^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",4)
50 . S ^TMP("ORDATA",$J,ORDT,"WP",6)="6^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",5)
51 . Q:ORTYPE'="TF"
52 . ;Get remaining data for tube feedings
53 . S ^TMP("ORDATA",$J,ORDT,"WP",7)="7^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",6)
54 . S ^TMP("ORDATA",$J,ORDT,"WP",8)="8^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",7)
55 . S ^TMP("ORDATA",$J,ORDT,"WP",9)="9^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",8)
56 K ^UTILITY($J)
57 S ROOT=$NA(^TMP("ORDATA",$J))
58 Q
59 ;
60DEM(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ; ADT Demographics
61 ; External calls to VASITE, VADPT, and ^DGSL(38.1
62 N VADM,VAPA,VAOA,ORSITE,SITE,I,ORDAT,ORETHN,ORRACE S (ORETHN,ORRACE)=""
63 K ^TMP("ORDATA",$J)
64 D 4^VADPT,OAD^VADPT
65 ; Quit if error in data gathering, otherwise get
66 ; demographic/address information as well as next
67 ; of kin addres
68 Q:VAERR
69 S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
70 S SITE=ORSITE
71 ; 1 Site
72 S ^TMP("ORDATA",$J,1,"WP",1)="1^"_SITE
73 ; 2 Patient Name
74 S ^TMP("ORDATA",$J,1,"WP",2)="2^"_VADM(1)
75 ; 3 SSN
76 S ^TMP("ORDATA",$J,1,"WP",3)="3^"_$P(VADM(2),"^")
77 ; 4 Sex
78 S ^TMP("ORDATA",$J,1,"WP",4)="4^"_$P(VADM(5),"^",2)
79 ; 5 Date of Birth
80 S ^TMP("ORDATA",$J,1,"WP",5)="5^"_$$DATE^ORDVU($P(VADM(3),"^"))
81 ; 6 Religion
82 S ^TMP("ORDATA",$J,1,"WP",6)="6^"_$P(VADM(9),"^",2)
83 ; 7 Marital Status
84 S ^TMP("ORDATA",$J,1,"WP",7)="7^"_$P(VADM(10),"^",2)
85 ; 8 Phone Number
86 S ^TMP("ORDATA",$J,1,"WP",8)="8^"_VAPA(8)
87 ; 9 Street Address (1-3), City, State, and ZIP
88 S ^TMP("ORDATA",$J,1,"WP",9,1)="9^"_VAPA(1) I $P(^(1),"^",2)="" K ^(1)
89 S ^TMP("ORDATA",$J,1,"WP",9,2)="9^"_VAPA(2) I $P(^(2),"^",2)="" K ^(2)
90 S ^TMP("ORDATA",$J,1,"WP",9,3)="9^"_VAPA(3) I $P(^(3),"^",2)="" K ^(3)
91 S ^TMP("ORDATA",$J,1,"WP",9,4)="9^"_VAPA(4)_$S($G(VAPA(4))'="":", ",1:"")_$P(VAPA(5),"^",2)_" "_VAPA(6)
92 ; 11 Ethnicity
93 S I=0 F S I=$O(VADM(11,I)) Q:+I=0 D
94 . S ORDAT=$P(VADM(11,I),"^",2) Q:'$L(ORDAT)
95 . S ORETHN=$G(ORETHN)_", "_ORDAT
96 . S ^TMP("ORDATA",$J,1,"WP",11,I)="11^"_ORDAT
97 ; 10 Race
98 S:$L(ORETHN) ^TMP("ORDATA",$J,1,"WP",10,1)="10^"
99 S I=0 F S I=$O(VADM(12,I)) Q:+I=0 D
100 . S ORDAT=$P($G(VADM(12,I)),"^",2) Q:'$L(ORDAT)
101 . S ORRACE=$G(ORRACE)_", "_ORDAT
102 . S ^TMP("ORDATA",$J,1,"WP",10,I)="10^"_ORDAT
103 S ORRACE=$P(ORRACE,", ",2,$L(ORRACE,", "))
104 I '$L($P($G(^TMP("ORDATA",$J,1,"WP",11,1)),"^",2)) D
105 . I '$L($P($G(^TMP("ORDATA",$J,1,"WP",10,1)),"^",2)) D
106 . . S ^TMP("ORDATA",$J,1,"WP",11,1)="11^"
107 . . S ^TMP("ORDATA",$J,1,"WP",10,1)="10^"_$P($G(VADM(8)),"^",2)
108 S ORETHN=$P(ORETHN,", ",2,$L(ORETHN,", "))
109 ; 12 Next of Kin
110 S ^TMP("ORDATA",$J,1,"WP",12)="12^"_VAOA(9)
111 ; 13 Next of Kin Relationship
112 S ^TMP("ORDATA",$J,1,"WP",13)="13^"_VAOA(10)
113 ; 14 NOK Street Address (1-3), City, State, and ZIP
114 S ^TMP("ORDATA",$J,1,"WP",14,1)="14^"_VAOA(1) I $P(^(1),"^",2)="" K ^(1)
115 S ^TMP("ORDATA",$J,1,"WP",14,2)="14^"_VAOA(2) I $P(^(2),"^",2)="" K ^(2)
116 S ^TMP("ORDATA",$J,1,"WP",14,3)="14^"_VAOA(3) I $P(^(3),"^",2)=""
117 S ^TMP("ORDATA",$J,1,"WP",14,4)="14^"_VAOA(4)_$S($G(VAOA(4))'="":", ",1:"")_$P(VAOA(5),"^",2)_" "_VAOA(6)
118 ; 15 Security Log
119 S ^TMP("ORDATA",$J,1,"WP",15)="15^"_$S($P($G(^DGSL(38.1,DFN,0)),"^",2):"YES",1:"NO")
120 S ROOT=$NA(^TMP("ORDATA",$J))
121 Q
122ICDSUR(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return ICD Surgery Information
123 ;External calls to VASITE, GMTSDGP
124 N ORSITE,SITE,T1,T2,I,J,GMS,PTF,ORDATE
125 K ^TMP("ORDATA",$J)
126 S T1=ORDEND,T2=ORDBEG,ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
127 F PTF=0:0 S PTF=$O(^DGPT("B",DFN,PTF)) Q:PTF="" D ICDS^GMTSDGP
128 S (I,ORDATE)=0
129 F S ORDATE=$O(GMS(ORDATE)) Q:ORDATE=""!(I'<ORMAX) S J=0 D
130 . F S J=$O(GMS(ORDATE,J)) Q:'J!(I'<ORMAX) S I=I+1 D ;Check for multiple procedures on same date
131 .. S SITE=$S($L($G(GMS(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
132 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,1)="1^"_SITE
133 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($P(GMS(ORDATE)," ",3)) ;Date of procedure
134 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,3)="3^"_$P($G(GMS(ORDATE,J)),"^") ;Surgery and code
135 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,4)="4^"_$P(GMS(ORDATE,J),"^",2) ;ICD code
136 S ROOT=$NA(^TMP("ORDATA",$J))
137 Q
138PRC(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Procedure Information
139 ;External calls to VASITE, GMTSDGP
140 N ORSITE,SITE,T1,T2,I,J,GMP,PTF,ORDATE
141 K ^TMP("ORDATA",$J)
142 S T1=ORDEND,T2=ORDBEG,PTF=0,ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
143 F S PTF=$O(^DGPT("B",DFN,PTF)) Q:PTF="" D ICDP^GMTSDGP
144 S (I,ORDATE)=0
145 F S ORDATE=$O(GMP(ORDATE)) Q:ORDATE=""!(I'<ORMAX) S J=0 D
146 . F S J=$O(GMP(ORDATE,J)) Q:'J!(I'<ORMAX) S I=I+1 D ;Check for multiple procedures on same date
147 .. S SITE=$S($L($G(GMP(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
148 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,1)="1^"_SITE
149 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($P(GMP(ORDATE)," ",2)) ;Date of procedure
150 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,3)="3^"_$P($G(GMP(ORDATE,J)),"^") ;Procedure and code
151 .. S ^TMP("ORDATA",$J,"WP",ORDATE,J,4)="4^"_$P(GMP(ORDATE,J),"^",2) ;ICD code
152 S ROOT=$NA(^TMP("ORDATA",$J))
153 Q
154INS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Insurance Information
155 ;External calls to VASITE and IBCNS1 and ^DIC(36, and ^IBE(355.1
156 N ORSITE,SITE,ORARRAY,I
157 K ^TMP("ORDATA",$J)
158 D ALL^IBCNS1(DFN,"ORARRAY")
159 Q:'$D(ORARRAY) ;quit if no insurance data returned
160 S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3),I=0
161 F S I=$O(ORARRAY(I)) Q:'I D
162 . S SITE=$S($L($G(ORARRAY(I,"facility"))):^("facility"),1:ORSITE)
163 . S ^TMP("ORDATA",$J,"WP",I,1)="1^"_SITE
164 . S ^TMP("ORDATA",$J,"WP",I,2)="2^"_$P($G(^DIC(36,+$P(ORARRAY(I,0),"^"),0)),"^") ;Insurance company
165 . S ^TMP("ORDATA",$J,"WP",I,3)="3^"_$P($G(^IBE(355.1,+$P(ORARRAY(I,355.3),"^",9),0)),"^") ;Policy type
166 . S ^TMP("ORDATA",$J,"WP",I,4)="4^"_$P(ORARRAY(I,355.3),"^",4) ;Group number
167 . S ^TMP("ORDATA",$J,"WP",I,5)="5^"_$S($P(ORARRAY(I,0),"^",6)="s":"SPOUSE",$P(ORARRAY(I,0),"^",6)="v":"SELF",1:"OTHER") ;Policy holder
168 . S ^TMP("ORDATA",$J,"WP",I,6)="6^"_$$DATE^ORDVU($P(ORARRAY(I,0),"^",8)) ;Effective date of policy
169 . S ^TMP("ORDATA",$J,"WP",I,7)="7^"_$$DATE^ORDVU($P(ORARRAY(I,0),"^",4)) ;Expiration date of policy
170 S ROOT=$NA(^TMP("ORDATA",$J))
171 Q
Note: See TracBrowser for help on using the repository browser.