-
Notifications
You must be signed in to change notification settings - Fork 4
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
Update uom for measurements #20
Open
kembree1
wants to merge
11
commits into
master
Choose a base branch
from
update_UOM_for_measurements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2db6b13
Updated preparePCORnetOntology.sql to be compatible with new UOM updates
kembree1 d108465
Added script to prep PHS Ontology into git repo.
kembree1 de1e508
Updated to OMOPMeasurement to set unit concepts from 2 sources...
kembree1 ad00042
Manually added 12 of the most common unit mappings
kembree1 d68dfb2
Fixed table.column references
kembree1 a65f218
Added a file of upserts for unit mappings
kembree1 91942b2
Commented out the modifiers as they are currently not used for any da…
kembree1 4a76ee4
merged distinct over window function
kembree1 6bafb67
Added a few more UOM mappings
kembree1 263e8bd
Added additional comments to make clear the modifications
kembree1 28aabf1
Renamed Mapping file
kembree1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--------------------------------------------------------------------------------------------- | ||
-- Mass General Brigham specific modifications | ||
-- Description: i2o_transform works off the PCORNET ARCH ontologies, following script | ||
-- --Modifies the transformation to use i2b2 ontoloies in certain circumstances | ||
-- --Adds manual mappings specific to Mass General Brigham | ||
-- Authored by: Jeff Klann | ||
-- Updated by: Kevin Embree on 2020-12-07 to use units specified in the MGB i2b2 XML | ||
-- Added manual mappings for unit conversion | ||
-------------------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------------------- | ||
-- When to run.... | ||
-- After the initial install of the pcornet Ontology or updates to the preparePCORnetOntology.sql | ||
-- Run the new preparePCORnetOntology.sql | ||
-- Subsequent to preparePCORnetOntology.sql For Mass General Brigham users, after delivery of a new i2b2 datamart or updates to the PrepNewOMOPLoader_PHS.sql | ||
-- Run this script, PrepNewOMOPLoader_PHS.sql | ||
-------------------------------------------------------------------------------------------- | ||
|
||
-- Set up the extra columns i_stdcode, i_stddomain | ||
ALTER TABLE [dbo].[i2b2metadata] | ||
ADD [i_stdcode] varchar(100) NULL, | ||
[i_stddomain] varchar(100) NULL, | ||
[i_unit] varchar(100) NULL | ||
GO | ||
CREATE NONCLUSTERED INDEX [i2b2meta_stdcode] | ||
ON [dbo].[i2b2metadata]([i_stdcode]) | ||
GO | ||
|
||
-- Chris' approach, use a view | ||
drop view vw_labtests_reconstructed | ||
GO | ||
create view vw_LabTests_Reconstructed | ||
as | ||
with t as ( | ||
select l.c_name, | ||
l.c_basecode, | ||
f.ENCOUNTER_NUM, | ||
f.PATIENT_NUM, | ||
f.VALTYPE_CD, | ||
f.NVAL_NUM, | ||
f.TVAL_CHAR, | ||
f.VALUEFLAG_CD, | ||
try_cast(l.c_metadataxml as xml) valuexml | ||
from i2b2metadata l | ||
inner join observation_fact f on l.C_BASECODE = f.CONCEPT_CD | ||
where l.c_fullname like '\I2B2MetaData\LabTests\%') | ||
select c_name LabName, | ||
C_BASECODE Concept_Cd, | ||
ENCOUNTER_NUM Encounter_Num, | ||
PATIENT_NUM Patient_Num, | ||
VALTYPE_CD ValueType, | ||
NVAL_NUM NumericValue, | ||
TVAL_CHAR TextValue, | ||
VALUEFLAG_CD ValueFlag, | ||
valuexml, | ||
valuexml.value('(/ValueMetadata/Loinc)[1]','VARCHAR(100)') Loinc, | ||
valuexml.value('(/ValueMetadata/LowofLowValue)[1]','VARCHAR(100)') RefLowofLow, | ||
valuexml.value('(/ValueMetadata/HighofLowValue)[1]','VARCHAR(100)') RefHighofLow, | ||
valuexml.value('(/ValueMetadata/LowofHighValue)[1]','VARCHAR(100)') RefLowofHigh, | ||
valuexml.value('(/ValueMetadata/HighofHighValue)[1]','VARCHAR(100)') RefHighofHigh, | ||
valuexml.value('(/ValueMetadata/UnitValues/NormalUnits)[1]','VARCHAR(100)') Units | ||
from t | ||
GO | ||
|
||
-- Update to set i_stddomain, i_stdcode and i_unit all at once from XML no need for vw_LabTests_Reconstructed | ||
update m set i_stddomain='LOINC',i_stdcode=try_cast(m.c_metadataxml as xml).value('(/ValueMetadata/Loinc)[1]','VARCHAR(50)'), i_unit = try_cast(m.c_metadataxml as xml).value('(/ValueMetadata/UnitValues/NormalUnits)[1]','VARCHAR(25)') from i2b2metadata m | ||
where m.C_FULLNAME like '%\I2B2MetaData\LabTests\%' | ||
GO | ||
-- Create the new views - change COVID_Mart to your DB name | ||
IF EXISTS (SELECT * FROM sys.views WHERE name = N'i2o_ontology_lab') DROP VIEW i2o_ontology_lab | ||
IF EXISTS (SELECT * FROM sys.views WHERE name = N'i2o_ontology_drug') DROP VIEW i2o_ontology_drug | ||
GO | ||
create view i2o_ontology_lab as (select * from AllOfUs_Mart..i2b2metadata where i_stddomain='LOINC') | ||
GO | ||
create view i2o_ontology_drug as (select * from AllOfUs_Mart..pcornet_med where i_stddomain='RxNorm' or i_stddomain='NDC') | ||
GO |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This script almost could be used generally, not just at PHS. You don't need to make those changes, but please describe what it's doing in the documentation and it is adaptable to any site using low/high/units in metadata XML.
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.
Also I would rename it something like extractUnitsFromOntology
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.
Renamed the script to be not PHS specific.