Skip to content

refactor: MedicalAppointments CRUD operations#249

Merged
lethib merged 5 commits into
mainfrom
refactor/CRUD-operations
Jul 5, 2026
Merged

refactor: MedicalAppointments CRUD operations#249
lethib merged 5 commits into
mainfrom
refactor/CRUD-operations

Conversation

@lethib

@lethib lethib commented Jul 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

@lethib lethib self-assigned this Jul 3, 2026
@lethib lethib linked an issue Jul 3, 2026 that may be closed by this pull request
@claude

claude Bot commented Jul 3, 2026

Copy link
Copy Markdown

Claude finished @lethib's task in 3m 50s —— View job


Review of PR #249 — MedicalAppointments CRUD operations

Tasks

  • Gather context (diff, changed files)
  • Review code quality, security, performance
  • Review test coverage
  • Post inline comments for actionable findings
  • Summarize review

Summary

This is a mechanical refactor migrating MedicalAppointments, CompanyInterventions, and PractitionerCompanies CRUD off model-level create/update_from_params methods onto a new ActiveModel::builder() / ActiveModelEx pattern (from the sea-ORM v2 #[sea_orm::model] codegen), with the params structs and validation logic relocated into new src/services/* modules. Authorization checks, validation rules (VAT values, address validation, email format), and trimming behavior are all preserved — I didn't find behavioral regressions or security issues.

Two inline comments posted with actionable feedback:

  1. src/controllers/patient.rs (generate_invoice, ~L141-151) — this call site wasn't migrated to the new builder pattern like its sibling in medical_appointment.rs; it still builds the ActiveModel manually with raw ActiveValue::Set(...). Worth converting for consistency.
  2. src/services/practitioner_companies.rs (~L22-53) — the address-validation logic that used to live in a single shared validate_address_params helper is now duplicated verbatim in both create and update. company_interventions.rs kept its equivalent validate_vat_values as a shared function in the same PR, so this is an inconsistency worth fixing.

Note: I was unable to run cargo check/cargo test or git fetch in this sandbox (Bash commands required approval that wasn't available in this automated context), so this review is based on static reading of the full diff and surrounding code only. If you'd like compilation/test verification, please update --allowedTools to permit cargo and git fetch.

Comment thread src/controllers/patient.rs Outdated
Comment on lines +141 to +151
MedicalAppointments {
date: ActiveValue::Set(NaiveDate::parse_from_str(&params.invoice_params.date, "%Y-%m-%d")?),
practitioner_office_id: ActiveValue::Set(params.invoice_params.office_id),
price_in_cents: ActiveValue::Set((params.invoice_params.amount * 100.0).round() as i32),
user_id: ActiveValue::Set(ctx.current_user.id),
patient_id: ActiveValue::Set(patient_id),
payment_method: ActiveValue::Set(params.payment_method),
..Default::default()
}
.insert(&ctx.db)
.await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call site still constructs the ActiveModel manually with raw ActiveValue::Set(...) fields, while the sibling create/update in src/controllers/medical_appointment.rs were migrated to the new medical_appointments::ActiveModel::builder() pattern in this same PR. For consistency (and to drop the now-unused ActiveModel as MedicalAppointments / ActiveValue imports), consider:

medical_appointments::ActiveModel::builder()
  .set_date(NaiveDate::parse_from_str(&params.invoice_params.date, "%Y-%m-%d")?)
  .set_practitioner_office_id(params.invoice_params.office_id)
  .set_price_in_cents((params.invoice_params.amount * 100.0).round() as i32)
  .set_user_id(ctx.current_user.id)
  .set_patient_id(patient_id)
  .set_payment_method(params.payment_method)
  .insert(&ctx.db)
  .await?;

Fix this →

Comment thread src/services/practitioner_companies.rs
@lethib
lethib merged commit 7a3496e into main Jul 5, 2026
4 checks passed
@lethib
lethib deleted the refactor/CRUD-operations branch July 5, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor CRUD operations

1 participant