diff --git a/backend/dps_training_k/configuration/config.py b/backend/dps_training_k/configuration/config.py index 67a1bf33..d49928da 100644 --- a/backend/dps_training_k/configuration/config.py +++ b/backend/dps_training_k/configuration/config.py @@ -4,3 +4,4 @@ CODE_LENGTH = 6 INVITATION_LOGIC = LevenshteinCode(CODE_LENGTH) CURRENT_TIME = lambda: timezone.now() +DEFAULT_STATE_ID = 101 diff --git a/backend/dps_training_k/configuration/settings.py b/backend/dps_training_k/configuration/settings.py index d731ab07..c3bf5de5 100644 --- a/backend/dps_training_k/configuration/settings.py +++ b/backend/dps_training_k/configuration/settings.py @@ -50,7 +50,7 @@ "corsheaders", "game.apps.GameConfig", "helpers.apps.GameConfig", - "templates.apps.GameConfig", + "template.apps.TemplateConfig", "rest_framework", "rest_framework.authtoken", "django_celery_beat", diff --git a/backend/dps_training_k/game/consumers/abstract_consumer.py b/backend/dps_training_k/game/consumers/abstract_consumer.py index dda2147a..279aaa08 100644 --- a/backend/dps_training_k/game/consumers/abstract_consumer.py +++ b/backend/dps_training_k/game/consumers/abstract_consumer.py @@ -155,17 +155,17 @@ def authenticate(self, token): def _send_exercise(self): exercise = Exercise.createExercise() patient = Patient.objects.create( - name="Max Mustermann", exercise=exercise, patientCode=123456 + name="Max Mustermann", exercise=exercise, patientId=123456 ) exercise_object = { "exercise": { - "exerciseId": exercise.invitation_code, + "exerciseId": exercise.exerciseId, "areas": [ { "areaName": "X", "patients": [ { - "patientId": patient.patientCode, + "patientId": patient.patientId, "patientName": patient.name, "patientCode": 0 } @@ -176,10 +176,10 @@ def _send_exercise(self): "personnelName": "X" } ], - "devices": [ + "material": [ { - "deviceId": 0, - "deviceName": "X" + "materialId": 0, + "materialName": "X" } ] } diff --git a/backend/dps_training_k/game/consumers/patient_consumer.py b/backend/dps_training_k/game/consumers/patient_consumer.py index caabfc4a..67a26b29 100644 --- a/backend/dps_training_k/game/consumers/patient_consumer.py +++ b/backend/dps_training_k/game/consumers/patient_consumer.py @@ -1,15 +1,16 @@ from .abstract_consumer import AbstractConsumer from urllib.parse import parse_qs -from game.models import Exercise, Patient class PatientConsumer(AbstractConsumer): class PatientIncomingMessageTypes: EXAMPLE = "example" + TEST_PASSTHROUGH = "test-passthrough" class PatientOutgoingMessageTypes: RESPONSE = "response" EXERCISE = "exercise" + TEST_PASSTHROUGH = "test-passthrough" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -19,7 +20,10 @@ def __init__(self, *args, **kwargs): self.handle_example, "exercise_code", "patient_code", - ) + ), + self.PatientIncomingMessageTypes.TEST_PASSTHROUGH: ( + self.handle_test_passthrough, + ), } def connect(self): @@ -36,3 +40,9 @@ def handle_example(self, exercise_code, patient_code): self.PatientOutgoingMessageTypes.RESPONSE, content=f"exercise_code {self.exercise_code} & patient_code {self.patient_code}", ) + + def handle_test_passthrough(self): + self.send_event( + self.PatientOutgoingMessageTypes.TEST_PASSTHROUGH, + message="received test event", + ) diff --git a/backend/dps_training_k/game/consumers/trainer_consumer.py b/backend/dps_training_k/game/consumers/trainer_consumer.py index 6a594b7d..8c165f10 100644 --- a/backend/dps_training_k/game/consumers/trainer_consumer.py +++ b/backend/dps_training_k/game/consumers/trainer_consumer.py @@ -1,6 +1,4 @@ from .abstract_consumer import AbstractConsumer -from game.models import Exercise, Patient -from django.conf import settings class TrainerConsumer(AbstractConsumer): diff --git a/backend/dps_training_k/game/migrations/0005_rename_invitation_code_exercise_exerciseid_and_more.py b/backend/dps_training_k/game/migrations/0005_rename_invitation_code_exercise_exerciseid_and_more.py new file mode 100644 index 00000000..89e6b354 --- /dev/null +++ b/backend/dps_training_k/game/migrations/0005_rename_invitation_code_exercise_exerciseid_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.1 on 2024-03-22 10:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('game', '0004_remove_scheduledevent_owner_owner_event'), + ] + + operations = [ + migrations.RenameField( + model_name='exercise', + old_name='invitation_code', + new_name='exerciseId', + ), + migrations.RemoveField( + model_name='patient', + name='patientCode', + ), + migrations.AddField( + model_name='patient', + name='patientId', + field=models.IntegerField(default=1, help_text='patientId used to log into patient - therefore part of authentication'), + preserve_default=False, + ), + ] diff --git a/backend/dps_training_k/game/migrations/0007_merge_20240325_1625.py b/backend/dps_training_k/game/migrations/0007_merge_20240325_1625.py new file mode 100644 index 00000000..386388be --- /dev/null +++ b/backend/dps_training_k/game/migrations/0007_merge_20240325_1625.py @@ -0,0 +1,14 @@ +# Generated by Django 5.0.1 on 2024-03-25 16:25 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('game', '0005_rename_invitation_code_exercise_exerciseid_and_more'), + ('game', '0006_patient_stateid_delete_patientstate'), + ] + + operations = [ + ] diff --git a/backend/dps_training_k/game/models/exercise.py b/backend/dps_training_k/game/models/exercise.py index b27c3b7a..a989b97a 100644 --- a/backend/dps_training_k/game/models/exercise.py +++ b/backend/dps_training_k/game/models/exercise.py @@ -20,7 +20,7 @@ class ExerciseStateTypes(models.TextChoices): to="Trainer", on_delete=models.CASCADE, ) """ - invitation_code = models.CharField( + exerciseId = models.CharField( unique=True, editable=settings.DEBUG, max_length=settings.INVITATION_LOGIC.code_length, @@ -35,7 +35,7 @@ def createExercise(cls): new_Exercise = cls.objects.create( # config=settings.DEFAULT_EXCERCISE_CONFIG, # trainer=trainer - invitation_code=settings.INVITATION_LOGIC.get_invitation_code(), + exerciseId=settings.INVITATION_LOGIC.get_exerciseId(), state=cls.ExerciseStateTypes.CONFIGURATION, ) return new_Exercise diff --git a/backend/dps_training_k/game/models/patient.py b/backend/dps_training_k/game/models/patient.py index d6ea7295..19b72385 100644 --- a/backend/dps_training_k/game/models/patient.py +++ b/backend/dps_training_k/game/models/patient.py @@ -10,7 +10,7 @@ class Patient(Eventable, models.Model): name = models.CharField( max_length=100, default="Max Mustermann" ) # technically patientData but kept here for simplicity for now - # patientID = models.ForeignKey() # currently called "SensenID" + # patientCode = models.ForeignKey() # currently called "SensenID" exercise = models.ForeignKey("Exercise", on_delete=models.CASCADE) stateID = models.OneToOneField( "template.PatientState", @@ -19,12 +19,12 @@ class Patient(Eventable, models.Model): default=settings.DEFAULT_STATE_ID, ) # measureID = models.ManyToManyField() - patientCode = models.IntegerField( - help_text="patientCode used to log into patient - therefore part of authentication" + patientId = models.IntegerField( + help_text="patientId used to log into patient - therefore part of authentication" ) def __str__(self): - return f"Patient #{self.id} called {self.name} with code {self.patientCode}" + return f"Patient #{self.id} called {self.name} with ID {self.patientId}" # ToDo remove when actual method is implemented def schedule_temporary_event(self): diff --git a/backend/dps_training_k/game/tests/test_authentication_views.py b/backend/dps_training_k/game/tests/test_authentication_views.py index 148d6739..c5591586 100644 --- a/backend/dps_training_k/game/tests/test_authentication_views.py +++ b/backend/dps_training_k/game/tests/test_authentication_views.py @@ -17,7 +17,7 @@ def test_access_success(self): """ Test the access with correct credentials. """ - data = {"exerciseCode": "testuser", "patientCode": "testpassword"} + data = {"exerciseId": "testuser", "patientId": "testpassword"} response = self.client.post(self.access_url, data) self.assertEqual(response.status_code, status.HTTP_200_OK) # Check if the response contains a token @@ -27,7 +27,7 @@ def test_access_fail_wrong_credentials(self): """ Test the access with wrong credentials. """ - data = {"exerciseCode": "wronguser", "patientCode": "wrongpassword"} + data = {"exerciseId": "wronguser", "patientId": "wrongpassword"} response = self.client.post(self.access_url, data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) # Check that the response indicates a failure @@ -39,8 +39,8 @@ def test_access_fail_missing_fields(self): Test the access with missing fields. """ data = { - "exerciseCode": "testuser" - # Missing "patientCode" + "exerciseId": "testuser" + # Missing "patientId" } response = self.client.post(self.access_url, data) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) diff --git a/backend/dps_training_k/game/views.py b/backend/dps_training_k/game/views.py index 2af3de95..5c8335d7 100644 --- a/backend/dps_training_k/game/views.py +++ b/backend/dps_training_k/game/views.py @@ -7,13 +7,13 @@ class PatientAccessView(APIView): def post(self, request, *args, **kwargs): - if not (request.data.get("exerciseCode") and request.data.get("patientCode")): + if not (request.data.get("exerciseId") and request.data.get("patientId")): return Response( status=status.HTTP_400_BAD_REQUEST, data="Some required fields are missing", ) - exercise_code = request.data.get("exerciseCode") - patient_code = request.data.get("patientCode") + exercise_code = request.data.get("exerciseId") + patient_code = request.data.get("patientId") user = authenticate(username=exercise_code, password=patient_code) if user: token, created = Token.objects.get_or_create(user=user) diff --git a/backend/dps_training_k/helpers/invitation_logic.py b/backend/dps_training_k/helpers/invitation_logic.py index d2fe9dc9..8aa46da0 100644 --- a/backend/dps_training_k/helpers/invitation_logic.py +++ b/backend/dps_training_k/helpers/invitation_logic.py @@ -8,11 +8,11 @@ def __init__(self, code_length): self.code_length = code_length self.codes_taken = [] - def get_invitation_code(self): + def get_exerciseId(self): """ - Generates an unique alphabetic invitation_code of length self.code_length, + Generates an unique alphabetic exerciseId of length self.code_length, that is also distinctive from other non-finished excercises (levenshtein distance >= 3). - :return: a string, the invitation_code + :return: a string, the exerciseId """ new_code = None letters = string.ascii_lowercase diff --git a/frontend/src/assets/main.css b/frontend/src/assets/main.css index 80f2b099..3219db32 100644 --- a/frontend/src/assets/main.css +++ b/frontend/src/assets/main.css @@ -1,5 +1,12 @@ @import './base.css'; +:root { + --red: #ee4035; + --yellow: #e6cf00; + --green: #269f42; + --gray: gray; +} + #app { height: 100vh; font-weight: normal; @@ -20,4 +27,21 @@ button:hover { button:active { cursor: pointer; filter: brightness(90%); -} \ No newline at end of file +} + +.gray { + background-color: var(--gray); +} + +.red { + background-color: var(--red); +} + +.yellow { + background-color: var(--yellow); +} + +.green { + background-color: var(--green); +} + diff --git a/frontend/src/components/screensPatient/ScreenInactive.vue b/frontend/src/components/screensPatient/ScreenInactive.vue index 5fa2bf33..91d173ee 100644 --- a/frontend/src/components/screensPatient/ScreenInactive.vue +++ b/frontend/src/components/screensPatient/ScreenInactive.vue @@ -11,7 +11,7 @@ Patient inaktiv
-
Patient: {{ patientStore.patientName }} | {{ patientStore.patientID }}
+
Patient: {{ patientStore.patientName }} | {{ patientStore.patientId }}
Bereich: {{ patientStore.areaName }}
diff --git a/frontend/src/components/screensPatient/ScreenStatus.vue b/frontend/src/components/screensPatient/ScreenStatus.vue index a027f733..31a0f76e 100644 --- a/frontend/src/components/screensPatient/ScreenStatus.vue +++ b/frontend/src/components/screensPatient/ScreenStatus.vue @@ -1,37 +1,25 @@ \ No newline at end of file diff --git a/frontend/src/components/screensTrainer/pagesResourceCreation/PagePatients.vue b/frontend/src/components/screensTrainer/pagesResourceCreation/PagePatients.vue index 99d30288..96bf9826 100644 --- a/frontend/src/components/screensTrainer/pagesResourceCreation/PagePatients.vue +++ b/frontend/src/components/screensTrainer/pagesResourceCreation/PagePatients.vue @@ -1,3 +1,120 @@ + + \ No newline at end of file + + +
+
+ + +
+ +
+ + + \ No newline at end of file diff --git a/frontend/src/components/screensTrainer/pagesResourceCreation/PagePersonnel.vue b/frontend/src/components/screensTrainer/pagesResourceCreation/PagePersonnel.vue index 7ce39729..5703321b 100644 --- a/frontend/src/components/screensTrainer/pagesResourceCreation/PagePersonnel.vue +++ b/frontend/src/components/screensTrainer/pagesResourceCreation/PagePersonnel.vue @@ -1,3 +1,23 @@ + + \ No newline at end of file +

