backend/med_backend/forms/schemas.py

81 lines
1.1 KiB
Python
Raw Normal View History

2022-12-09 02:33:22 +03:00
from typing import List
from pydantic import BaseModel
class Question(BaseModel):
id: int
type: str
question: str
class BaseFormField(BaseModel):
type: str
question: str
ref_min: int | None
ref_max: int | None
class CreateFormField(BaseFormField):
...
class FormField(BaseFormField):
id: int
class Config:
orm_mode = True
class QuestionRef(BaseModel):
id: int
ref_min: int | None
ref_max: int | None
class FormAssigment(BaseModel):
user_id: int
question_refs: List[QuestionRef]
2022-12-09 12:09:22 +03:00
class FormAnswer(BaseModel):
field_id: int
answer: str
class FullAnswer(BaseModel):
field_id: int
question: str
type: str
answer: str
ref_min: int | None
ref_max: int | None
class FullSubmission(BaseModel):
fio: str
answers: List[FullAnswer]
2022-12-09 02:33:22 +03:00
class BaseForm(BaseModel):
name: str
class FormCreate(BaseForm):
user_id: int
class ListForm(BaseForm):
id: int
class Config:
orm_mode = True
class Form(BaseForm):
id: int
questions: List[Question]
class Config:
orm_mode = True