forked from troyshelton/CCL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
APA_postgolive_audit
185 lines (148 loc) · 5.99 KB
/
APA_postgolive_audit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
select
Order_ID = o.order_id
,Item_ID = op.Item_ID
,Pt_Name=p.NAME_FULL_FORMATTED
,Pt_FIN=ea.alias
,OrderingPerson = prs.name_full_formatted
,Encounter_type= uar_get_code_display(rpaga.encntr_type_cd)
,Patient_Location = uar_get_code_display(rpaga.pat_locn_cd)
,Facility = uar_get_code_display(rpaga.facility_cd)
;,PRIMARY_MNEMONIC=O.HNA_ORDER_MNEMONIC
,PowerOrder = ocs.mnemonic
,PowerOrder_type = uar_get_code_display(ocs.mnemonic_type_cd)
,Order_Display = o.DEPT_MISC_LINE
,Powerplan_Order =o.PATHWAY_CATALOG_ID
,Updt_DT_TM =op.updt_dt_tm
,Auto_Assign_Flag=op.auto_assign_flag
/*indicates if pharmacy verification is needed:
*/
,APA_Tier_1_Logic_Product_Order_mapping = "Tier_1 -->"
,PowerOrder = ocs.mnemonic
,Product_description = id.unique_field
,APA_Tier_2_Logic_Product_Facility = "Tier_2 -->"
,APA_Tier_3_Logic_Route_Filtertype = "Tier_3 -->"
, rpaga.continuous_filter_ind
, rpaga.intermittent_filter_ind
, rpaga.med_filter_ind
,Order_Route = uar_get_code_display(rpaga.route_cd)
,Order_Form = uar_get_code_display(rpaga.form_cd)
,APA_Tier_4_Logic_Form_match = "Tier_4 -->"
,Order_Form = uar_get_code_display(rpaga.form_cd)
,APA_Tier_5_Logic_Route_Form_Compatibility = "Tier_5 -->"
,Order_Form = uar_get_code_display(rpaga.form_cd)
,Order_Route = uar_get_code_display(rpaga.route_cd)
,APA_Tier_6_Logic_QPD = "Tier_6 -->"
,NEED_RX_VERIFY = if(O.NEED_RX_VERIFY_IND = 0) "Does not Need Verification"
elseif (O.NEED_RX_VERIFY_IND = 1) "needs verification"
elseif (O.NEED_RX_VERIFY_IND = 2) "rejected or halted"
elseif (O.NEED_RX_VERIFY_IND > 2) "rejected or halted child order"
endif
; RAVA
/*flag representing current order catalog's auto verification settings for discern alerts.
for iv set, this is the flag on the catalog of the matching iv set.
*/
,OrderCatalog_AutoVerify_Setting_DiscernAlert =
if(rava.discern_auto_verify_flag = 0.00) "Not set"
elseif (rava.discern_auto_verify_flag = 1.00) "No auto verification performed"
elseif (rava.discern_auto_verify_flag = 2.00) "If alert exists, autoverification is not performed"
elseif (rava.discern_auto_verify_flag = 3.00) "Only auto verify if a reason was provided with the alert(s)"
elseif (rava.discern_auto_verify_flag = 4.00) "Auto verify regardless of alerts"
endif
/*
flag representing current order catalog's auto verification settings for interaction checking.
for iv set, this is the flag on the catalog of the matching iv set.
*/
,OrderCatalog_AutoVerify_InteractionChecking_Setting =
if(rava.ic_auto_verify_flag =0.00) "Not set"
elseif(rava.ic_auto_verify_flag = 1.00) "No auto verification performed"
elseif(rava.ic_auto_verify_flag = 2.00) "If alert exists, autoverification is not performed."
elseif(rava.ic_auto_verify_flag = 3.00) "Only autoverify if a reason was provided with the alert(s)"
elseif(rava.ic_auto_verify_flag = 4.00) "Auto verify regardless of alerts"
endif
;Rpaia
,Order_Free_text_Dose = rpaia.freetext_dose
,Order_Strength = rpaia.strength
,Order_Strength_unit = uar_get_code_display(rpaia.strength_unit_cd)
,Order_volume = rpaia.volume
,Order_volume_unit = uar_get_code_display(rpaia.volume_unit_cd)
; RPAA
/*
text description of a specific event that occurred during the auto product assignment process.
*/
, rpaa.status_message
,broken_RPAA_Status_Number =
if(rpaa.status_number = 0.00) "Found a match successfully. Matching item is recorded in set_item_id or item_id field"
elseif(rpaa.status_number = 1.00) "fail to match because of reasons recorded in status_number and status_string fields"
elseif(rpaa.status_number = 2.00) "Addiitonal information about a specific event with details recorded in status_number and status_string fields."
endif
/*
FLAG_VALUE DESCRIPTION DEFINITION
0.00 Audit Found a match successfully. Matching item is recorded in set_item_id or item_id field.
1.00 Info Fail to match because of reasons recorded in status_number and status_string fields
2.00 Debug Additional information about a specific event with details recorded in status_number and status_string fields.
*/
,broken_rpaa_report_level = rpaa.report_level_flag
from
order_product OP
,Item_Definition ID ; Description
,orders o
,order_catalog_synonym ocs
, RX_AUTO_VERIFY_AUDIT RAVA
, RX_PRODUCT_ASSIGN_GROUP_AUDIT RPAGA
, RX_PRODUCT_ASSIGN_ITEM_AUDIT RPAIA
, RX_PRODUCT_ASSIGN_AUDIT RPAA
,encntr_alias ea
,encounter e
,person p
,prsnl prs
,dummyt d
plan OP
where op.auto_assign_flag not in (0, 1)
and op.updt_dt_tm between cnvtdatetime("01-JAN-2018 0000") and cnvtdatetime("01-FEB-2018 2359")
join ID
where op.item_id= outerjoin(ID.ITEM_ID)
; and ID.MED_IDENTIFIER_TYPE_CD = value(uar_get_code_by("MEANING", 11000,"DESC"))
join o
where op.order_id = o.order_id
and o.orig_order_dt_tm between cnvtdatetime("01-JAN-2018 0000") and cnvtdatetime("01-FEB-2018 2359")
join ocs
where ocs.synonym_id = o.synonym_id
join RAVA
where rava.order_id = outerjoin(o.order_id)
join RPAGA
where rpaga.catalog_group_id = rava.catalog_group_id
join rpaia
Where rpaia.catalog_group_id = rpaga.catalog_group_id
join rpaa
where rpaa.catalog_group_id = rava.catalog_group_id
join ea
where o.encntr_id =ea.encntr_id
and EA.ENCNTR_ALIAS_TYPE_CD =1077
join e
where ea.encntr_id = e.encntr_id
and e.loc_facility_cd in(
;CODE_VALUE DISPLAY
21198290 ;location
,271998575 ;location
,271998583 ;location
,271998479 ;location
,276041517 ;location
,276497813 ;location
,344062579 ;location
,349503863 ;location
,499091795 ;location
,516280427 ;location
,416024841 ;location
,428514323 ;location
,275964153 ;location
,275964173 ;location
)
join p
where e.person_id = p.person_id
;and p.NAME_LAST_KEY != "PRODTEST" ; If you have a standard naming convention for Test Patients, you can exlude them from the report.
join prs
where o.ACTIVE_STATUS_PRSNL_ID = prs.person_id
;and prs.POSITION_CD not in (441, 2356532)
join d
with outerjoin = d,nullreport, time = 300
go