<?php

namespace App\Services;

use App\Services\Service;
use App\Services\ServiceResponse\ServiceResponse;
use App\DAO\AnamneseDAO;
use App\ViewModels\Anamnese\AnamneseAdicionalRegistrationViewModel\AnamneseAdicionalRegistrationViewModel;
use App\Mappers\AnamneseAdicionalMapper;

class AnamneseService extends Service {

	public function newAnamneseAdicional(array $request): ServiceResponse {

		$obj_register = AnamneseAdicionalMapper::getAnamneseAdicionalRegistrationFromArrayPost( $request );
		$service_response = new ServiceResponse();
		$dao = new AnamneseDAO();
		$dao_response = $dao->newAnamneseAdicional( $obj_register );
		$service_response = $this->setServiceResponse( $dao_response );

		return $service_response;

	}

	public function saveAnamneseAdicional(array $request): ServiceResponse {

		$service_response = new ServiceResponse();
		$consultaService = new ConsultaService();
		$service_response = $consultaService->registerConsultaAnamneseAdicional( $request );

		return $service_response;

	}

	public function newAnamneseRetroativa(array $request): ServiceResponse {

		$service_response = new ServiceResponse();
		$dao = new AnamneseDAO();
		return $service_response;

	}

	public function newAnamneseAdicionalValid(array $request): bool {

		if (!(intval( $request ['idPet'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idTutor'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idUnidade'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idProcedimento'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idFormulario'] ) > 0)) {
			return false;
		}
		return true;

	}
	
	public function newAnamneseRetroativaValid(array $request): bool {
		
		if (!(intval( $request ['idPet'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idTutor'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idUnidade'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idProcedimento'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idFormulario'] ) > 0)) {
			return false;
		}
		if (!(intval( $request ['idFormulario'] ) > 0)) {
			return false;
		}
		if (!(strlen(trim( $request ['dataAnamnese'] )) != 10)) {
			return false;
		}
		if (!(strlen(trim( $request ['horaAnamnese'] )) != 8)) {
			return false;
		}
		return true;
		
	}

}

