Reputation: 15180
Am trying to store a Clinical Document Architecture (CDA) Continuity of Care Document (CCD) into HealthKit to display under HK's Health Records sub-section.
HealthKit's CDADocumentSampleWithData:startDate:endDate:metadata:validationError:
gives me:
Error code 3
and userInfo
shows:
[0]
Key: NSLocalizedDescription
Value: Failed to validate XML, error code 1871
[1]
Key: HKDetailedCDAValidationErrorKey
Value: Element '{urn:hl7-org:v3}reference': This element is not expected. Expected is ( {urn:hl7-org:v3}translation ).\nElement '{urn:hl7-org:v3}reference': This element is not expected. Expected is ( {urn:hl7-org:v3}translation ).\n
Which gives no clue as to where (in which line) the issue exists in the CDA CCD. And to make it a little more confusing the Value element shows the string twice as shown above... and no line numbers.
"reference
" vs "translation
" is perhaps a clue. Unfortunately the word "reference
" is found on 422 lines in the CCD, "translation
" found 46 on 46 lines.
I wish I could post the CCD but it contains PHI (protected health information) so I cannot.
Any hints or tips appreciated!
Upvotes: 0
Views: 326
Reputation: 15180
The key turned out to be stray empty xml tags:
<reference \>
and while someone thought it was helpful to respond with:
Expected is ( {urn:hl7-org:v3}translation )
it simply was of no use. The HealthKit error was basically useless and would have been clearer if it were in Klingon.
To find the line where the problem existed... I found a great (not pretty) online validator which had the courtesy of providing the same error and the line number:
lineNumber: 9709; columnNumber: 24; cvc-complex-type.2.4.a: Invalid content was found starting with element 'reference'. One of '{"urn:hl7-org:v3":translation}' is expected.
And the link to the online validator that did what HealthKit could not:
https://www.lantanagroup.com/validator/
Upvotes: 1
Reputation: 691
To validate a CDA, I always use HL7 official schemas or schematrons, both if I do local validations on my desktop using XML tools like Oxygen XML or if I do it on Java. On both cases I get detailed info and location of the errors, so these is why I recommend this option. I hope useful.
Upvotes: 1
Reputation: 37916
Chances are you're trying to consume a wrong document type, e.g. parse HITSP CCD as HL7 CCD. Determine your CDA type (there're different flavours and versions). Here's a good article on how to do this - https://motorcycleguy.blogspot.com/2017/01/what-version-of-ccda-document-is-this.html
Validate the CDA document. Make sure that reference
element is where it is not by mistake. Use any of these services:
Upvotes: 0