Skip to content

Add vitals fields to registration - #183

Merged
noahseethorcodes merged 3 commits into
devfrom
AddTemperatureToRegistration
Dec 10, 2025
Merged

noahseethorcodes merged 3 commits into
devfrom
AddTemperatureToRegistration

Conversation

@naa-siuuuu-ff

Copy link
Copy Markdown
Contributor

✨ Feature: Integrate Initial Vitals (Temperature) via Transactional Workflow

Description

This pull request refactors the patient creation process into a robust, atomic transaction to ensure data integrity across multiple models.

The primary goal is to successfully capture the initial Temperature reading provided during registration. This is achieved by creating a three-step chained workflow: Patient $\rightarrow$ Visit $\rightarrow$ Vitals.

This PR also made creating vitals more efficient by doing it in the backend, instead of the previous method of sending another API to the frontend, then another api to the backend to create vitals when a patient was created.

Key Changes and Implementation Details

  • Transactional Service Function: Introduced @transaction.atomic on the new create_patient_with_temperature service function (likely in api/services/patient_service.py or similar) to guarantee that either the Patient, Visit, and Vitals records are all created successfully, or none are.
  • Multi-Model Chaining:
    1. A new Patient record is created.
    2. An initial Visit record is immediately created for the new patient with a status of 'started'.
    3. If the temperature field exists in the form data, a new Vitals record is created using the dedicated VitalsSerializer and is correctly linked to the newly created Visit.
  • View Update: The PatientView.post method is updated to utilize this new transactional function.

How to Test

  1. Use the frontend patient registration form and include the Temperature value.
  2. Submit the form.
  3. Verify that three database records were created successfully and are linked:
    • A new Patient entry.
    • A new Visit entry (linked to the Patient).
    • A new Vitals entry (linked to the Visit, containing the correct Temperature).
  4. (Optional): Test submitting the form without the temperature field to confirm only the Patient and Visit are created.

Related Issue: [Link to JIRA/Trello ticket, if applicable]

@noahseethorcodes
noahseethorcodes force-pushed the AddTemperatureToRegistration branch from 0b56e46 to 25e325b Compare December 10, 2025 00:29
@noahseethorcodes noahseethorcodes changed the title Enable registration temperature pass to vitals Add vitals field to registration Dec 10, 2025
@noahseethorcodes noahseethorcodes changed the title Add vitals field to registration Add vitals fields to registration Dec 10, 2025
@noahseethorcodes

Copy link
Copy Markdown
Contributor

added child fields (e.g. pallor, scoliosis) as well

@noahseethorcodes
noahseethorcodes merged commit 8081088 into dev Dec 10, 2025
0 of 2 checks passed
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.

2 participants