amida-tech/blue-button

Social history value not parsed when `@xsi:type="PQ"`

Closed this issue · 2 comments

Problem

When given a CCDA document with social history records that contain

<value xsi:type="PQ" value="12" />

the value is not parsed by blue-button. That social history record will not have a value property but value is required by the model.

Example xml

https://github.com/HL7/C-CDA-Examples/blob/master/Documents/CCD/CCD%201/CCD.XML

The <value> with xsi:type="PQ" is on line 3148.

Parses into invalid document

After parsing the xml above and printing bb.validator.getLastError(), I see an error:

 {
    code: 'OBJECT_MISSING_REQUIRED_PROPERTY',
    params: [ 'value' ],
    message: 'Missing required property: value',
    path: '#/data/social_history/1',
    schemaId: 'document_model'
}

Proposed fix

Update the xpath expression in the social history parser so it handles PQ values.

-["value", "0..1", "h:value[@xsi:type='ST']/text() | h:value[@xsi:type='CD']/@displayName"]
+["value", "0..1", "h:value[@xsi:type='ST']/text() | h:value[@xsi:type='CD']/@displayName | h:value[@xsi:type='PQ']/@value"]

Would you be open to accepting a PR with this change?

@psalaets Send a PR for this when ready.

Thanks for the quick turnaround