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

Missing Patient class #415

Open
svenvanderburg opened this issue Dec 10, 2024 · 0 comments
Open

Missing Patient class #415

svenvanderburg opened this issue Dec 10, 2024 · 0 comments

Comments

@svenvanderburg
Copy link
Collaborator

svenvanderburg commented Dec 10, 2024

The extras episodes on persistence and databases assume a Patient class is in the inflammation project. This class was removed with the new section 3.

The test test_patient.py refers to a models.Patient class but it does not exist in models.py.

We could easily fix this by adding the Patient class back to models.py:

class Observation:
    def __init__(self, day, value):
        self.day = day
        self.value = value

    def __str__(self):
        return str(self.value)

class Patient:
    """A patient in an inflammation study."""
    def __init__(self, name):
        self.name = name
        self.observations = []

    def add_observation(self, value, day=None):
        if day is None:
            try:
                day = self.observations[-1].day + 1

            except IndexError:
                day = 0

        new_observation = Observation(day, value)

        self.observations.append(new_observation)
        return new_observation

    def __str__(self):
        return self.name
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

No branches or pull requests

1 participant