Skip to content

Commit

Permalink
Uncouple reports from collections
Browse files Browse the repository at this point in the history
  • Loading branch information
medihack committed Feb 24, 2024
1 parent 8919188 commit ebe16c1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
13 changes: 13 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## High Priority

- Show metadata in report details
- Age slider
- <https://tailwindcomponents.com/component/multi-range-slider>
- <https://codepen.io/glitchworker/pen/XVdKqj>
- <https://medium.com/@predragdavidovic10/native-dual-range-slider-html-css-javascript-91e778134816>
- Upgrade Github actions workflows (also ADIT)
- Allow to set filters when using search
- from:2024-01-01 until:2024-02-01 modality:ct description:"CT\*"
Expand All @@ -17,6 +22,7 @@
- Reference: name (unique), match (unique)
- Sidebar like in <https://cord19.vespa.ai/search?query=pain> with filters: Age, Gender, Modality, Study Description
- Remove unneeded templatetags
- Are pandas and openpyxl needed as deps?!

## Fix

Expand All @@ -42,6 +48,7 @@
- Collect all matching reports
- Notify user by Email when job is finished
- Let user browse the results
- Fetch favicon for links
- Categories app
- LLMs answers to questions abouts reports to tag them with different categories like LAE, emphysema, ...
- Similar to RAG app (also maybe depends on it for accessing the LLM)
Expand All @@ -58,6 +65,12 @@

## Maybe

- Rename reports model fields to something in the HL7 FHIR standard
- Interesting resources in this regard are:
- <https://hl7.org/fhir/patient.html>
- <https://hl7.org/fhir/observation.html>
- <https://hl7.org/fhir/diagnosticreport.html>
- <https://hl7.org/fhir/imagingstudy.html>
- Adjust the summary dynamic snippets of the search results
- <https://docs.vespa.ai/en/document-summaries.html>
- Unfortunately, ApplicationConfiguration does not allow to put the configuration inside the content cluster (see link above)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load collections_count from reports_extras %}
{% load collections_count from collections_extras %}
<div hx-get="{% url 'collection_count_badge' report.id %}"
hx-trigger="collectionsOfReportChanged_{{ report.id }} from:body"
hx-swap="outerHTML"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from typing import Any, cast

from django.db.models import QuerySet
from django.template import Library

from radis.accounts.models import User
from radis.reports.models import Report

from ..models import Report
from ..models import Collection

register = Library()


@register.simple_tag(takes_context=True)
def collections_count(context: dict[str, Any], report: Report):
user = cast(User, context["request"].user)
return report.get_collections_count(user)
collections = cast(QuerySet[Collection], getattr(report, "collections"))
return collections.filter(owner=user).count()
17 changes: 0 additions & 17 deletions radis/reports/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import TYPE_CHECKING

from django.contrib.auth.models import Group
from django.contrib.postgres.fields import ArrayField
from django.db import models

from radis.accounts.models import User
from radis.core.models import AppSettings
from radis.core.validators import (
no_backslash_char_validator,
Expand All @@ -14,11 +11,6 @@
validate_patient_sex,
)

if TYPE_CHECKING:
from django.db.models import manager

from radis.collections.models import Collection


class ReportsAppSettings(AppSettings):
class Meta:
Expand Down Expand Up @@ -60,14 +52,5 @@ class Report(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

if TYPE_CHECKING:
collections = manager.RelatedManager["Collection"]()

def __str__(self) -> str:
return f"Report {self.id} [{self.document_id}]"

def get_collections(self, owner: User) -> models.QuerySet["Collection"]:
return self.collections.filter(owner=owner)

def get_collections_count(self, owner: User) -> int:
return self.get_collections(owner).count()

0 comments on commit ebe16c1

Please sign in to comment.