<?php
require_once "../modelos/Dsm5.php";

$dsm5 = new Dsm5();

switch ($_GET["op"]) {
    case 'listar':
        $texto = isset($_GET['q']) ? $_GET['q'] : '';
        $rspta = $dsm5->listar($texto);
        $data = array();

        while ($reg = $rspta->fetch_object()) {
            $data[] = array(
                "id" => $reg->codigo . " - " . $reg->enfermedad,
                "text" => " [" . $reg->codigo . "] " . $reg->enfermedad,
                "categoria" => $reg->categoria,
                "enfermedad" => $reg->enfermedad,
                "codigo" => $reg->codigo
            );
        }
        echo json_encode($data);
        break;

    case 'mostrar':
        $id = $_POST["iddiagnostico_dsm5"];
        $rspta = $dsm5->mostrar($id);
        echo json_encode($rspta);
        break;
}
?>
