protected virtual void OnMessageDataExchange(Web_MedicalStatisticsResp message) { var handler = Web_MedicalStatisticsRespExchange; if (handler != null) { handler(this, new DataExchangeRespEventArgs(message)); } }
public DataExchangeRespEventArgs(Web_MedicalStatisticsResp message) { Web_MedicalStatisticsRespMessage = message; }
private void ExchangeDataResp(Web_MedicalStatisticsResp message) { OnMessageDataExchange(message); }
public SyncDataRespEventArgs(Web_MedicalStatisticsResp message) { Web_MedicalStatisticsRespMessage = message; }
/// <summary> /// 同步病历填写项目与值对应关系数据 /// </summary> public void SyncWeb_MedicalStatistics(Web_MedicalStatistics MedicalStatistics, string UnitCode) { try { string strLcoalLSH = ""; string strLocalCS = ""; string strLocalCLBH = ""; string strLocalRecordId = ""; string strLocalStatisticsId = ""; string strTargetLSH = MedicalStatistics.LSH; string strTargetCS = MedicalStatistics.CS; string strTargetCLBH = MedicalStatistics.CLBH; string strTargetStatisticsId = MedicalStatistics.ID; string strTargetRecordId = MedicalStatistics.MEDICALRECORDSID; if (IsLWDD(MedicalStatistics.LSH, UnitCode, ref strLcoalLSH)) { //如果不存在出车对应记录,需要添加一条虚拟出车记录 if (!HasVehicleMatchRecord(MedicalStatistics.LSH, MedicalStatistics.CLBH, MedicalStatistics.CS, UnitCode, ref strLocalCS, ref strLocalCLBH)) { //如果还未有出车记录的话不再虚拟,不插入等待重新插入 LogHelper.WriteLog("SyncWeb_MedicalStatistics无出车记录,不插入患者信息。本地流水号:" + strLcoalLSH + " ID:" + strTargetRecordId + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); return; ////出车信息尚未关联,需先往出车信息表,生成一条记录 //DispatchVehicleData Dispatchdata = new DispatchVehicleData(); //if (hasInsertedDispatchVehicleRecord(Dispatchdata, UnitCode, strLcoalLSH, ref strLocalCLBH, ref strLocalCS)) //{ // //主键关联 // string sql = "insert into LWCLTBDYB (locallsh,localCS,localCLBH,TargetLSH,TargetCS,TargetCLBH,TargetDWBH) values ('" // + strLcoalLSH + "','" + strLocalCS + "','" + strLocalCLBH + "','" // + strTargetLSH + "','" + strTargetCS + "','" + strTargetCLBH + "','" + UnitCode + "')"; // int i = DB120Help.ExecuteSql(sql); // if (i > 0) // { // LogHelper.WriteLog("车辆信息表主键关联成功本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); // } // else // { // LogHelper.WriteLog("车辆信息表主键关联失败本地流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); // } //} //else //{ // return; //} } //如果不存在患者对应记录,需要添加一条虚拟患者记录 if (!hasMedicalMatchRecords(strTargetRecordId, UnitCode, strTargetLSH, ref strLocalRecordId)) { LogHelper.WriteLog("SyncWeb_MedicalStatistics无出车记录,不插入患者信息。本地流水号:" + strLcoalLSH + " ID:" + strTargetRecordId + " 关联的流水号:" + strTargetLSH + " 车次:" + strTargetCS + " 车辆编号:" + strTargetCLBH); return; ////需要添加患者记录 //Web_MedicalRecords MedicalRecords = new Web_MedicalRecords(); //if (hasInsertedMedicalRecords(MedicalRecords, strLcoalLSH, strLocalCS, strLocalCLBH, ref strLocalRecordId)) //{ // //将患者信息关联起来 // string Sql = "insert into LWBLTBDYB (locallsh,localRecordId,TargetLSH,TargetRecordId,TargetDWBH) values (" + // strLcoalLSH + ",'" + strLocalRecordId + "','" + strTargetLSH + "','" + strTargetRecordId + "','" + UnitCode + "')"; // int i = DB120Help.ExecuteSql(Sql); // if (i > 0) // { // LogHelper.WriteLog("患者病历记录主键关联成功"); // } // else // { // LogHelper.WriteLog("患者病历记录主键关联失败"); // } //} //else //{ // return; //} } //是否存在病历项目-值对应数据 if (hasMedicalMatchStatistics(strTargetStatisticsId, UnitCode, strTargetLSH, ref strLocalStatisticsId)) { MedicalStatistics.ID = strLocalStatisticsId; MedicalStatistics.MEDICALRECORDSID = strLocalRecordId; MedicalStatistics.CLBH = strLocalCLBH; MedicalStatistics.LSH = strLcoalLSH; MedicalStatistics.CS = strLocalCS; ParameterSql parSql = SyncDataSql.GetUpadateMedicalStatisticsSql(MedicalStatistics); int i = DB120Help.ExecuteSql(parSql.StrSql, parSql.OrclPar); if (i == 0) { LogHelper.WriteLog("病历记录数据更新本地库失败本地ID:" + MedicalStatistics.ID + " 流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH); } else { Web_MedicalStatisticsResp Data = new Web_MedicalStatisticsResp(); Data.CommandID = MedicalStatistics.CommandID + "Resp"; Data.ID = strTargetStatisticsId; Data.Result = 1; ExchangeDataResp(Data); } } //需要添加病历项目-值对应数据 else { MedicalStatistics.CLBH = strLocalCLBH; MedicalStatistics.LSH = strLcoalLSH; MedicalStatistics.CS = strLocalCS; MedicalStatistics.MEDICALRECORDSID = strLocalRecordId; ParameterSql parSql = SyncDataSql.GetAddMedicalStatisticsSql(MedicalStatistics); int i = DB120Help.ExecuteSql(parSql.StrSql, parSql.OrclPar); if (i <= 0) { LogHelper.WriteLog("病历项目-值对应数据更新本地库失败流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH); } else { //插入成功,则获取当前的ID //string Sql = "select max(ID) from web_medicalstatistics where MEDICALRECORDSID='" + strLocalRecordId + "'"; string Sql = "select max(ID) from web_medicalstatistics where MEDICALRECORDSID='" + strLocalRecordId + "' and CONTROLID = '" + MedicalStatistics.CONTROLID + "'"; object obj = DB120Help.GetSingle(Sql); strLocalStatisticsId = obj.ToString(); LogHelper.WriteLog("病历项目-值对应数据更新本地库成功本地ID:" + strLocalStatisticsId + " 流水号:" + strLcoalLSH + " 车次:" + strLocalCS + " 车辆编号:" + strLocalCLBH); //create table LWBLGXTBDYB //( // locallsh 本地流水号 // localStatisticsID 本地病历关系ID号 // TargetLSH 对方流水号 // TargetStatisticsID 对方病历关系ID号 // TargetDWBH 对方单位编号 // ) //将病历项目-值对应数据关联起来 Sql = "insert into LWBLGXTBDYB (locallsh,localStatisticsID,TargetLSH,TargetStatisticsID,TargetDWBH) values (" + strLcoalLSH + ",'" + strLocalStatisticsId + "','" + strTargetLSH + "','" + strTargetStatisticsId + "','" + UnitCode + "')"; i = DB120Help.ExecuteSql(Sql); if (i > 0) { LogHelper.WriteLog("病历项目-值对应数据主键关联成功"); } else { LogHelper.WriteLog("病历项目-值对应数据主键关联失败"); } Web_MedicalStatisticsResp Data = new Web_MedicalStatisticsResp(); Data.CommandID = MedicalStatistics.CommandID + "Resp"; Data.ID = strTargetStatisticsId; Data.Result = 1; ExchangeDataResp(Data); } } } else { Web_MedicalStatisticsResp Data = new Web_MedicalStatisticsResp(); Data.CommandID = MedicalStatistics.CommandID + "Resp"; Data.ID = strTargetStatisticsId; Data.Result = 1; ExchangeDataResp(Data); } } catch (Exception ex) { Web_MedicalStatisticsResp Data = new Web_MedicalStatisticsResp(); Data.CommandID = MedicalStatistics.CommandID + "Resp"; Data.ID = MedicalStatistics.ID; Data.Result = 0; Data.FailtureReason = ex.Message; ExchangeDataResp(Data); LogHelper.WriteLog("", ex); } }