/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.elotech.websaude.integracao.cnes.backend.controller;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import static br.com.elotech.websaude.integracao.cnes.backend.model.dao.Conexao.CONN;
/**
 *
 * @author elotech
 */
public class EspecialidadeController {

    int MEDICO_SAUDE_DA_FAMILIA = 1055;

    PreparedStatement pstmt;

    public int getEspecialidadePorCbo(String cbo) throws SQLException{
        pstmt = CONN.prepareStatement("SELECT esp_codigo FROM especialidade WHERE cod_cbo=?");
        pstmt.setString(1, cbo);
        System.out.println(pstmt);
        ResultSet rs = pstmt.executeQuery();

        if(rs.next()){
            return rs.getInt("esp_codigo");
        }

        return MEDICO_SAUDE_DA_FAMILIA;
    }

}
