ARCH-commons / i2p-transform

i2b2 to PCORnet Common Data Model Transformation - requires i2b2 PCORnet ontology
Other
3 stars 16 forks source link

how is the PRESCRIBING pivot modifier_cd constraint supposed to work? #46

Closed dckc closed 7 years ago

dckc commented 7 years ago

How could this ever work? The modifier_cd in basis and freq are never the same. The result we see, rather than one row with basis and freq columns, is two rows, one with basis, and one with freq:

 from i2b2medfact m inner join pcornet_med mo on m.concept_cd = mo.c_basecode 
...
    left join basis
    on m.encounter_num = basis.encounter_num
    and m.concept_cd = basis.concept_Cd
    and m.start_date = basis.start_date
    and m.provider_id = basis.provider_id
    and m.modifier_cd = basis.modifier_cd

    left join  freq
    on m.encounter_num = freq.encounter_num
    and m.concept_cd = freq.concept_Cd
    and m.start_date = freq.start_date
    and m.provider_id = freq.provider_id
    and m.modifier_cd = freq.modifier_cd

cc @mprittie @rwaitman

dckc commented 7 years ago

It would seem to make more sense to join on instance_num. I see somebody else requested this in #11.

matthewjoss commented 7 years ago

I changed the left joins to use instance_num instead of modifer_cd.

dckc commented 7 years ago

for reference: 58f138dabe46a485b26dacf51d9980a65d0a9cb5