<MudStack class="pb-20 font-iranyekan">
    <BasePartDivider Index="9" Title="ظاهر کلی بیمار ( GA )" />

    <div class="grid grid-cols-2 gap-1 md:grid-cols-4 sm:grid-cols-2">
        @foreach (var question in GaQuestions)
        {
            <BaseMedicalQuestionTemplate Question="@question" AnswerChanged="GaAnswerChanged" />
        }

    </div>
    <MudTextField T="string"
                  Value="@GaDetail" ValueChanged="async detail => { GaDetail = detail; await GaDetailChanged.InvokeAsync(detail); }"
                  Label="توضیحاتـــ تکمیلی" Lines="2" Variant="Variant.Outlined" />


    <BasePartDivider Index="10" Title="علائم حیاتی ( VS )" />
    <div class="flex flex-row">
        <p class="my-auto mr-5 font-extrabold text-md grow">فشــــار خون</p>
        <MudTextField InputType="InputType.Number" Label="سیستولیک" Margin="Margin.Dense" class="mx-3 my-auto basis-1/12" T="string" Variant="Variant.Outlined" />
        <MudTextField InputType="InputType.Number" Label="دیاستولیک" Margin="Margin.Dense" class="my-auto basis-1/12" T="string" Variant="Variant.Outlined" />

        
    </div>
    <div class="grid grid-cols-3">
        
        <MudTextField InputType="InputType.Number" Margin="Margin.Dense" Label="نبض" T="string" Variant="Variant.Outlined" />
        
        <MudTextField InputType="InputType.Number" class="mx-2" Margin="Margin.Dense" Label="اکسیژن" T="string" Variant="Variant.Outlined" />
        
        <MudTextField InputType="InputType.Number" Margin="Margin.Dense" Label="دمای بدن" T="string" Variant="Variant.Outlined" />
    </div>


    <BasePartDivider Index="11" Title="بررسی سیستماتیک ( ROS )" />
    <div class="grid grid-cols-2 gap-1 md:grid-cols-4 sm:grid-cols-2">
        @foreach (var question in GaQuestions)
        {
            <BaseMedicalQuestionTemplate Question="@question" AnswerChanged="GaAnswerChanged" />
        }

    </div>
    <MudTextField T="string"
                  Value="@RosDetail" ValueChanged="async detail => { RosDetail = detail; await RosDetailChanged.InvokeAsync(detail); }"
                  Label="توضیحاتـــ تکمیلی" Lines="2" Variant="Variant.Outlined" />


</MudStack>
@code {


    [Parameter]
    public string RosDetail { get; set; } = string.Empty;

    [Parameter]
    public EventCallback<string> RosDetailChanged { get; set; }

    [Parameter]
    public List<MedicalHistoryAnswerSDto> GaAnswers { get; set; } = new();

    [Parameter]
    public List<MedicalHistoryQuestionSDto> GaQuestions { get; set; } = new();

    [Parameter]
    public string GaDetail { get; set; } = string.Empty;

    [Parameter]
    public EventCallback<string> GaDetailChanged { get; set; }

    private void GaAnswerChanged(MedicalHistoryAnswerSDto dto)
    {
        var findAnswer = GaAnswers.FirstOrDefault(pi => pi.Question == dto.Question && pi.Part == dto.Part);
        if (findAnswer != null)
            findAnswer.Answer = dto.Answer;
        else
            GaAnswers.Add(dto);
    }

    
    [Parameter]
    public int SystolicBloodPressure { get; set; }

    [Parameter]
    public EventCallback<int> SystolicBloodPressureChanged { get; set; }

    
    [Parameter]
    public int DiastolicBloodPressure { get; set; }

    [Parameter]
    public EventCallback<int> DiastolicBloodPressureChanged { get; set; }

    
    [Parameter]
    public int PulseRate { get; set; }

    [Parameter]
    public EventCallback<int> PulseRateChanged { get; set; }


    [Parameter]
    public int SPO2 { get; set; }

    [Parameter]
    public EventCallback<int> SPO2Changed { get; set; }


    [Parameter]
    public int Temperature { get; set; }

    [Parameter]
    public EventCallback<int> TemperatureChanged { get; set; }
}