public function parteDiario() { $salida = []; $params = Input::all(); $coes = CentroOdontologoEspecialidad::where('odontologo_id', $params['odontologo_id'])->where('centro_id', $params['centro_id'])->where('especialidad_id', $params['especialidad_id'])->get(); foreach ($coes as $coe) { //$agendas = $coe->agendas()->where('habilitado_turnos','=',1)->where('fecha','=',$params["fecha"])->get(); $agendas = $coe->agendas()->where('fecha', '=', $params["fecha"])->get(); foreach ($agendas as $agenda) { $turnos = $agenda->vistaTurnos(); foreach ($turnos as $t) { $pp = PacientePrepaga::find($t->paciente_prepaga_id); $tt = Turno::find($t->id); $trata = $tt->tratamientos()->get(); if (!empty($pp)) { $t->fecha_agenda = $agenda->fecha; $t->tiene_fichados = $pp->paciente->tieneFichados() > 0; $ver_queja = $pp->paciente->getPresentoQuejaAttribute(); $t->presento_queja = $ver_queja == "1" ? "S" : "N"; //$t->presento_queja = $pp->paciente->getPresentoQuejaAttribute(); // Este Va $ver_hiv = $pp->paciente->getTieneHivAttribute(); $t->hiv = $ver_hiv == "1" ? "S" : "N"; $t->edad = $pp->paciente->getEdadAttribute(); $t->presupuestos_con_saldo = $pp->presupuestosConSaldo(); $t->facturas_con_saldo = $pp->facturasConSaldo(); $t->es_vip = $pp->paciente->vip ? "S" : "N"; $t->cant_tratam = count($trata); } else { $t->fecha_agenda = $agenda->fecha; $t->tiene_fichados = False; $t->presento_queja = NULL; $t->hiv = NULL; $t->edad = NULL; $t->presupuestos_con_saldo = False; $t->facturas_con_saldo = False; $t->es_vip = NULL; $t->cant_tratam = 0; } $salida[] = $t; } } } return Response::json(array('error' => false, 'listado' => $salida), 200); }