<commit_before><?php
namespace HealthCareAbroad\InstitutionBundle\Controller;

use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalProcedureType;
use HealthCareAbroad\InstitutionBundle\Event\InstitutionBundleEvents;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterStatus;
use HealthCareAbroad\InstitutionBundle\Event\InstitutionMedicalCenterEvents;
use HealthCareAbroad\InstitutionBundle\Event\CreateInstitutionMedicalCenterEvent;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenter;
use HealthCareAbroad\InstitutionBundle\Form\InstitutionMedicalCenterType;
use HealthCareAbroad\InstitutionBundle\Form\InstitutionMedicalProcedureTypeFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

/**
 * Purpose: Controller for Institution Medical Center (weh naa ko documentation)
 *
 *
 * TODO: these business rules should be moved to a service class
 *
 * A newly added MedicalCenter has status DRAFT and will have this status until
 * at least one procedure type is added to it. After which the status will change
 * to PENDING. A MedicalCenter with status PENDING should have at least one media
 * attached to it.
 *
 * Note: this spec needs to be verified with Hazel.
 *
 */
class MedicalCenterController extends InstitutionAwareController
{
    /**
     * Displays a list of of active institution medical centers.
     *
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction(Request $request)
    {
        $institutionRepository = $this->getDoctrine()->getRepository('InstitutionBundle:Institution');
        $institutionMedicalCenters = $institutionRepository->getActiveInstitutionMedicalCenters($this->institution);
        $draftInstitutionMedicalCenters = $institutionRepository->getDraftInstitutionMedicalCenters($this->institution);

        return $this->render('InstitutionBundle:MedicalCenter:index.html.twig', array(
            'institutionMedicalCenters' => $institutionMedicalCenters,
            'draftInstitutionMedicalCenters' => $draftInstitutionMedicalCenters
        ));
    }

    /**
     * This is the FIRST STEP when adding/updating a draft center.
     * Displays form for adding or editing draft institution medical centers.
     *
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_MEDICAL_CENTER')")
     *
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function addAction(Request $request)
    {
        $imcId = $request->get('imcId', 0);

        if ($imcId === 0) {
            $institutionMedicalCenter = new InstitutionMedicalCenter();
            $institutionMedicalCenter->setInstitution($this->institution);
        }
        else {
            $institutionMedicalCenter = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenter')->find($imcId);<commit_msg>removed reference to missing event class<commit_after><?php
namespace HealthCareAbroad\InstitutionBundle\Controller;

use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalProcedureType;
use HealthCareAbroad\InstitutionBundle\Event\InstitutionBundleEvents;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenterStatus;
use HealthCareAbroad\InstitutionBundle\Event\CreateInstitutionMedicalCenterEvent;
use HealthCareAbroad\InstitutionBundle\Entity\InstitutionMedicalCenter;
use HealthCareAbroad\InstitutionBundle\Form\InstitutionMedicalCenterType;
use HealthCareAbroad\InstitutionBundle\Form\InstitutionMedicalProcedureTypeFormType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

/**
 * Purpose: Controller for Institution Medical Center (weh naa ko documentation)
 *
 *
 * TODO: these business rules should be moved to a service class
 *
 * A newly added MedicalCenter has status DRAFT and will have this status until
 * at least one procedure type is added to it. After which the status will change
 * to PENDING. A MedicalCenter with status PENDING should have at least one media
 * attached to it.
 *
 * Note: this spec needs to be verified with Hazel.
 *
 */
class MedicalCenterController extends InstitutionAwareController
{
    /**
     * Displays a list of of active institution medical centers.
     *
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function indexAction(Request $request)
    {
        $institutionRepository = $this->getDoctrine()->getRepository('InstitutionBundle:Institution');
        $institutionMedicalCenters = $institutionRepository->getActiveInstitutionMedicalCenters($this->institution);

        return $this->render('InstitutionBundle:MedicalCenter:index.html.twig', array(
            'institutionMedicalCenters' => $institutionMedicalCenters
        ));
    }

    /**
     * This is the FIRST STEP when adding/updating a draft center.
     * Displays form for adding or editing draft institution medical centers.
     *
     * @PreAuthorize("hasAnyRole('SUPER_ADMIN', 'CAN_MANAGE_MEDICAL_CENTER')")
     *
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     */
    public function addAction(Request $request)
    {
        $imcId = $request->get('imcId', 0);

        if ($imcId === 0) {
            $institutionMedicalCenter = new InstitutionMedicalCenter();
            $institutionMedicalCenter->setInstitution($this->institution);
        }
        else {
            $institutionMedicalCenter = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenter')->find($imcId);
{'fraction_non_alphanumeric': 0.08494809688581315, 'fraction_numerical': 0.0006920415224913495, 'mean_word_length': 4.510962821734986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4629983', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1481, 'n_words': 354}