<?php

namespace RxConnexionBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Doctrine\Common\Persistence\ObjectManager;
use RxConnexionBundle\Form\DataTransformer\DataTransformer;

class PatientChartTypeMethodForm extends AbstractType
{
    private $manager;

    public function __construct(ObjectManager $manager) {
        $this->manager = $manager;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('id', HiddenType::class)
            ->add('note', TextareaType::class, array(
                'required' => false,
                'attr' => array(
                    'rows' => 5
                )
            ))
            ->add('pressureRangeFrom', TextType::class, array(
                'required' => false
            ))
            ->add('pressureRangeTo', TextType::class, array(
                'required' => false
            ))
            ->add('currentAHI', TextType::class, array(
                'required' => false
            ))
            ->add('currentRDI', TextType::class, array(
                'required' => false
            ))
            ->add('averageCPAPUsage', TextType::class, array(
                'required' => false
            ))
            ->add('maskLeak', TextType::class, array(
                'required' => false
            ))
            ->add('lastDeviceReplaced', TextType::class, array(
                'required' => false
            ))
            ->add('neckSize', TextType::class, array(
                'required' => false
            ))
            ->add('ess', TextType::class, array(
                'required' => false
            ))
            ->add('initialBerlinQuestionnaireScore', TextType::class, array(
                'required' => false
            ))
            ->add('initialEpworthSleepnessScale', TextType::class, array(
                'required' => false
            ))
            ->add('initialAhi', TextType::class, array(
                'required' => false
            ))
            ->add('initialRdi', TextType::class, array(
                'required' => false
            ))
            ->add('timeNinetyPercentSpotwo', TextType::class, array(
                'required' => false
            ))
            ->add('initialMeanSpotwo', TextType::class, array(
                'required' => false
            ))
            ->add('chart_type_method', HiddenType::class);


        $builder->get('chart_type_method')->addModelTransformer(new DataTransformer($this->manager, 'RxConnexionBundle:ChartTypeMethodEntity', false));
    }

    public function getBlockPrefix()
    {
        return 'patientChartTypeMethod';
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' 	  => 'RxConnexionBundle\Entity\PatientChartTypeMethodEntity'
        ));
    }
}