-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LAB_RESULT_CM transform #32
Changes from all commits
e94a6df
1976883
8051c44
2d3e8ba
2192479
ab172f1
aa9dd53
baa708f
227e2d1
d4441dd
3828e24
6d91bbb
93b9272
129bf9b
146792a
0d00d3e
5b29763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -415,66 +415,6 @@ begin | |
end; | ||
/ | ||
|
||
BEGIN | ||
PMN_DROPSQL('DROP TABLE PMN_LabNormal'); | ||
END; | ||
/ | ||
CREATE TABLE PMN_LabNormal ( | ||
LAB_NAME varchar(150) NULL, | ||
NORM_RANGE_LOW varchar(10) NULL, | ||
NORM_MODIFIER_LOW varchar(2) NULL, | ||
NORM_RANGE_HIGH varchar(10) NULL, | ||
NORM_MODIFIER_HIGH varchar(2) NULL | ||
) | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:LDL', '0', 'GE', '165', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:A1C', '', 'NI', '', 'NI') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:CK', '50', 'GE', '236', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:CK_MB', '', 'NI', '', 'NI') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:CK_MBI', '', 'NI', '', 'NI') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:CREATININE', '0', 'GE', '1.6', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:CREATININE', '0', 'GE', '1.6', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:HGB', '12', 'GE', '17.5', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:INR', '0.8', 'GE', '1.3', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:TROP_I', '0', 'GE', '0.49', 'LE') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:TROP_T_QL', '', 'NI', '', 'NI') | ||
/ | ||
|
||
INSERT INTO PMN_LabNormal(LAB_NAME, NORM_RANGE_LOW, NORM_MODIFIER_LOW, NORM_RANGE_HIGH, NORM_MODIFIER_HIGH) | ||
VALUES('LAB_NAME:TROP_T_QN', '0', 'GE', '0.09', 'LE') | ||
/ | ||
|
||
BEGIN | ||
PMN_DROPSQL('DROP TABLE death'); | ||
|
@@ -1335,7 +1275,8 @@ m.start_date SPECIMEN_DATE, | |
to_char(m.start_date,'HH:MI') SPECIMEN_TIME, | ||
m.end_date RESULT_DATE, | ||
to_char(m.end_date,'HH:MI') RESULT_TIME, | ||
CASE WHEN m.ValType_Cd='T' THEN NVL(nullif(m.TVal_Char,''),'NI') ELSE 'NI' END RESULT_QUAL, -- TODO: Should be a standardized value | ||
--CASE WHEN m.ValType_Cd='T' THEN NVL(nullif(m.TVal_Char,''),'NI') ELSE 'NI' END RESULT_QUAL, -- TODO: Should be a standardized value | ||
'NI' RESULT_QUAL, -- Temporary fix for KUMC | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mprittie: Do you have a design in mind that will allow you to revert this temporary fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @njgraham: The TODO on the original line indicated that they knew that this was an issue. After talking with Dan, he suggested this temporary fix and logging a bug with the SCHILS folks (which I did ARCH-commons#19). Jeff responded on Thursday, but it sounds like they haven't found the right solution yet. |
||
CASE WHEN m.ValType_Cd='N' THEN m.NVAL_NUM ELSE null END RESULT_NUM, | ||
CASE WHEN m.ValType_Cd='N' THEN (CASE NVL(nullif(m.TVal_Char,''),'NI') WHEN 'E' THEN 'EQ' WHEN 'NE' THEN 'OT' WHEN 'L' THEN 'LT' WHEN 'LE' THEN 'LE' WHEN 'G' THEN 'GT' WHEN 'GE' THEN 'GE' ELSE 'NI' END) ELSE 'TX' END RESULT_MODIFIER, | ||
NVL(m.Units_CD,'NI') RESULT_UNIT, -- TODO: Should be standardized units | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -528,6 +528,38 @@ order by 2 | |
; | ||
*/ | ||
|
||
|
||
/* Verify that LAB_RESULT_CM contains data associated with a least half of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to see a test that the average lab value is close to clinical norms (which we should be able to find in wikipedia or the like). |
||
labs defined in PMN_LABLOCAL. | ||
*/ | ||
insert into test_cases (query_name, description, obs, by_value1, by_value2, record_pct, pass) | ||
with partial_lab_counts as ( | ||
select lab_name, count(lab_name) lab_count | ||
from lab_result_cm | ||
group by lab_name | ||
), complete_lab_counts as( | ||
select replace(pmn.lab_name, 'LAB_NAME:', '') lab_name, | ||
case when lc.lab_count is null then 0 else lc.lab_count end lab_count | ||
from pmn_labnormal pmn | ||
left outer join partial_lab_counts lc on concat('LAB_NAME:', lc.lab_name) = pmn.lab_name | ||
), total_lab_types as ( | ||
select count(*) num_labs from complete_lab_counts | ||
), present_lab_types as ( | ||
select count(*) num_labs from complete_lab_counts | ||
where lab_count > 0 | ||
) | ||
select | ||
'LAB_RESULT_CM Test' query_name, | ||
'LAB_RESULT_CM contains data associated with at least half of the defined labs' description, | ||
rownum obs, | ||
plt.num_labs by_value1, | ||
tlt.num_labs by_values2, | ||
round(plt.num_labs/tlt.num_labs, 4) record_pct, | ||
case when (plt.num_labs/tlt.num_labs) > 0.5 then 1 else 0 end pass | ||
from present_lab_types plt | ||
cross join total_lab_types tlt | ||
; | ||
|
||
select case when count(*) > 0 then 1/0 else 1 end all_test_cases_pass from ( | ||
select * from test_cases where pass = 0 | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LAB_NAME,NORM_RANGE_LOW,NORM_MODIFIER_LOW,NORM_RANGE_HIGH,NORM_MODIFIER_HIGH | ||
LAB_NAME:LDL,0,GE,165,LE | ||
LAB_NAME:A1C,,NI,,NI | ||
LAB_NAME:CK,50,GE,236,LE | ||
LAB_NAME:CK_MB,,NI,,NI | ||
LAB_NAME:CK_MBI,,NI,,NI | ||
LAB_NAME:CREATININE,0,GE,1.6,LE | ||
LAB_NAME:HGB,12,GE,17.5,LE | ||
LAB_NAME:INR,0.8,GE,1.3,LE | ||
LAB_NAME:TROP_I,0,GE,0.49,LE | ||
LAB_NAME:TROP_T_QL,,NI,,NI | ||
LAB_NAME:TROP_T_QN,0,GE,0.09,LE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@njgraham , @mprittie noted this is a somewhat invasive change to the SCILHS code but he said you and he chatted about it and couldn't think of a better idea. Does that sound about right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dckc, yes, it seemed like it was best to create/populate the PMN_LabNormal table from a .csv rather than doing a bunch of inserts with hard-coded strings. As I recall, the motivation was that Mike needed access to those values earlier in the process.
We hoped this change would be something that SCILHS would merge back to their version.