Patienten

+ {{ currentAreaData?.personnel }} + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/AddPatientPopup.vue b/frontend/src/components/widgets/AddPatientPopup.vue new file mode 100644 index 00000000..dcc7d45e --- /dev/null +++ b/frontend/src/components/widgets/AddPatientPopup.vue @@ -0,0 +1,156 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/ButtonMainAction.vue b/frontend/src/components/widgets/ButtonMainAction.vue index 26f42b2d..3915d95c 100644 --- a/frontend/src/components/widgets/ButtonMainAction.vue +++ b/frontend/src/components/widgets/ButtonMainAction.vue @@ -24,17 +24,12 @@ background-color: #FFFFFF; border: 1px solid rgb(209, 213, 219); border-radius: .5rem; - box-sizing: border-box; - display: block; width: calc(100% - 2rem); - color: #111827; font-size: 1.25rem; line-height: 1.25rem; padding: .75rem 1rem; margin: 1rem; text-align: center; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); - cursor: pointer; - vertical-align: bottom; } \ No newline at end of file diff --git a/frontend/src/components/widgets/EditPatientPopup.vue b/frontend/src/components/widgets/EditPatientPopup.vue new file mode 100644 index 00000000..15a4db03 --- /dev/null +++ b/frontend/src/components/widgets/EditPatientPopup.vue @@ -0,0 +1,164 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/LoginPatient.vue b/frontend/src/components/widgets/LoginPatient.vue index 0ed78f77..e3d49c01 100644 --- a/frontend/src/components/widgets/LoginPatient.vue +++ b/frontend/src/components/widgets/LoginPatient.vue @@ -18,7 +18,7 @@ return } - patientStore.patientID = patientIdNumber + patientStore.patientId = patientIdNumber const requestBody = { "exerciseId": exerciseIdNumber, diff --git a/frontend/src/components/widgets/PatientCodeList.vue b/frontend/src/components/widgets/PatientCodeList.vue new file mode 100644 index 00000000..d20c8334 --- /dev/null +++ b/frontend/src/components/widgets/PatientCodeList.vue @@ -0,0 +1,47 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/PatientInfo.vue b/frontend/src/components/widgets/PatientInfo.vue new file mode 100644 index 00000000..eb289c53 --- /dev/null +++ b/frontend/src/components/widgets/PatientInfo.vue @@ -0,0 +1,46 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/ToggleSwitchForListItems.vue b/frontend/src/components/widgets/ToggleSwitchForListItems.vue new file mode 100644 index 00000000..bd3f2b14 --- /dev/null +++ b/frontend/src/components/widgets/ToggleSwitchForListItems.vue @@ -0,0 +1,66 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/widgets/TriageForListItems.vue b/frontend/src/components/widgets/TriageForListItems.vue new file mode 100644 index 00000000..a0ab41e5 --- /dev/null +++ b/frontend/src/components/widgets/TriageForListItems.vue @@ -0,0 +1,38 @@ + + + + +@/Utils@/utils \ No newline at end of file diff --git a/frontend/src/components/widgets/TriagePopup.vue b/frontend/src/components/widgets/TriagePopup.vue index a0e985f0..6a5b44a0 100644 --- a/frontend/src/components/widgets/TriagePopup.vue +++ b/frontend/src/components/widgets/TriagePopup.vue @@ -1,12 +1,10 @@