Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse CDA section by code in addition to templateId #66

Closed
jenniferjiangkells opened this issue Sep 30, 2024 · 7 comments · Fixed by #87
Closed

Parse CDA section by code in addition to templateId #66

jenniferjiangkells opened this issue Sep 30, 2024 · 7 comments · Fixed by #87
Labels
Component: CDA/FHIR parser Issue/PR that relate to the CDA or FHIR parsing component good first issue Good for newcomers hacktoberfest Issues suitable for hacktoberfest

Comments

@jenniferjiangkells
Copy link
Member

jenniferjiangkells commented Sep 30, 2024

Description

CDA (Clinical Document Architecture) is an XML-based standard for encoding clinical documents, designed to facilitate interoperable exchange of medical information between healthcare systems.

Currently, the CDA parser parses problems, medications, and allergies sections, using a dictionary-based internal representation via xmltodict. It finds sections by parsing and checking the templateId field in structuredBody/Component/Section(Reference). However as it is not a required field, sections are sometimes not picked up. To make sure sections are picked up, we should check the code field as well.

Example

This will parse as a medication section because it contains templateId:

<section>
<templateId root="2.16.840.1.113883.10.20.1.8" />
<templateId root="2.16.840.1.113883.3.88.11.83.112" />
<templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.19" />
<id root="369C0DBE-6FCB-11ED-8917-000C29CBAF7B" />
<code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of Medication use Narrative" />
<title>Medication</title>

This will not be parsed as a medication section because it doesn't contain templateId. The identifier is in the code field instead:
<section>
<code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="HISTORY OF MEDICATION USE" />
<title>Current Medications - as of 09/16/2014</title>

Context

CDAs from different regions and providers can be implemented very differently. This is part of a larger effort to make the CDA parser more configurable and adaptable.

Possible Implementation

  1. Add a SectionCode enum
class SectionCode(Enum):
    MEDICATION = "10160-0"
  1. Add ._find_section_by_code() in CdaAnnotator
  2. Update _find_problems_section(), _find_medications_section(), and _find_allergies_section()
  3. e.g.
def _find_medications_section(self) -> Optional[Section]:
    return (self._find_section_by_template_id(SectionId.MEDICATION.value) or self._find_section_by_code(SectionId.MEDICATION.value))

Alternative Implementation

We can also make the templateId and code configurable - currently hard-coded.

@jenniferjiangkells jenniferjiangkells added Issue: Feature Request ✨ New feature or improvement to existing feature Component: CDA/FHIR parser Issue/PR that relate to the CDA or FHIR parsing component labels Sep 30, 2024
@jenniferjiangkells jenniferjiangkells added good first issue Good for newcomers hacktoberfest Issues suitable for hacktoberfest and removed Issue: Feature Request ✨ New feature or improvement to existing feature labels Sep 30, 2024
@Vortex-21
Copy link
Contributor

Hey Can you assign me this issue ? Will start working on it right away!

@jenniferjiangkells
Copy link
Member Author

👋 @Vortex-21 - assigned you the issue, any questions let me know!

@jenniferjiangkells
Copy link
Member Author

@Vortex-21 just checking if you still want to work on this issue! I will unassign you but please still feel free to work on it if you want - we've just decided to to change the issue assignment system.

@Vortex-21
Copy link
Contributor

Yes I would still want to work on this issue !

@Vortex-21
Copy link
Contributor

Vortex-21 commented Oct 18, 2024

Screenshot 2024-10-18 094011

Here in this component , is the code "51847-2" supposed to be the LOINC code for the NOTE enum ? I could get the exact medication, problem and allergy codes but I am not so sure about the "note" code.

Asking this because the section_id does contain NOTE :

class SectionId(Enum):
    PROBLEM = "2.16.840.1.113883.10.20.1.11"
    MEDICATION = "2.16.840.1.113883.10.20.1.8"
    ALLERGY = "2.16.840.1.113883.10.20.1.2"
    NOTE = "1.2.840.114350.1.72.1.200001"

Apart from this I have made the necessary changes and tested on the uclh_cd.xml document as well as the already existing tests . Everything is working as expected and is ready for a PR .

@jenniferjiangkells
Copy link
Member Author

@Vortex-21 Yes you can assume that's the code for the note section for now!

@Vortex-21
Copy link
Contributor

@Vortex-21 Yes you can assume that's the code for the note section for now!

Yes . Raised the PR using that code only !

@jenniferjiangkells jenniferjiangkells moved this from Todo to Done in HealthChain Nov 26, 2024
@jenniferjiangkells jenniferjiangkells closed this as completed by moving to Done in HealthChain Nov 26, 2024
@jenniferjiangkells jenniferjiangkells linked a pull request Nov 26, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CDA/FHIR parser Issue/PR that relate to the CDA or FHIR parsing component good first issue Good for newcomers hacktoberfest Issues suitable for hacktoberfest
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants