diff --git a/tracex_project/extraction/templates/filter_journey.html b/tracex_project/extraction/templates/filter_journey.html
index d1337db5..7f59988a 100644
--- a/tracex_project/extraction/templates/filter_journey.html
+++ b/tracex_project/extraction/templates/filter_journey.html
@@ -332,7 +332,7 @@ DFG activity key
-
+
diff --git a/tracex_project/extraction/templates/journey_details.html b/tracex_project/extraction/templates/journey_details.html
index 70fd9da8..aea158fd 100644
--- a/tracex_project/extraction/templates/journey_details.html
+++ b/tracex_project/extraction/templates/journey_details.html
@@ -17,7 +17,7 @@ Content of "{{ patient_journey.name }}"
-
+
diff --git a/tracex_project/extraction/templates/result.html b/tracex_project/extraction/templates/result.html
index 7a5f4fb7..e0dfead8 100644
--- a/tracex_project/extraction/templates/result.html
+++ b/tracex_project/extraction/templates/result.html
@@ -11,7 +11,7 @@
Success! The TracEX pipeline produced the following results:
- This is the patient journey you provided:
+ This is the Patient Journey you provided:
{{ journey }}
diff --git a/tracex_project/extraction/templates/select_journey.html b/tracex_project/extraction/templates/select_journey.html
index 8106cd99..703a0527 100644
--- a/tracex_project/extraction/templates/select_journey.html
+++ b/tracex_project/extraction/templates/select_journey.html
@@ -10,7 +10,7 @@
Select Patient Journey from Database
- Please select a patient journey from the database below.
+ Please select a Patient Journey from the database below.
-
+
diff --git a/tracex_project/extraction/tests/test_orchestrator.py b/tracex_project/extraction/tests/test_orchestrator.py
index 1955713e..caaea5dc 100644
--- a/tracex_project/extraction/tests/test_orchestrator.py
+++ b/tracex_project/extraction/tests/test_orchestrator.py
@@ -5,7 +5,6 @@
from extraction.logic.orchestrator import ExtractionConfiguration, Orchestrator
from extraction.logic.modules import (
- Preprocessor,
ActivityLabeler,
CohortTagger,
)
@@ -109,16 +108,15 @@ def test_initialize_modules(self):
def test_run(self):
"""Test if the run method correctly returns a dataframe. Execution of ActivityLabeler, CohortTagger and
- Preprocessor is necessary since the run method makes assumptions on how the patient journey looks like.
+ Preprocessor is necessary since the run method makes assumptions on how the Patient Journey looks like.
"""
Orchestrator.reset_instance()
configuration = ExtractionConfiguration(
- patient_journey="This is a test patient journey. This is some description about how I fell ill and "
+ patient_journey="This is a test Patient Journey. This is some description about how I fell ill and "
"recovered in the end.",
)
configuration.update(
modules={
- "preprocessing": Preprocessor,
"activity_labeling": ActivityLabeler,
"cohort_tagging": CohortTagger,
}
diff --git a/tracex_project/extraction/tests/test_views.py b/tracex_project/extraction/tests/test_views.py
index 9b3c3e4e..7375c94c 100644
--- a/tracex_project/extraction/tests/test_views.py
+++ b/tracex_project/extraction/tests/test_views.py
@@ -9,7 +9,6 @@
JourneyUploadForm,
JourneySelectForm,
FilterForm,
- ResultForm,
)
from extraction.models import (
PatientJourney,
@@ -20,7 +19,6 @@
JourneySelectView,
JourneyDetailView,
JourneyFilterView,
- ResultView,
)
@@ -101,7 +99,7 @@ def test_view_post_valid_form(self):
Test that posting a valid form with a file upload successfully creates
a new model instance with the uploaded content and redirects to the correct success URL.
"""
- file_content = "This is a test patient journey."
+ file_content = "This is a test Patient Journey."
uploaded_file = SimpleUploadedFile("test.txt", file_content.encode("utf-8"))
form_data = {"name": "Test Journey", "file": uploaded_file}
@@ -168,10 +166,10 @@ def test_view_context_data(self):
def test_view_post_valid_form(self):
"""
- Test that posting a valid form by selecting an existing patient journey redirects to the correct success URL.
+ Test that posting a valid form by selecting an existing Patient Journey redirects to the correct success URL.
"""
mock_journey = PatientJourney.manager.create(
- name="Test Journey", patient_journey="This is a test patient journey."
+ name="Test Journey", patient_journey="This is a test Patient Journey."
)
form_data = {"selected_patient_journey": mock_journey.name}
response = self.client.post(self.url, data=form_data, format="multipart")
@@ -203,10 +201,10 @@ class JourneyDetailViewTests(TestCase):
"""Test cases for the JourneyDetailView."""
def setUp(self): # pylint: disable=invalid-name
- """Set up test client, a mock patient journey and the URL."""
+ """Set up test client, a mock Patient Journey and the URL."""
self.client = Client()
self.mock_journey = PatientJourney.manager.create(
- name="Test Journey", patient_journey="This is a test patient journey."
+ name="Test Journey", patient_journey="This is a test Patient Journey."
)
self.url = reverse("journey_details", kwargs={"pk": self.mock_journey.pk})
@@ -235,7 +233,7 @@ def test_view_context_data(self):
)
def test_view_without_patient_journey(self):
- """Test that requesting a patient journey that does not exist returns a 404 error."""
+ """Test that requesting a Patient Journey that does not exist returns a 404 error."""
response = self.client.get(reverse("journey_details", kwargs={"pk": 999}))
self.assertEqual(response.status_code, 404)
@@ -263,10 +261,10 @@ class JourneyFilterViewTests(TestCase):
fixtures = ["tracex_project/extraction/fixtures/prompts_fixture.json"]
def setUp(self): # pylint: disable=invalid-name
- """Set up test client, a mock patient journey, the URL and a factory that sends requests to the view."""
+ """Set up test client, a mock Patient Journey, the URL and a factory that sends requests to the view."""
self.client = Client()
self.mock_journey = PatientJourney.manager.create(
- name="Test Journey", patient_journey="This is a test patient journey."
+ name="Test Journey", patient_journey="This is a test Patient Journey."
)
self.url = reverse("journey_filter")
self.factory = RequestFactory()
@@ -301,27 +299,6 @@ def test_get_context_data(self):
self.assertIn("is_comparing", context)
- # Non-deterministic test since orchestrator is executed
- def test_form_valid(self):
- """Test that a valid form submission redirects to the correct URL."""
- form_data = {
- "modules_required": ["activity_labeling"],
- "modules_optional": ["preprocessing", "event_type_classification"],
- "event_types": ["Symptom Onset", "Symptom Offset"],
- "locations": ["Home", "Hospital", "Doctors", "N/A"],
- "activity_key": "event_type",
- }
- # Set up session data
- session = self.client.session
- session["is_comparing"] = False
- session.save()
-
- # Submit the form using the test client
- response = self.client.post(self.url, data=form_data)
-
- self.assertEqual(response.status_code, 302)
- self.assertRedirects(response, reverse("result"))
-
def test_get_ajax(self):
"""
Test the `get` method when an AJAX request is made.
@@ -338,70 +315,3 @@ def test_get_ajax(self):
self.assertEqual(
json.loads(response.content), {"progress": 50, "status": "running"}
)
-
-
-class ResultViewTests(TestCase):
- """Test cases for the ResultView."""
-
- fixtures = ["tracex_project/tracex/fixtures/dataframe_fixtures.json"]
-
- def setUp(self): # pylint: disable=invalid-name
- """Set up test client, a mock patient journey, session data and the URL."""
- self.client = Client()
- self.mock_journey = PatientJourney.manager.create(
- name="Test Journey", patient_journey="This is a test patient journey."
- )
- self.session = self.client.session
- self.session["selected_modules"] = ["activity_labeling", "cohort_tagging"]
- self.session.save()
- self.url = reverse("result")
-
- def test_view_get_request(self):
- """Test that the view URL exists and is accessible by passing a GET request."""
- response = self.client.get(self.url)
- resolver = resolve(self.url)
-
- self.assertEqual(response.status_code, 200)
- self.assertEqual(resolver.func.view_class, ResultView)
-
- def test_uses_correct_template(self):
- """Test that the view uses the correct template."""
- response = self.client.get(self.url)
-
- self.assertTemplateUsed(response, "result.html")
-
- def test_uses_correct_form(self):
- """Test that the view uses the correct form."""
- response = self.client.get(self.url)
-
- self.assertIsInstance(response.context["form"], ResultForm)
-
- def test_get_form_kwargs(self):
- """Test that correct form kwargs are passed to the form."""
- response = self.client.get(self.url)
-
- self.assertEqual(response.status_code, 200)
-
- form = response.context["form"]
-
- self.assertIsInstance(form, ResultForm)
- self.assertEqual(
- (form.initial["selected_modules"]), self.session["selected_modules"]
- )
-
- def test_get_context_data(self):
- """Test that the view fetches the correct context data."""
- response = self.client.get(self.url)
-
- self.assertEqual(response.status_code, 200)
-
- context = response.context
-
- self.assertIn("form", context)
- self.assertIsInstance(context["form"], ResultForm)
- self.assertIn("journey", context)
- self.assertEqual(context["journey"], self.mock_journey.patient_journey)
- self.assertIn("dfg_img", context)
- self.assertIn("trace_table", context)
- self.assertIn("all_dfg_img", context)
- self.assertIn("event_log_table", context)
diff --git a/tracex_project/extraction/views.py b/tracex_project/extraction/views.py
index eca6d05f..b9524100 100644
--- a/tracex_project/extraction/views.py
+++ b/tracex_project/extraction/views.py
@@ -28,13 +28,13 @@
class JourneyInputSelectView(generic.TemplateView):
- """A Django view that renders a template for the user to choose the patient journey input method."""
+ """A Django view that renders a template for the user to choose the Patient Journey input method."""
template_name = "choose_input_method.html"
class JourneyUploadView(generic.CreateView):
- """A Django view that handles the uploading of a patient journey."""
+ """A Django view that handles the uploading of a Patient Journey."""
form_class = JourneyUploadForm
template_name = "upload_journey.html"
@@ -55,7 +55,7 @@ def get_success_url(self):
class JourneySelectView(generic.FormView):
- """A Django view that handles the selection of a patient journey from the database."""
+ """A Django view that handles the selection of a Patient Journey from the database."""
model = PatientJourney
form_class = JourneySelectForm
@@ -71,13 +71,13 @@ def form_valid(self, form):
class JourneyDetailView(generic.DetailView):
- """A Django view that displays the details of a selected patient journey."""
+ """A Django view that displays the details of a selected Patient Journey."""
model = PatientJourney
template_name = "journey_details.html"
def get_context_data(self, **kwargs):
- """Overrides the get_context_data method to add the patient journey to the context data."""
+ """Overrides the get_context_data method to add the Patient Journey to the context data."""
context = super().get_context_data(**kwargs)
patient_journey = self.get_object()
context["patient_journey"] = patient_journey
diff --git a/tracex_project/patient_journey_generator/apps.py b/tracex_project/patient_journey_generator/apps.py
index 3280e08c..4e81b3bc 100644
--- a/tracex_project/patient_journey_generator/apps.py
+++ b/tracex_project/patient_journey_generator/apps.py
@@ -1,4 +1,4 @@
-"""App configuration for patient journey generator app."""
+"""App configuration for Patient Journey generator app."""
from django.apps import AppConfig
diff --git a/tracex_project/patient_journey_generator/forms.py b/tracex_project/patient_journey_generator/forms.py
index 3a9a9372..8344e84c 100644
--- a/tracex_project/patient_journey_generator/forms.py
+++ b/tracex_project/patient_journey_generator/forms.py
@@ -1,13 +1,13 @@
-"""Implementation of forms for the patient journey generator app."""
+"""Implementation of forms for the Patient Journey generator app."""
from django import forms
from extraction.models import PatientJourney
class GenerationOverviewForm(forms.ModelForm):
"""
- Form for generating a patient journey.
+ Form for generating a Patient Journey.
- By submitting this form, a patient journey is generated and saved in the orchestrator's configuration.
+ By submitting this form, a Patient Journey is generated and saved in the orchestrator's configuration.
"""
class Meta:
@@ -19,8 +19,9 @@ class Meta:
fields -- The fields to include in the form.
help_texts -- The help texts for the fields.
widgets -- The widgets for the fields.
- - "name" - A text input field to name the patient journey. Required, to save patient journey in the database.
+ - "name" - A text input field to name the Patient Journey. Required, to save Patient Journey in the database.
"""
+
model = PatientJourney
fields = ["name"]
help_texts = {
@@ -28,6 +29,6 @@ class Meta:
}
widgets = {
"name": forms.TextInput(
- attrs={"placeholder": "Name for your patient journey"}
+ attrs={"placeholder": "Name for your Patient Journey"}
),
}
diff --git a/tracex_project/patient_journey_generator/generator.py b/tracex_project/patient_journey_generator/generator.py
index 433639f3..1bf0d36e 100644
--- a/tracex_project/patient_journey_generator/generator.py
+++ b/tracex_project/patient_journey_generator/generator.py
@@ -1,12 +1,12 @@
"""
-Provides functionality to generate a synthetic patient journey by using the OpenAI API.
+Provides functionality to generate a synthetic Patient Journey by using the OpenAI API.
Functions:
-generate_patient_journey -- Generates a synthetic patient journey.
-create_patient_journey_context -- Creates a context for the synthetic patient journey.
+generate_patient_journey -- Generates a synthetic Patient Journey.
+create_patient_journey_context -- Creates a context for the synthetic Patient Journey.
get_country -- Randomizes a european country.
-get_date -- Randomizes a start date for the synthetic patient journey.
-get_life_circumstances -- Generates life circumstances for the synthetic patient journey.
+get_date -- Randomizes a start date for the synthetic Patient Journey.
+get_life_circumstances -- Generates life circumstances for the synthetic Patient Journey.
"""
from datetime import datetime, timedelta
import random
@@ -17,7 +17,7 @@
def generate_patient_journey():
- """Generate a synthetic patient journey."""
+ """Generate a synthetic Patient Journey."""
messages = Prompt.objects.get(name="CREATE_PATIENT_JOURNEY").text
messages.insert(0, {"role": "system", "content": create_patient_journey_context()})
patient_journey = u.query_gpt(messages=messages, temperature=1)
@@ -27,7 +27,7 @@ def generate_patient_journey():
def create_patient_journey_context():
"""
- Create a context for the patient journey.
+ Create a context for the Patient Journey.
The context includes a random sex, country, date and life circumstances.
"""
diff --git a/tracex_project/patient_journey_generator/templates/journey_generator_overview.html b/tracex_project/patient_journey_generator/templates/journey_generator_overview.html
index c60d653d..fdd25b36 100644
--- a/tracex_project/patient_journey_generator/templates/journey_generator_overview.html
+++ b/tracex_project/patient_journey_generator/templates/journey_generator_overview.html
@@ -1,12 +1,12 @@
@@ -23,7 +23,7 @@
{% if generated_journey %}
-
Generated Journey
+
Generated Patient Journey
{{ generated_journey }}
{% else %}
@@ -60,7 +60,7 @@
Welcome to the Patient Journey Generator of TracEX
{% endif %}
- Generate New Patient Journey
+ Generate new Patient Journey
diff --git a/tracex_project/patient_journey_generator/views.py b/tracex_project/patient_journey_generator/views.py
index 364b4f5b..4d4647d8 100644
--- a/tracex_project/patient_journey_generator/views.py
+++ b/tracex_project/patient_journey_generator/views.py
@@ -1,9 +1,9 @@
"""
-Provide class-based views for the patient journey generator app.
+Provide class-based views for the Patient Journey generator app.
Views:
-JourneyGeneratorOverviewView -- View for the landing page of the patient journey generator.
-JourneyGenerationView -- View to inspect the generated patient journey.
+JourneyGeneratorOverviewView -- View for the landing page of the Patient Journey generator.
+JourneyGenerationView -- View to inspect the generated Patient Journey.
"""
import traceback
@@ -18,9 +18,9 @@
class JourneyGeneratorOverviewView(generic.CreateView):
"""
- View for the landing page of the patient journey generator.
+ View for the landing page of the Patient Journey generator.
- If a generated patient journey exists in the session, this view displays a form to name the patient journey
+ If a generated Patient Journey exists in the session, this view displays a form to name the Patient Journey
and save it in the database.
"""
@@ -29,14 +29,14 @@ class JourneyGeneratorOverviewView(generic.CreateView):
success_url = reverse_lazy("journey_filter")
def get_context_data(self, **kwargs):
- """Add the patient journey to the context to pass to the HTML file."""
+ """Add the Patient Journey to the context to pass to the HTML file."""
context = super().get_context_data(**kwargs)
context["generated_journey"] = self.request.session.get("generated_journey")
return context
def form_valid(self, form):
- """Create an empty patient journey instance and save the ID in the orchestrator."""
+ """Create an empty Patient Journey instance and save the ID in the orchestrator."""
orchestrator = Orchestrator.get_instance()
form.instance.patient_journey = orchestrator.get_configuration().patient_journey
response = super().form_valid(form)
@@ -47,9 +47,9 @@ def form_valid(self, form):
class JourneyGenerationView(generic.RedirectView):
"""
- View to inspect the generated patient journey.
+ View to inspect the generated Patient Journey.
- By passing a GET request to the view, a patient journey is generated and saved in the orchestrator's configuration.
+ By passing a GET request to the view, a Patient Journey is generated and saved in the orchestrator's configuration.
Since the JourneyGenerationView is a RedirectView, the user is redirected back to the JourneyGeneratorOverviewView.
Therefore, this view does not render a template.
"""
@@ -58,17 +58,19 @@ class JourneyGenerationView(generic.RedirectView):
def get(self, request, *args, **kwargs):
"""
- Handle GET requests by generating a patient journey and updating the orchestrator's configuration.
+ Handle GET requests by generating a Patient Journey and updating the orchestrator's configuration.
- The empty patient journey instance from the orchestrator's configuration is modified to contain the generated
- patient journey text. The generated patient journey is also saved in the session to pass to the HTML file
+ The empty Patient Journey instance from the orchestrator's configuration is modified to contain the generated
+ Patient Journey text. The generated Patient Journey is also saved in the session to pass to the HTML file
of the JourneyGenerationOverviewView.
"""
orchestrator = Orchestrator()
try:
- configuration = ExtractionConfiguration(patient_journey=generate_patient_journey())
+ configuration = ExtractionConfiguration(
+ patient_journey=generate_patient_journey()
+ )
except Exception as e: # pylint: disable=broad-except
orchestrator.reset_instance()
self.request.session.flush()
@@ -76,10 +78,15 @@ def get(self, request, *args, **kwargs):
return render(
self.request,
"error_page.html",
- {"error_type": type(e).__name__, "error_traceback": traceback.format_exc()}
+ {
+ "error_type": type(e).__name__,
+ "error_traceback": traceback.format_exc(),
+ },
)
orchestrator.set_configuration(configuration)
- request.session["generated_journey"] = orchestrator.get_configuration().patient_journey
+ request.session[
+ "generated_journey"
+ ] = orchestrator.get_configuration().patient_journey
return super().get(request, *args, **kwargs)
diff --git a/tracex_project/trace_comparator/forms.py b/tracex_project/trace_comparator/forms.py
index 955297b6..df8cb18f 100644
--- a/tracex_project/trace_comparator/forms.py
+++ b/tracex_project/trace_comparator/forms.py
@@ -6,9 +6,11 @@
class PatientJourneySelectForm(forms.Form):
- """Form for selecting a patient journey to use in the trace testing environment."""
+ """Form for selecting a Patient Journey to use in the trace testing environment."""
- selected_patient_journey = forms.ChoiceField(choices=[])
+ selected_patient_journey = forms.ChoiceField(
+ choices=[], label="Selected Patient Journey:"
+ )
def __init__(self, *args, **kwargs):
"""Initializes the PatientJourneySelectForm with available choices."""
@@ -19,7 +21,7 @@ def __init__(self, *args, **kwargs):
@staticmethod
def get_patient_journey_choices() -> List[Tuple[str, str]]:
- """Retrieves the available patient journey choices from the database. Available choices are those with a
+ """Retrieves the available Patient Journey choices from the database. Available choices are those with a
saved ground truth."""
patient_journeys = PatientJourney.manager.filter(
name__contains="journey_comparison_"
diff --git a/tracex_project/trace_comparator/migrations/__init__.py b/tracex_project/trace_comparator/migrations/__init__.py
deleted file mode 100644
index e69de29b..00000000
diff --git a/tracex_project/trace_comparator/templates/testing_overview.html b/tracex_project/trace_comparator/templates/testing_overview.html
index 2acb1e3b..e26983b7 100644
--- a/tracex_project/trace_comparator/templates/testing_overview.html
+++ b/tracex_project/trace_comparator/templates/testing_overview.html
@@ -9,7 +9,7 @@
Welcome to the Trace Testing Environment
The Trace Testing Environment is a tool that enables you to assess the effectiveness of your current prompts by comparing the results of the extraction pipeline against a manually created trace, which serves as a predefined groundtruth.
- Please select one patient journey as ground truth to compare it against the extraction pipeline result.
+ Please select one Patient Journey as ground truth to compare it against the extraction pipeline result.