Skip to content

Add helper function to create FHIR DocumentReferenceContent #138

@jenniferjiangkells

Description

@jenniferjiangkells

The codebase has helper functions for creating various FHIR resources (e.g., create_condition, create_document_reference), but is missing a helper for creating DocumentReferenceContent objects. This makes it harder to build DocumentReference resources with content.

File: healthchain/fhir/helpers.py

Current TODO:

# TODO: create a function that creates a DocumentReferenceContent to add to the DocumentReference

Goal:
Create a create_document_reference_content() helper function following the existing patterns in helpers.py.

Acceptance Criteria:

  • Function signature follows existing helper patterns (see create_condition, etc.)
  • Supports common content types (at minimum: text/plain, text/html, application/pdf)
  • Returns a properly structured DocumentReferenceContent object
  • Includes comprehensive docstring with examples
  • Add unit tests in tests/fhir/test_helpers.py
  • Export function in healthchain/fhir/__init__.py

Suggested API:

def create_document_reference_content(
    attachment_data: str,
    content_type: str = "text/plain",
    language: str = "en-US",
    title: Optional[str] = None,
    **kwargs
) -> DocumentReferenceContent:
    """Create a FHIR DocumentReferenceContent object.
    
    Args:
        attachment_data: The content data (text or base64 encoded)
        content_type: MIME type (e.g., 'text/plain', 'application/pdf')
        language: Language code
        title: Optional title for the content
        **kwargs: Additional DocumentReferenceContent fields
    
    Returns:
        DocumentReferenceContent: A FHIR DocumentReferenceContent object
        
    Example:
        >>> content = create_document_reference_content(
        ...     "Patient presents with fever...",
        ...     content_type="text/plain",
        ...     title="Clinical Note"
        ... )
    """

Resources:

  • FHIR DocumentReference docs
  • Study existing helpers in healthchain/fhir/helpers.py for patterns
  • fhir.resources library documentation for DocumentReferenceContent

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions