Skip to content
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
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

kembree1
Copy link
Contributor

This pull request covers the following...

  1. Extracts unit of measurement values from the i2b2 Ontology MetadataXML
  2. Changes OMOPmeasuremnt to use the extracted i2b2 unit of measure if the unit value in observation_fact is null
  3. Adds a script that adds more unit of measure mappings to i2o_unit mapping
  4. Adds/updates a number of comments

First option is from the XML housed in PHS Ontology
Second is directly from the observationfact.units_cd
If both fail the value is set to 'unknown' concept 0.
Addded logic to OMOPMeasurement to limit the join to i2o_onotology_lab only based on the most recent XML entry.
Cleaned up the preparePHSOntology.sql
…ta at the moment. May bring them back in.

Removed the inner join to the visit_occurrence which does not change the number of records as every measurement does have a visit_occurrence.
Added more restrictions to the i2o_ontology_lab records that are used.
Fixed the second join to the i2o_unitsmap
Added soem additional comments
Copy link
Contributor

@jklann jklann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I'm suggesting mostly some organizational / documentations changes. Can you also check whether you need to update the README to describe this new approach?

@@ -0,0 +1,75 @@
---------------------------------------------------------------------------------------------
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

@@ -1805,15 +1805,17 @@ cast(m.start_Date as datetime) measurement_datetime,
-- NOTE: Are these concept_ids the ones analysts want?
CASE isnull(m.VALUEFLAG_CD,'0') WHEN 'H' THEN '45876384' WHEN 'L' THEN '45881666' WHEN 'A' THEN '45878745' WHEN 'N' THEN '45884153' ELSE '0' END value_as_concept_id,
CASE WHEN m.ValType_Cd='N' THEN m.NVAL_NUM ELSE null END value_as_number,
isnull(m.Units_CD,'') unit_source_value,
-- NOTE: Units are pulled from PHS Ontology first (extracted from XML) , if not present then it falls back to units_cd on the observation fact
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate to include what it is actually doing (pulling from i_unit in ontology vs units_cd in fact table)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more elaborated comments.

left outer join i2o_unitsmap u on u.units_name=m.units_cd
left outer join i2o_unitsmap u2 on u.units_name=m.i_unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be cleaner to use one left join with and OR in the ON clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our discussion on Friday leaving this as 2 left outer joins with the isnull() function in the select provide more control over precedence and avoids accidental duplicate records.

GO

--Manually UPSERT unit mappings for most commonly used unit values in the PHS XML values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem useful even to people not using the XML-extraction above. Maybe they should go in a different script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has already been separated out into it's own file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants