调用存储过程实例

[WebMethod]
public DataSet EmrGetLongOrderData(string strPatientID, string intVisitID)
{
DataSet dsOrder = new DataSet();
//转化服务器日期格式
System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("zh-CN", true);
myCI.DateTimeFormat.ShortDatePattern = "yyyy-M-d";
System.Threading.Thread.CurrentThread.CurrentCulture = myCI;
//---添加日志机制
string strExceptionSql = string.Empty;
string strDBType = string.Empty;
//连接HIS数据库串
ConnectionStringSettings strHis = ConfigurationManager.ConnectionStrings[strHISConnectionString];
ConnectionStringSettings strEmr = ConfigurationManager.ConnectionStrings[strEMRConnectionString];

DbProviderFactory factHis = DbProviderFactories.GetFactory(strHis.ProviderName);
DbProviderFactory factEmr = DbProviderFactories.GetFactory(strEmr.ProviderName);

using (DbConnection connEmr = factEmr.CreateConnection())
{
connEmr.ConnectionString = strEmr.ConnectionString;
connEmr.Open();
try
{
DbCommand cmdEmr = connEmr.CreateCommand();
DbDataAdapter daEmr = factEmr.CreateDataAdapter();
//科室不取mr_on_line 当前ward_code,改成取pat_visit的ward_admission_to 李菲2011-12-14
cmdEmr.CommandText = "select a.inp_no,a.ward_admission_to,a.baby_flag from pat_visit a "
+ " where a.patient_id=‘" + strPatientID + "‘ and a.visit_id=‘" + intVisitID + "‘";
strExceptionSql = cmdEmr.CommandText;//记录日志
strDBType = strDBEmr;
DataSet dsInpNo = new DataSet();
daEmr.SelectCommand = cmdEmr;
daEmr.Fill(dsInpNo);

string strInpNo = "", strWardCode = "";
int iBabyFlag = 0;
if (dsInpNo.Tables.Count > 0)
{
if (dsInpNo.Tables[0].Rows.Count > 0)
{
strInpNo = dsInpNo.Tables[0].Rows[0]["inp_no"].ToString();
strWardCode = dsInpNo.Tables[0].Rows[0]["ward_admission_to"].ToString();
iBabyFlag = Convert.ToInt32(dsInpNo.Tables[0].Rows[0]["baby_flag"].ToString());
}
}
using (DbConnection connHis = factHis.CreateConnection())
{
connHis.ConnectionString = strHis.ConnectionString;
connHis.Open();
DbCommand cmdHis = connHis.CreateCommand();
DbDataAdapter daHis = factHis.CreateDataAdapter();
daHis.SelectCommand = cmdHis;
daHis.SelectCommand.Connection = connHis;
daHis.SelectCommand.CommandText = "SP_HS_ORDERS_SELECT_EMR";
daHis.SelectCommand.CommandType = CommandType.StoredProcedure;

DbParameter param1 = factHis.CreateParameter();
param1.ParameterName = "V_BINID";
param1.DbType = DbType.Int64;
param1.Direction = ParameterDirection.Input;
param1.Value = Convert.ToInt64(strInpNo);

DbParameter param2 = factHis.CreateParameter();
if (iBabyFlag == 0)
{
param2.ParameterName = "V_BABYID";
param2.DbType = DbType.Int32;
param2.Direction = ParameterDirection.Input;
param2.Value = 0;
}
else
{
iBabyFlag = Convert.ToInt32(strPatientID.Substring(3));
param2.ParameterName = "V_BABYID";
param2.DbType = DbType.Int32;
param2.Direction = ParameterDirection.Input;
param2.Value = iBabyFlag;
}

//V_SELTYPE 0-长嘱 1,5-临嘱
DbParameter param3 = factHis.CreateParameter();
param3.ParameterName = "V_SELTYPE";
param3.DbType = DbType.Int32;
param3.Direction = ParameterDirection.Input;
param3.Value = 0;

//V_SELKIND 0-无效 1有效
DbParameter param4 = factHis.CreateParameter();
param4.ParameterName = "V_SELKIND";
param4.DbType = DbType.Int32;
param4.Direction = ParameterDirection.Input;
param4.Value = 1;

DbParameter param5 = factHis.CreateParameter();
param5.ParameterName = "V_DOC";
param5.DbType = DbType.Int64;
param5.Direction = ParameterDirection.Input;
param5.Value = 0;

DbParameter param6 = factHis.CreateParameter();
param6.ParameterName = "V_EXECDATE";
param6.DbType = DbType.DateTime;
param6.Direction = ParameterDirection.Input;
param6.Value = DateTime.Today;

DbParameter param7 = factHis.CreateParameter();
param7.ParameterName = "V_WARDID";
param7.DbType = DbType.String;
param7.Direction = ParameterDirection.Input;
param7.Value = strWardCode;

daHis.SelectCommand.Parameters.Add(param1);
daHis.SelectCommand.Parameters.Add(param2);
daHis.SelectCommand.Parameters.Add(param3);
daHis.SelectCommand.Parameters.Add(param4);
daHis.SelectCommand.Parameters.Add(param5);
daHis.SelectCommand.Parameters.Add(param6);
daHis.SelectCommand.Parameters.Add(param7);

daHis.SelectCommand = cmdHis;
daHis.Fill(dsOrder);
}
}
catch (Exception ex)
{
this.ExceptionLoger(strDBType, strExceptionSql, ex, "同步医嘱错误");
}
}
return dsOrder;
}

