Mirth调用存储过程报错ORA-01861: 文字与格式字符串不匹配
Mirth调用存储过程报错.ORA-01861: 文字与格式字符串不匹配
这种绝对是日期的错误,要进行日期格式转换,具体呢需要自己一步步测试
上业务场景
function func_CreateCardPatInfo(request) {
var ret = new XML("<response></response>");
ret["returncode"] = "22002";
var TransCode =msg['ControlActProcess']['Request']['TransCode'].toString() ;
var CardType =msg['ControlActProcess']['Request']['CardType'].toString() ;
var CardNo =msg['ControlActProcess']['Request']['CardNo'].toString() ;
var PatientName =msg['ControlActProcess']['Request']['PatientName'].toString() ;
var Sex =msg['ControlActProcess']['Request']['Sex'].toString() ;
var Birthday1 =msg['ControlActProcess']['Request']['Birthday'].toString() ;
var Birthday2 = Birthday1.replace(/-/g, "/");
var Birthday = new java.text.SimpleDateFormat("yyyy/MM/dd").parse(Birthday2);
var Age =msg['ControlActProcess']['Request']['Age'].toString() ;
var IDCardNo =msg['ControlActProcess']['Request']['IDCardNo'].toString() ;
var BankCardNo =msg['ControlActProcess']['Request']['BankCardNo'].toString() ;
var Identity =msg['ControlActProcess']['Request']['Identity'].toString() ;
var Charge_Type =msg['ControlActProcess']['Request']['Charge_Type'].toString() ;
var nation =msg['ControlActProcess']['Request']['nation'].toString() ;
var Tel =msg['ControlActProcess']['Request']['Tel'].toString() ;
var UserId =msg['ControlActProcess']['Request']['UserId'].toString() ;
var Amt =msg['ControlActProcess']['Request']['Amt'].toString() ;
var Password =msg['ControlActProcess']['Request']['Password'].toString() ;
var Fingerprint1 =msg['ControlActProcess']['Request']['Fingerprint1'].toString() ;
var Fingerprint2 =msg['ControlActProcess']['Request']['Fingerprint2'].toString() ;
var hisid =msg['ControlActProcess']['Request']['hisid'].toString() ;
var ActDate1 =msg['ControlActProcess']['Request']['ActDate'].toString() ;
var ActDate2 = ActDate1.replace(/-/g, "/");
var ActDate = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(ActDate2);
var SerNo =msg['ControlActProcess']['Request']['SerNo'].toString() ;
$c("1CardNo",CardNo);
$c("3PatientName",PatientName );
$c("4Sex",Sex );
$c("5Birthday",Birthday);
$c("6IDCardNo",IDCardNo);
$c("9Amt",Amt);
$c("11Tel",Tel);
$c("12UserId",UserId);
$c("13ActDate",ActDate);
$c("14TransCode",TransCode);
$c("15CardType",CardType);
$c("16Age",Age);
$c("19Identity",Identity);
$c("20Charge_Type",Charge_Type);
$c("22nation",nation);
var conn = GetConnection("HISDB");
var connection = conn.getConnection();
var statement = connection.prepareCall("{ call billservice.pkg_autobillservice.proc_createcardpatinfo(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
statement.setObject(1, CardNo ); //cardno
statement.setObject(2, UserId); //hisid
statement.setObject(3, PatientName ); //patientname
statement.setObject(4, Sex ); //sex
statement.setObject(5, new java.sql.Timestamp(Birthday.getTime())); //birthday
statement.setObject(6, IDCardNo ); //idcardno
statement.setObject(7, SerNo ); //secrityno
statement.setObject(8, '' ); //cardserno
statement.setObject(9, Amt ); // amt
statement.setObject(10, '' );//address
statement.setObject(11, Tel ); //telphone
statement.setObject(12, UserId ); //userid
statement.setObject(13, new java.sql.Timestamp(ActDate.getTime())); //actdate
statement.setObject(14, TransCode ); //tranno
statement.setObject(15, CardType );//cardtype
statement.setObject(16, Age ); //age
statement.setObject(17, Fingerprint1); //fingerprint1
statement.setObject(18, Fingerprint2 );//fingerprint2
statement.setObject(19, Identity ); //identity
statement.setObject(20, Charge_Type );//charge_type
statement.setObject(21, BankCardNo );//bankcardno
statement.setObject(22, nation ); //nation
statement.registerOutParameter(23,java.sql.Types.VARCHAR); //resultcode
statement.registerOutParameter(24,java.sql.Types.VARCHAR); //errormsg
statement.registerOutParameter(25,java.sql.Types.VARCHAR); //serid
statement.registerOutParameter(26,java.sql.Types.VARCHAR); //patient_id
statement.registerOutParameter(27,java.sql.Types.VARCHAR); //sickid
statement.execute();
ret["ResultCode"] = statement.getString(23);
ret["ErrorMsg"] = statement.getString(24);
ret["PatientID"] = statement.getString(25);
ret["TranFlow"] = statement.getString(26);
ret["SickID"] = statement.getString(27);
return ret;
}
1代码分析:
1.正则表达式1998-08-02和1998/08/02之间转换
var Birthday1 =msg['ControlActProcess']['Request']['Birthday'].toString() ;
var Birthday2 = Birthday1.replace(/-/g, "/");
2.日期格式转换
var Birthday = new java.text.SimpleDateFormat("yyyy/MM/dd").parse(Birthday2);
statement.setObject(5, new java.sql.Timestamp(Birthday.getTime())); //birthday