Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Not all of a procedures's participants are "device"s. #17

Closed
jmandel opened this issue Mar 7, 2013 · 7 comments
Closed

Not all of a procedures's participants are "device"s. #17

jmandel opened this issue Mar 7, 2013 · 7 comments
Milestone

Comments

@jmandel
Copy link
Member

jmandel commented Mar 7, 2013

For example the following is silly:

    "device": {
      "name": "General Acute Care Hospital",
      "code": "GACH",
      "code_system": "2.16.840.1.113883.5.111"
    }

The hospital isn't listed as a device; it's listed as Service Delivery Location (templateId = 2.16.840.1.113883.10.20.22.4.32). You'll want to identify devices by [@templateId = '2.16.840.1.113883.10.20.22.4.37']/../playingDevice/code...

(This appears to stem from the use of getElementsByTag at https://github.com/blue-button/bluebutton.js/blob/master/src/core.js#L45, which recurses and finds nested elements, not just direct-children -- which can make the convenience wrappers fail in surprising ways when it doesn't find what it expects at the top of the hierarchy.)

@blacktm
Copy link
Member

blacktm commented Mar 7, 2013

A few things. <participant> is mapped to device, from your earlier suggestion. This is what I have in bb.js:

// participant => device
el = entry.tag('participant').tag('code');
var device_name = el.attr('displayName'),
    device_code = el.attr('code'),
    device_code_system = el.attr('codeSystem');

Designed to parse:

<participant typeCode="LOC">
  <participantRole classCode="SDLOC">
    <templateId root="2.16.840.1.113883.10.20.22.4.32"/>
    <!-- Service Delivery Location template -->
    <code code="GACH" codeSystem="2.16.840.1.113883.5.111" codeSystemName="HL7 RoleCode" displayName="General Acute Care Hospital"/>

Instead of grabbing the participant tag, I should grab by templateId? That would look something like this (a snippet from problems):

el = entry.template('2.16.840.1.113883.10.20.22.4.4').tag('code');
var name = el.attr('displayName'),
    code = el.attr('code'),
    code_system = el.attr('codeSystem');

@jmandel
Copy link
Member Author

jmandel commented Mar 8, 2013

Yes -- going on participant is picking up not only devices, but also service delivery locations. (Ideally you'd define the entire path segment, e.g. participant/participantRole/templateId[@root="..."]/../code" which could make the behavior more predictable.)

@sankarravi sankarravi reopened this Mar 27, 2015
@thetylerhayes
Copy link
Contributor

FWIW we already do something similar to this in the C32 results parser: https://github.com/blue-button/bluebutton.js/blob/master/lib/parsers/c32/results.js#L36:

... 
// sometimes results organizers contain non-results. we only want tests
    if (observation.template('2.16.840.1.113883.10.20.1.31').val()) {
        var date = parseDate(observation.tag('effectiveTime').attr('value'));
...

So some sorta kinda precedent exists.

@sankarravi
Copy link
Member

Yep, I have a fix for this on https://github.com/blue-button/bluebutton.js/pull/127/files#diff-e8efe13f6db4f401b317888b6d6cc9f4R39. Working on getting that PR ready for merge.

@sankarravi sankarravi added this to the 0.4.0 milestone Apr 10, 2015
@norlowski
Copy link

Was this merged into master? I still see the above code with "participant => device".

Is the example @jmandel mentioned just a data problem in the official example ccda?

@sankarravi
Copy link
Member

@norlowski The code on master looks like this:

    // participant => device
    el = entry.template('2.16.840.1.113883.10.20.22.4.37').tag('code');
    var device_name = el.attr('displayName'),
        device_code = el.attr('code'),
        device_code_system = el.attr('codeSystem');

So it now looks specifically for a tag that identifies a device. This should mean that only actual devices get parsed as devices. You can see in 79042f5#diff-46f39fe99505a71da1d296e1f8f3969eR640 that Josh's specific example is no longer parsed as a device (or technically that the tests, which pass, had to adjust for that expectation)

@norlowski
Copy link

Thanks for the updates!

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

No branches or pull requests

5 participants