from typing import Optional

from fastapi import Form

from src.model.request.request_base_model import RequestBaseModel


class UltmarcDoctorSearchModel(RequestBaseModel):
    dcf_pcf_dr_cd: Optional[str]
    dr_name: Optional[str]
    dr_name_kana: Optional[str]
    dcf_dsf_inst_cd: Optional[str]
    form_inst_name_kanji: Optional[str]
    form_inst_name_kana: Optional[str]
    prefc_cd: Optional[str]
    blng_sec_name: Optional[str]
    trt_course_name: Optional[str]
    alma: Optional[str]
    grad_y: Optional[str]
    pagination_page_number: Optional[int]

    @classmethod
    def as_form(
        cls,
        ctrl_dcf_pcf_dr_cd: str = Form(None),
        ctrl_dr_name: str = Form(None),
        ctrl_dr_name_kana: str = Form(None),
        ctrl_dcf_dsf_inst_cd: str = Form(None),
        ctrl_form_inst_name_kanji: str = Form(None),
        ctrl_form_inst_name_kana: str = Form(None),
        ctrl_prefc_cd: str = Form(None),
        ctrl_blng_sec_name: str = Form(None),
        ctrl_trt_course_name: str = Form(None),
        ctrl_alma: str = Form(None),
        ctrl_grad_y: str = Form(None),
        pagination_page_number: str = Form(None)
    ):

        return cls(
            dcf_pcf_dr_cd=ctrl_dcf_pcf_dr_cd,
            dr_name=ctrl_dr_name,
            dr_name_kana=ctrl_dr_name_kana,
            dcf_dsf_inst_cd=ctrl_dcf_dsf_inst_cd,
            form_inst_name_kanji=ctrl_form_inst_name_kanji,
            form_inst_name_kana=ctrl_form_inst_name_kana,
            prefc_cd=ctrl_prefc_cd,
            blng_sec_name=ctrl_blng_sec_name,
            trt_course_name=ctrl_trt_course_name,
            alma=ctrl_alma,
            grad_y=ctrl_grad_y,
            pagination_page_number=pagination_page_number
        )


class UltmarcDoctorInfoModel(RequestBaseModel):
    doc_id: Optional[str]
    page_num: Optional[int]

    @classmethod
    def as_form(
        cls,
        doc_id: str = Form(None),
        page_num: str = Form(None)
    ):

        return cls(
            doc_id=doc_id,
            page_num=int(page_num)
        )
