Skip to content

Commit

Permalink
🐛 fix bug with durations
Browse files Browse the repository at this point in the history
  • Loading branch information
PitButtchereit committed Jan 22, 2024
1 parent 4d287ea commit de4355c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ def __get_date():
"content": "Please give me one date between 01/01/2020 and 01/09/2023.",
}
]
country = u.query_gpt(messages=message, max_tokens=50, temperature=0.5)
return country
date = u.query_gpt(messages=message, max_tokens=50, temperature=0.5)
print(date)
return date

@staticmethod
def __get_life_circumstances(sex):
Expand Down
1 change: 0 additions & 1 deletion tracex/extraction/logic/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def generate_patient_journey(self):
module = self.configuration.modules["patient_journey_generation"]()
module.execute(self.data, self.configuration.patient_journey)
self.configuration.update(patient_journey=module.result)
return module.result

# Will be deleted when dataframes are implemented
@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions tracex/extraction/logic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_all_xes_output_path(
if not (is_test or is_extracted):
append_csv()
all_traces_xes_path = Conversion.create_xes(
CSV_ALL_TRACES, name=xes_name, key=activity_key
csv_file=CSV_ALL_TRACES, name=xes_name, key=activity_key
)
else:
all_traces_xes_path = (
Expand Down Expand Up @@ -112,9 +112,10 @@ def create_xes(csv_file, name, key):
dataframe["caseID"] = dataframe["caseID"].astype(str)
dataframe["start"] = pd.to_datetime(dataframe["start"])
dataframe["end"] = pd.to_datetime(dataframe["end"])
dataframe["duration"] = pd.to_timedelta(dataframe["duration"]) # Bug: When filters are applied from the JourneyGenerationView, there seems to be some type of "offset"
# Bug on 118: When filters are applied from the JourneyGenerationView, there seems to be some type of "offset"
# Hence I got the error "Could not convert 'Symptom Onset' to NumPy timedelta" when deselecting "Home" from
# This error does not appear when configuring filters in the ResultView
dataframe["duration"] = pd.to_timedelta(dataframe["duration"])
dataframe = dataframe.rename(
columns={
key: "concept:name",
Expand Down
27 changes: 14 additions & 13 deletions tracex/extraction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def redirect_to_selection(request):
return redirect("selection")


class SelectionView(generic.TemplateView):
"""View for selecting a patient journey."""

template_name = "selection.html"


class JourneyInputView(generic.FormView):
"""View for uploading a patient journey."""

Expand All @@ -47,12 +53,6 @@ def form_valid(self, form):
return super().form_valid(form)


class SelectionView(generic.TemplateView):
"""View for selecting a patient journey."""

template_name = "selection.html"


class JourneyGenerationView(generic.FormView):
"""View for generating a patient journey."""

Expand All @@ -69,11 +69,11 @@ def get_context_data(self, **kwargs):
if IS_TEST:
with open(str(utils.input_path / "journey_synth_covid_1.txt"), "r") as file:
journey = file.read()
orchestrator.configuration.update(patient_journey=journey)
else:
# This automatically updates the configuration with the generated patient journey
orchestrator.generate_patient_journey()
journey = orchestrator.configuration.patient_journey

orchestrator.configuration.update(patient_journey=journey) # In case of test mode off, this is already executed from generate_patient_journey()
context["generated_journey"] = orchestrator.configuration.patient_journey
return context

Expand All @@ -82,6 +82,7 @@ def form_valid(self, form):
cache.set("is_extracted", False)
orchestrator = Orchestrator.get_instance()
orchestrator.configuration.update(
patient_journey=orchestrator.configuration.patient_journey, # This should not be necessary, unspecefied values should be unchanged
event_types=form.cleaned_data["event_types"],
locations=form.cleaned_data["locations"],
)
Expand Down Expand Up @@ -159,11 +160,11 @@ def get_context_data(self, **kwargs):
def form_valid(self, form):
"""Save the filter settings in the cache."""
orchestrator = Orchestrator.get_instance()
configuration = {
"event_types": form.cleaned_data["event_types"],
"locations": form.cleaned_data["locations"],
}
orchestrator.configuration.update(**configuration)
orchestrator.configuration.update(
patient_journey=orchestrator.configuration.patient_journey, # This should not be necessary, unspecefied values should be unchanged
event_types=form.cleaned_data["event_types"],
locations=form.cleaned_data["locations"],
)
return super().form_valid(form)

@staticmethod
Expand Down

0 comments on commit de4355c

Please sign in to comment.