Skip to content

FHIR API to dicom4ortho. Generate Orthodontic Photographs From a FHIR Bundle and a DICOM ModalityWorklist

License

Notifications You must be signed in to change notification settings

open-ortho/fhir2dicom4ortho

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

fhir2dicom4ortho 0.1.0

A FHIR API Frontend to dicom4ortho.
Explore the docs »

View Demo · Report Bug · Request Feature

About The Project

TODO

Built With

Building

poetry install

Getting Started

Prerequisites

Poetry

Installation

# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -

# or install with pipx

# Install dependencies
poetry install

# Activate the virtual environment
poetry shell

Usage

docker run -d \
  --env-file ./test/env-dev \
  -p 127.0.0.1:8203:8000 \
  -v ./tasks.sqlite:/app/tasks.sqlite \
  --name fhir2dicom4ortho \
  cr.medoco.health/open-ortho/fhir2dicom4ortho:latest

There is the docker-compose.yml you can use as example.

API Endpoints

The fhir2dicom4ortho project implements a partial set of FHIR API endpoints to interact with DICOM Orthodontic imaging studies. Below are the currently implemented endpoints along with their functionalities and references to the official FHIR documentation.

POST /fhir/Bundle

Description:
Accepts a FHIR Bundle containing Task, ImagingStudy, and Binary resources. Processes the bundle by scheduling the creation and sending of a DICOM image to the PACS server.

Functionality:

  • Validates the incoming Bundle for required resources.
  • Updates the Task status to "received".
  • Schedules the job using APScheduler.
  • Returns the updated Task resource.

FHIR Documentation:

GET /fhir/Task/{task_id}

Description:
Retrieves the status of a specific Task by its task_id.

Functionality:

  • Fetches the Task resource corresponding to the provided task_id.
  • Returns the Task resource if found.
  • Returns an OperationOutcome if the Task is not found.

FHIR Documentation:

GET /fhir/Task

Description:
Retrieves all existing Tasks.

Functionality:

  • Fetches all Task resources.
  • Returns a FHIR Bundle containing the list of Tasks.

FHIR Documentation:

Note:
The current implementation includes only the above endpoints. Additional endpoints and functionalities could be planned for future releases to provide better support for FHIR operations.

Known Issues

Please check the Implementation Status document.

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development

Before development,

  1. poetry update to update all dependencies;
  2. Run all tests and fix issues caused by update dependecies;
  3. Continue development;

requirement.txt

The requirements.txt file is only used for Dependabot, which i think works off of that and not poetry.lock. However, the project's dependencies are managed by poetry.

Building a new docker image should trigger the generation of a new requirements.txt, which you should then safely commit.

Building the FHIR Bundle

To operate this API, you need to construct a FHIR Bundle containing specific resources. Below is an example of how to build the required FHIR Bundle, using fhir2dicom4ortho.Bundle.json as a reference.

Example FHIR Bundle

See test/fhir2dicom4ortho.Bundle.json for a full example implementation.

The FHIR Bundle should contain the following resources:

  1. Task: Describes the task to be performed.
  2. ImagingStudy: Contains information about the imaging study.
  3. Binary (DICOM MWL): Contains the DICOM Modality Worklist (MWL) data.
  4. Binary (Image File): Contains the image file data.

Task Resource

The Task resource describes the task to be performed, including references to the Binary and ImagingStudy resources.

{
  "resourceType": "Task",
  "id": "task-id",
  "status": "requested",
  "intent": "order",
  "description": "Process DICOM MWL and Image Input",
  "authoredOn": "2024-06-16T14:00:00Z",
  "requester": {
    "reference": "Practitioner/456",
    "display": "Dr. John Doe"
  },
  "for": {
    "reference": "Patient/123",
    "display": "Patient Example"
  },
  "input": [
    {
      "type": {
        "text": "DICOM MWL"
      },
      "valueReference": {
        "reference": "Binary/dicom-mwl-id"
      }
    },
    {
      "type": {
        "text": "Image File"
      },
      "valueReference": {
        "reference": "Binary/image-file-id"
      }
    },
    {
      "type": {
        "text": "Image Study"
      },
      "valueReference": {
        "reference": "ImagingStudy/imaging-study-id"
      }
    }
  ]
}

ImagingStudy Resource

The ImagingStudy resource contains information about the imaging study, including series and instances.

{
  "resourceType": "ImagingStudy",
  "id": "imaging-study-id",
  "status": "available",
  "subject": {
    "reference": "Patient/123",
    "display": "Patient Example"
  },
  "started": "2024-06-16T14:00:00Z",
  "numberOfSeries": 1,
  "numberOfInstances": 1,
  "series": [
    {
      "uid": "series-uid",
      "number": 7,
      "modality": {
        "coding": [
          {
            "system": "http://dicom.nema.org/resources/ontology/DCM",
            "code": "XC",
            "display": "External-camera Photography"
          }
        ]
      },
      "started": "2024-06-16T14:00:00Z",
      "description": "Sample XC Series",
      "numberOfInstances": 1,
      "instance": [
        {
          "uid": "instance-uid",
          "sopClass": {
            "system": "https://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_B.5.html#table_B.5-1",
            "code": "1.2.840.10008.5.1.4.1.1.77.1.4.1",
            "display": "VL Photographic Image Storage"
          },
          "number": 100,
          "title": "Sample Orthodontic Image"
        }
      ]
    }
  ]
}

Binary (DICOM MWL) Resource

The Binary resource containing the DICOM Modality Worklist (MWL) data.

{
  "resourceType": "Binary",
  "id": "dicom-mwl-id",
  "contentType": "application/dicom",
  "data": "base64-encoded-dicom-mwl-data"
}

Binary (Image File) Resource

The Binary resource containing the image file data.

{
  "resourceType": "Binary",
  "id": "image-file-id",
  "contentType": "image/png",
  "data": "base64-encoded-image-data"
}

Constructing the Bundle

Combine the above resources into a single FHIR Bundle.

{
  "resourceType": "Bundle",
  "type": "batch",
  "entry": [
    {
      "fullUrl": "urn:uuid:task-id",
      "resource": { /* Task resource */ },
      "request": {
        "method": "POST",
        "url": "http://fhir2dicom4ortho/fhir/Bundle"
      }
    },
    {
      "fullUrl": "urn:uuid:imaging-study-id",
      "resource": { /* ImagingStudy resource */ },
      "request": {
        "method": "POST",
        "url": "http://fhir2dicom4ortho/fhir/Bundle"
      }
    },
    {
      "fullUrl": "urn:uuid:dicom-mwl-id",
      "resource": { /* Binary (DICOM MWL) resource */ },
      "request": {
        "method": "POST",
        "url": "http://fhir2dicom4ortho/fhir/Bundle"
      }
    },
    {
      "fullUrl": "urn:uuid:image-file-id",
      "resource": { /* Binary (Image File) resource */ },
      "request": {
        "method": "POST",
        "url": "http://fhir2dicom4ortho/fhir/Bundle"
      }
    }
  ]
}

This FHIR Bundle can then be sent to the API to process the DICOM MWL and image input.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Toni Magni- @zgypa - [email protected]

Project Link: https://github.com/open-ortho/fhir2dicom4ortho

Acknowledgements

About

FHIR API to dicom4ortho. Generate Orthodontic Photographs From a FHIR Bundle and a DICOM ModalityWorklist

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published