Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix adding a child in the UI #161

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions project/npda/views/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def get_context_data(self, **kwargs):
pz_code = self.request.session.get("sibling_organisations", {}).get(
"pz_code", ""
)
organisation_ods_code = self.request.user.organisation_employer
organisation_ods_code = self.request.user.organisation_employers.first().ods_code
context = super().get_context_data(**kwargs)
context["title"] = f"Add New Child to {organisation_ods_code} ({pz_code})"
context["button_title"] = "Add New Child"
Expand All @@ -235,17 +235,17 @@ def form_valid(self, form: BaseForm) -> HttpResponse:
paediatric_diabetes_unit_pz_code=self.request.session.get(
"sibling_organisations", {}
).get("pz_code"),
organisation_ods_code=self.request.user.organisation_employer,
organisation_ods_code=self.request.user.organisation_employers.first().ods_code,
date_leaving_service=form.cleaned_data.get("date_leaving_service"),
reason_leaving_service=form.cleaned_data.get("reason_leaving_service"),
)
patient.site = site
patient.is_valid = True
patient.save()
# add patient to the latest audit cohort
if AuditCohort.objects.count() > 0:
new_first = AuditCohort.objects.order_by("-submission_date").first()
new_first.patients.add(patient)
patient.save()
return super().form_valid(form)


Expand Down
Loading