/// <summary> /// 正式结算 /// </summary> /// <param name="prescriptions">需要结算的处方</param> /// <returns>true:结算成功,false:结算失败</returns> /// <param name="Result">返回的相关信息</param> public bool Charge(Prescription[] prescriptions, out object Result) { Result = null; PatientComp patComp = new PatientComp(); patComp.uploadorg = MED_ORG_CODE; DataClass dataClass = new DataClass(); dataClass.dataClassValue = "1"; patComp.dataClass = dataClass; JoinArea joinArea = new JoinArea(); joinArea.code = JOIN_AREA_CODE; joinArea.name = JOIN_AREA_NAME; patComp.joinArea = joinArea; DataType dataType = new DataType(); dataType.dataTypeName = "门诊数据"; dataType.dataTypeValue = "2"; patComp.dataType = dataType; MzPatBaseData mzPat = new MzPatBaseData(); mzPat.idCard = hisOutPatient.InsurInfo.IdCard; mzPat.person_code = hisOutPatient.InsurInfo.Person_Code; mzPat.hisID = hisOutPatient.PatListID.ToString();//本次门诊的唯一号 mzPat.area_id = JOIN_AREA_CODE; mzPat.family_code = hisOutPatient.InsurInfo.Family_Code; mzPat.medorg_code = MED_ORG_CODE; mzPat.medorg_level = hisOutPatient.InsurInfo.Medorg_Level; mzPat.visit_type = "1"; //1,门诊,2-住院 mzPat.age = hisOutPatient.Age.ToString(); mzPat.name = hisOutPatient.PatientName; mzPat.medcard_id = hisOutPatient.InsurInfo.Medcard_Id; patComp.mzPat = mzPat; List <FeeDetail> fees = new List <FeeDetail>(); for (int i = 0; i < prescriptions.Length; i++) { for (int j = 0; j < prescriptions[i].PresDetails.Length; j++) { FeeDetail feeDetail = new FeeDetail(); feeDetail.his_billno = prescriptions[i].ChargeID.ToString(); feeDetail.item_sn = prescriptions[i].PrescriptionID.ToString() + prescriptions[i].PresDetails[j].DetailId.ToString() + prescriptions[i].ChargeID.ToString(); feeDetail.item_code = prescriptions[i].PresDetails[j].ItemId.ToString(); if (prescriptions[i].PresDetails[j].ItemType == "01" || prescriptions[i].PresDetails[j].ItemType == "02" || prescriptions[i].PresDetails[j].ItemType == "03") { feeDetail.item_class = "1"; } else { feeDetail.item_class = "2"; } feeDetail.item_equal = "0"; feeDetail.item_name = prescriptions[i].PresDetails[j].Itemname.Trim(); feeDetail.item_use_time = DateTime.Now.ToString("yyyy-MM-dd"); feeDetail.amount = Convert.ToDouble(prescriptions[i].PresDetails[j].Amount); feeDetail.drugform = ""; feeDetail.doctorTitle = GetDoctorTitle(prescriptions[i].PresDocCode); feeDetail.doctor = prescriptions[i].PresDocCode; feeDetail.money = Convert.ToDouble(prescriptions[i].PresDetails[j].Tolal_Fee); feeDetail.price = Convert.ToDouble(prescriptions[i].PresDetails[j].Sell_price); feeDetail.center_item_code = GetNcmsCenterCode(feeDetail.item_code, feeDetail.item_class); feeDetail.specs = prescriptions[i].PresDetails[j].Standard; feeDetail.unit = prescriptions[i].PresDetails[j].Unit; feeDetail.nccm_comp_status = "0"; feeDetail.feeType = GetClassCode(prescriptions[i].PresDetails[j].BigitemCode); feeDetail.comp_ratio = Convert.ToDouble(GetNcmsCompRate(feeDetail.item_code, feeDetail.item_class)); fees.Add(feeDetail); } } FeeDetail[] detailList = fees.ToArray(); patComp.mzDetail = detailList; //调用接口预算功能 try { CompData[] cpData = NccmInterfaces.OutPatientCharge(patComp); Result = cpData; return(true); } catch (OperatorException operr) { throw operr; } catch (Exception err) { ErrorWriter.WriteLog(err.Source + "\r\n" + err.Message); throw new Exception("新农合接口调用期间发生错误!"); } }
/// <summary> /// 预算(接口预算完成后,回写入参的补偿金额字段以便后续使用) /// </summary> /// <returns>返回医保预算信息</returns> public InsurChargeInfo PreviewCharge(Prescription[] prescriptions) { PatientComp patComp = new PatientComp(); patComp.uploadorg = MED_ORG_CODE; DataClass dataClass = new DataClass(); dataClass.dataClassValue = "1"; patComp.dataClass = dataClass; JoinArea joinArea = new JoinArea(); joinArea.code = JOIN_AREA_CODE; joinArea.name = JOIN_AREA_NAME; patComp.joinArea = joinArea; DataType dataType = new DataType(); dataType.dataTypeName = "门诊数据"; dataType.dataTypeValue = "2"; patComp.dataType = dataType; MzPatBaseData mzPat = new MzPatBaseData(); mzPat.idCard = hisOutPatient.InsurInfo.IdCard; mzPat.person_code = hisOutPatient.InsurInfo.Person_Code; mzPat.hisID = hisOutPatient.PatListID.ToString();//本次门诊的唯一号 mzPat.area_id = JOIN_AREA_CODE; mzPat.family_code = hisOutPatient.InsurInfo.Family_Code; mzPat.medorg_code = MED_ORG_CODE; mzPat.medorg_level = hisOutPatient.InsurInfo.Medorg_Level; mzPat.visit_type = "1"; //1,门诊,2-住院 mzPat.age = hisOutPatient.Age.ToString(); mzPat.name = hisOutPatient.PatientName; mzPat.medcard_id = hisOutPatient.InsurInfo.Medcard_Id; mzPat.birthdate = hisOutPatient.InsurInfo.BirthDate.ToString("yyyy-MM-dd"); mzPat.age = hisOutPatient.InsurInfo.Age.ToString(); patComp.mzPat = mzPat; List <FeeDetail> fees = new List <FeeDetail>(); for (int i = 0; i < prescriptions.Length; i++) { for (int j = 0; j < prescriptions[i].PresDetails.Length; j++) { try { FeeDetail feeDetail = new FeeDetail(); feeDetail.his_billno = prescriptions[i].ChargeID.ToString(); feeDetail.item_sn = prescriptions[i].PrescriptionID.ToString() + prescriptions[i].PresDetails[j].DetailId.ToString() + prescriptions[i].ChargeID.ToString(); feeDetail.item_code = prescriptions[i].PresDetails[j].ItemId.ToString(); if (prescriptions[i].PresDetails[j].ItemType == "01" || prescriptions[i].PresDetails[j].ItemType == "02" || prescriptions[i].PresDetails[j].ItemType == "03") { feeDetail.item_class = "1"; } else { feeDetail.item_class = "2"; } feeDetail.item_equal = "0"; feeDetail.item_name = prescriptions[i].PresDetails[j].Itemname.Trim(); feeDetail.item_use_time = DateTime.Now.ToString("yyyy-MM-dd"); feeDetail.amount = Convert.ToDouble(prescriptions[i].PresDetails[j].Amount); feeDetail.drugform = ""; feeDetail.doctorTitle = GetDoctorTitle(prescriptions[i].PresDocCode); feeDetail.doctor = prescriptions[i].PresDocCode; feeDetail.money = Convert.ToDouble(prescriptions[i].PresDetails[j].Tolal_Fee); feeDetail.price = Convert.ToDouble(prescriptions[i].PresDetails[j].Sell_price); feeDetail.center_item_code = GetNcmsCenterCode(feeDetail.item_code, feeDetail.item_class); feeDetail.specs = prescriptions[i].PresDetails[j].Standard; feeDetail.unit = prescriptions[i].PresDetails[j].Unit; feeDetail.nccm_comp_status = "0"; feeDetail.feeType = GetClassCode(prescriptions[i].PresDetails[j].BigitemCode); feeDetail.comp_ratio = Convert.ToDouble(GetNcmsCompRate(feeDetail.item_code, feeDetail.item_class)); fees.Add(feeDetail); } catch (Exception err) { ErrorWriter.WriteLog(err.Message); throw new OperatorException("准备上传数据期间发生错误!"); } } } FeeDetail[] detailList = fees.ToArray(); patComp.mzDetail = detailList; InsurChargeInfo insurChargeInfo = new InsurChargeInfo();//定义的农合结算信息 //调用接口预算功能 try { CompData[] compDatas = NccmInterfaces.OutPatientBudegt(patComp); //判断返回的农合结算结果记录是是否和医院处方数对应 if (compDatas.Length != prescriptions.Length) { throw new NcmsInterfaceException("新农合预算结果的记录数(" + compDatas.Length.ToString() + ")不等于医院上传的处方数(" + prescriptions.Length.ToString() + ")"); } //回写每条明细的补偿金额 for (int i = 0; i < prescriptions.Length; i++) { for (int j = 0; j < compDatas.Length; j++) { if (prescriptions[i].ChargeID.ToString() == compDatas[j].bill_no) { prescriptions[i].RedeemCost = Convert.ToDecimal(compDatas[j].comp_money); break; } } } } catch (NcmsInterfaceException ncmsErr) { throw new OperatorException(ncmsErr.Message); } catch (Exception err) { ErrorWriter.WriteLog(err.Message); ErrorWriter.WriteLog(err.InnerException.Message); throw new Exception("农合预算发生错误!"); } return(insurChargeInfo); }