<MudStack class="pb-20 font-iranyekan">
    <BasePartDivider Index="8" Title="ظاهر کلی بیمار ( GA )" />
    <div class="grid mx-1 gap-2 grid-cols-1 md:grid-cols-2">
        @foreach (var item in VitalSigns)
        {
            <MudCard @onclick="()=>RemoveGeneralAppearance(item)" class="text-center">
                <MudCardContent>
                    <p class="font-extrabold text-gray-600 text-md">@item.Question</p>
                </MudCardContent>
            </MudCard>
        }
    </div>

    <div class="flex flex-row">
        <MudTextField @bind-Value="@_vitalSign" class="grow" T="string" Label="نام دارو مورد نظر" Variant="Variant.Outlined" />

        <MudButton Variant="Variant.Outlined" @onclick="AddGeneralAppearance" Color="Color.Info" IconSize="Size.Large" DisableElevation="false" class="mx-2 mt-1.5 mb-0.5 pt-2 text-4xl rounded-md">
            +
        </MudButton>
    </div>


    <BasePartDivider class="mt-9" Index="9" Title="مرور سیستماتیک ( ROS )" />
    @foreach (var item in ReviewOfSystems)
    {
        <MudPaper class="px-3 py-2 mx-1">

            <div class="flex flex-row">
                <div>
                    <p>@item.Question</p>
                    <div class="flex flex-row">
                        <MudPaper Elevation="0" Class="mx-1 mt-1 bg-gray-200 w-fit text-center rounded-full py-0.5 px-3 text-gray-800 text-xs">
                            معده
                        </MudPaper>
                        @if(true)
                        {
                            <MudPaper Elevation="0" Class="mx-1 mt-1 bg-gray-200 w-fit text-center rounded-full py-0.5 px-3 text-gray-800 text-xs">
                                Sign
                            </MudPaper>
                        }
                        @if (true)
                        {
                            <MudPaper Elevation="0" Class="mx-1 mt-1 bg-gray-200 w-fit text-center rounded-full py-0.5 px-3 text-gray-800 text-xs">
                                Symptom
                            </MudPaper>
                        }
                    </div>
                </div>
                <MudIconButton @onclick="()=>RemoveReviewOfSystems(item)" class="mr-auto" Color="Color.Error" Icon="@Icons.Material.Filled.Close" />
            </div>
        </MudPaper>
    }

    <MudTextField @bind-Value="@_reviewOfSystemTitle" class="grow" T="string" Label="علامت مورد نظر" Variant="Variant.Outlined" />
    <MudTextField @bind-Value="@_reviewOfSystemSystem" class="grow" T="string" Label="سیستم مورد نظر" Variant="Variant.Outlined" />
    <div class="flex flex-row">

        <MudCheckBox @bind-Checked="@_reviewOfSystemIsSign" Color="Color.Primary" UnCheckedColor="Color.Default" Size="Size.Large" T="bool"
                     class="my-auto" Label="Sign"></MudCheckBox>

        <MudCheckBox @bind-Checked="@_reviewOfSystemIsSymptom" Color="Color.Primary" UnCheckedColor="Color.Default" Size="Size.Large" T="bool"
                     class="my-auto" Label="Symptom"></MudCheckBox>

        <MudButton @onclick="AddReviewOfSystems" Variant="Variant.Outlined" Color="Color.Info" IconSize="Size.Large" DisableElevation="false"
                   class="mr-auto mt-1.5 mb-0.5 pt-2 text-4xl rounded-md">
            +
        </MudButton>
    </div>


</MudStack>
@code {

    private string _vitalSign = string.Empty;
    [Parameter]
    public List<MedicalHistoryQuestionSDto> VitalSigns { get; set; } = new();
    private void RemoveGeneralAppearance(MedicalHistoryQuestionSDto generalAppearance)
    {
        VitalSigns.Remove(generalAppearance);
    }
    private void AddGeneralAppearance()
    {
        VitalSigns.Add(new MedicalHistoryQuestionSDto
        {
            Question = _vitalSign,
            QuestionType = MedicalHistoryQuestionType.Selective,
            Part = MedicalHistoryPart.VitalSign
        });
        _vitalSign = string.Empty;
    }

    private string _reviewOfSystemTitle = string.Empty;
    private string _reviewOfSystemSystem = string.Empty;
    private bool _reviewOfSystemIsSign;
    private bool _reviewOfSystemIsSymptom;
    public List<MedicalHistoryQuestionSDto> ReviewOfSystems { get; set; } = new();
    private void RemoveReviewOfSystems(MedicalHistoryQuestionSDto review)
    {
        ReviewOfSystems.Remove(review);
    }
    private void AddReviewOfSystems()
    {
        // ReviewOfSystems.Add(new MedicalHistorySystemReview
        //     {
        //         Title = _reviewOfSystemTitle,
        //         IsSign = _reviewOfSystemIsSign,
        //         IsSymptom = _reviewOfSystemIsSymptom,
        //         System = _reviewOfSystemSystem
        //     });
        _reviewOfSystemTitle = string.Empty;
    }
}