时间: 2024-10-11 00:51:05

调用存储过程实例的相关文章

Spring Data JPA调用存储过程实例

Spring Data JPA调用存储过程实例 作者:chszs,未经博主允许不得转载.经许可的转载需注明作者和博客主页:http://blog.csdn.net/chszs JPA连接到数据库,调用存储过程,这样的需求很常见.本文就针对这一点,讲述如何使用Spring Data JPA调用存储过程的方法. 1.存储过程 假设存储过程如下: CREATE OR REPLACE PACKAGE test_pkg AS PROCEDURE in_only_test (inParam1 IN VARC

EF调用存储过程实例

创建实体: 1 public class User 2 { 3 public string UserID { get; set; } 4 public string UserName { get; set; } 5 public string Password { get; set; } 6 [Description("测试")] 7 public string UserGroupId { get; set; } 8 public UserGroup UserGroup { get;

EF 调用存储过程实例

IQueryable<TPT_ECN_MSTR> q = db.TPT_ECN_MSTRS.AsNoTracking(); if (_OrdDateFr == DateTime.MinValue && _OrdDateTo == DateTime.MaxValue) return q.Where(p => 1 == 2).ToList(); string usr_user = GetIdentityName(); OracleParameter[] pars = { ne

使用CompletionService结合ExecutorService批处理调用存储过程任务实例

此实例为java多线程并发调用存储过程实例,只做代码记载,不做详细描述 1.线程池构造初始化类CommonExecutorService.java package com.pupeiyuan.go; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.u

PHP调用MYSQL存储过程实例

PHP调用MYSQL存储过程实例 标签: mysql存储phpsqlquerycmd 2010-09-26 11:10 11552人阅读 评论(3) 收藏 举报 实例一:无参的存储过程$conn = mysql_connect('localhost','root','root') or die ("数据连接错误!!!");mysql_select_db('test',$conn);$sql = "create procedure myproce()beginINSERT IN

mybatis 调用存储过程 返回游标 实例

存储过程示例: create or replace procedure Fsp_Plan_CheckPrj(v_grantno varchar2, v_deptcode number, v_cursor out sys_refcursor) is ……………… ---返回统计结果 open v_Cursor for select s.plan_code, s.plan_dept, s.plan_amount, s.exec_amount, p.cname as plan_name, d.cnam

oracle中job定时调用存储过程的实例

使用job模拟定时从元数据表中抽取指定数据进入目标表的过程. 一.创建元数据表 --create table test_origianl create table test_original_data( id number(10,2) primary key, name varchar2(200), descCont varchar2(100), dateType char(5) ); 二.元数据表中插入数据 insert into test_original_data values(2.9,'

MySQL之存储过程实例讲解(创建、调用、查看、修改、删除)

1.存储过程简介: 存储过程,英文名Stored Procedure,说简单点,就是将MySQL语句集或必要的程序封装在一个结构体里面,存储在数据库中,供外部调用的一个数据库对象,存储过程在思想上很简单,就是SQL代码的封装与重用. 优点 存储过程可封装,并隐藏复杂的商业逻辑. 存储过程可以回传值,并可以接受参数. 存储过程可以返回多个值,而普通函数只能返回一个值. 存储过程无法使用 SELECT 指令来运行,因为它是子程序,与查看表,数据表或用户定义函数不同. 存储过程可以用在数据检验,强制实

oracle存储过程实例

oracle存储过程实例 分类: 数据(仓)库及处理 2010-05-03 17:15 1055人阅读 评论(2)收藏 举报 认识存储过程和函数 存储过程和函数也是一种PL/SQL块,是存入数据库的PL/SQL块.但存储过程和函数不同于已经介绍过的PL/SQL程序,我们通常把PL/SQL程序称为无名块,而存储过程和函数是以命名的方式存储于数据库中的.和PL/SQL程序相比,存储过程有非常多长处,详细归纳例如以下: * 存储过程和函数以命名的数据库对象形式存储于数据库其中.存储在数据库中的长处是非