amida-tech / blue-button

Blue Button (CCDA/CMS Blue Button/etc) to JSON Parser.
Other
48 stars 44 forks source link

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

Closed psalaets closed 2 years ago

psalaets commented 2 years ago

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?

Manhydra commented 2 years ago

@psalaets Send a PR for this when ready.

psalaets commented 2 years ago

Thanks for the quick turnaround