Skip to content

Commit

Permalink
Merge pull request #151 from swiftss-org/feature/episode-comment
Browse files Browse the repository at this point in the history
Feature/episode comment
  • Loading branch information
szigyi authored Mar 29, 2024
2 parents f372451 + 68ea5c3 commit b690275
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Run one test:
make test-one file=tmh_registry/registry/tests/api/viewsets/test_discharges.py test_name=TestDischargeCreate
```

Run checks before committing:
```shell
make pre-commit
```

Everything you need for this project is under [Makefile](./Makefile). Take a look at the commands by running `make`.

### Create a local user in Django
Expand Down
7 changes: 7 additions & 0 deletions tmh_registry/registry/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EpisodeSerializer(ModelSerializer):
complexity = CharField(source="get_complexity_display")
mesh_type = CharField(source="get_mesh_type_display")
anaesthetic_type = CharField(source="get_anaesthetic_type_display")
comments = CharField()

class Meta:
model = Episode
Expand All @@ -53,6 +54,7 @@ class Meta:
"diathermy_used",
"antibiotic_used",
"antibiotic_type",
"comments",
]


Expand Down Expand Up @@ -320,6 +322,7 @@ class EpisodeReadSerializer(ModelSerializer):
mesh_type = CharField(source="get_mesh_type_display")
anaesthetic_type = CharField(source="get_anaesthetic_type_display")
antibiotic_type = CharField()
comments = CharField()

class Meta:
model = Episode
Expand All @@ -341,6 +344,7 @@ class Meta:
"diathermy_used",
"antibiotic_used",
"antibiotic_type",
"comments",
]


Expand All @@ -364,6 +368,7 @@ class EpisodeWriteSerializer(ModelSerializer):
mesh_type = CharField()
anaesthetic_type = CharField()
antibiotic_type = CharField(required=False)
comments = CharField(required=False)

class Meta:
model = Episode
Expand All @@ -384,6 +389,7 @@ class Meta:
"diathermy_used",
"antibiotic_used",
"antibiotic_type",
"comments",
]

def to_representation(self, instance):
Expand Down Expand Up @@ -449,6 +455,7 @@ def create(self, validated_data):
diathermy_used=validated_data["diathermy_used"],
antibiotic_used=validated_data["antibiotic_used"],
antibiotic_type=validated_data.get("antibiotic_type", ""),
comments=validated_data.get("comments", ""),
)
except IndexError:
raise ValidationError(
Expand Down
18 changes: 18 additions & 0 deletions tmh_registry/registry/migrations/0035_episode_comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2024-02-28 22:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("registry", "0034_auto_20230808_0957"),
]

operations = [
migrations.AddField(
model_name="episode",
name="comments",
field=models.TextField(blank=True, null=True),
),
]
1 change: 1 addition & 0 deletions tmh_registry/registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class AnaestheticChoices(TextChoices):
diathermy_used = BooleanField()
antibiotic_used = BooleanField()
antibiotic_type = CharField(max_length=128, null=True, blank=True)
comments = TextField(null=True, blank=True)

def __str__(self):
return f"({self.episode_type}) {self.patient_hospital_mapping.patient.full_name}"
Expand Down

0 comments on commit b690275

Please sign in to comment.