如果resultset与整行值匹配,如何获取值



这里我附上了我的代码。如果stateVector包含statename,我只需要检查整行,而不是所有的icd和dicd向量值。我该怎么做?

在我的代码中,一旦状态名与任何其他或icdid匹配,它就会检查所有向量,这表明它是可用的。

public class LCDEdits 
{   
@SuppressWarnings("unchecked")
public String validateICD_CPT(String cptCode,  String stateName, String icdCode) throws Exception
{
    /**** Variable Initialization ***/
    String lcdRes = null;
    StringBuffer lcdSql = null;
//  String error = null;
    java.sql.Connection con = null;
    java.sql.PreparedStatement poStmt1 = null;      
    DBConfig db1 = null;
    ResultSet rs = null;
    JSONObject JObj = new JSONObject(); 
    try
    {
        lcdSql = new StringBuffer(" SELECT cpt.hcpc_code, cpt.lcd_id, statepri.state_abbr, icd.icd10_id, ");
        lcdSql.append(" dicd.icd10_id_dont FROM lcd_cpt cpt ");
        lcdSql.append(" LEFT JOIN lcd_statepri statepri ON(cpt.lcd_id = statepri.lcd_id) ");            
        //lcdSql.append(" LEFT JOIN lcd_statesec statesec ON( cpt.lcd_id = statesec.lcd_id) ");
        lcdSql.append(" LEFT JOIN lcd_icd_support icd ON( cpt.lcd_id = icd.lcd_id) ");
        lcdSql.append(" LEFT JOIN lcd_icd_dont_support dicd ON( cpt.lcd_id = dicd.lcd_id) ");
        lcdSql.append(" WHERE hcpc_code = ? ");
        db1 = new DBConfig();
        con = db1.openConn();
        poStmt1 = con.prepareStatement(lcdSql.toString());
        poStmt1.setString(1, cptCode);
        rs = poStmt1.executeQuery();                
        Vector<String> stateVector = new Vector<String>();
        Vector<String> icdVector = new Vector<String>();
        Vector<String> dicdVector = new Vector<String>();
        while(rs.next())
        {                   
            stateVector.add(rs.getString("state_abbr") );
        //  icdVector.add(rs.getString("icd10_id") );
        //  dicdVector.add(rs.getString("icd10_id_dont") ); 
            //stateVector.add(rs.getString("sec_state_abbr") );

        }

            if(stateVector.contains(stateName))
            {
                if(icdVector.contains(icdCode))
                {
                //  String lcd_icd = lcd_Id;
                    lcdRes = "CPT-Code is Available in LCD Database.";
                //  lcdRes1 = "As for the LCD-Code " +lcd_icd+ ", the CPT-Code " + cptCode + " is supported the Diagnosis " +icdCode+ " in the state of " +stateName+ ".";
                }
                else if(dicdVector.contains(icdCode))
                {   
                    lcdRes = "Medicare is not interest to pay Amount for this CPT-Code.";
                //  lcdRes1 = "As for the LCD-Code " +lcd_Id+ ", the CPT-Code " +cptCode+ " is not supported the Diagnosis " +icdCode+ " in the state of " +stateName+ ".";
                }
                else 
                {
                    lcdRes = "CPT-Code is not available in the LCD-Database.";  
                //  lcdRes1 = "As for the LCD-Code " +lcd_Id+ ", the CPT-Code " +cptCode+ " is not applicable for the Diagnosis " +icdCode+ " in the state of " +stateName+ ".";
                }
            }
            else 
            {
            //  String lcd_state = lcd_Id;
                lcdRes = "State not matched with LCD-Code.";
            //  lcdRes1 = "As for the LCD-Code " +lcd_state+ ", the CPT-Code " +cptCode+ " is not applicable in the state of " +stateName+ ".";
            }
        JObj.put("status", "success");
        JObj.put("res_msg", lcdRes);
    //  JObj.put("dis_msg", lcdRes1);
    }
    catch(Exception ex) {
        ex.printStackTrace();
        JObj.put("status", "failed");           
    }
    finally {
        rs.close();
        poStmt1.close();
        db1.closeConnection(con);           
    }
    return JObj.toString();
}
}

首先,将读取数据库和处理数据分开。

Vector stateVector = null;
try {
     Reading data from database
} catch (the problems) {
     And handle them
} finally {
     close the connection
}

然后检查你是否有一些数据:

if (stateVector != null {
    // get the data you want, probably with a loop construct
}

相关内容

  • 没有找到相关文章

最新更新