|
|
|
|
@ -1,52 +1,53 @@
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Services\Xml;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
|
|
class ShenQingDanService
|
|
|
|
|
{
|
|
|
|
|
public function Save($result,$jsonData)
|
|
|
|
|
public function Save($result, $jsonData)
|
|
|
|
|
{
|
|
|
|
|
$Body= $result['message']['Request']["Body"];
|
|
|
|
|
$Header=$result['message']['Request']["Header"];
|
|
|
|
|
$orderList=isset($Body['AddRisAppBillRt']['OrderList'])?$Body['AddRisAppBillRt']['OrderList']:[];
|
|
|
|
|
$Body = $result['message']['Request']["Body"];
|
|
|
|
|
$Header = $result['message']['Request']["Header"];
|
|
|
|
|
$orderList = isset($Body['AddRisAppBillRt']['OrderList']) ? $Body['AddRisAppBillRt']['OrderList'] : [];
|
|
|
|
|
if (!empty($orderList) && !isset($orderList[0])) {
|
|
|
|
|
// 如果OrderList当前不是数组的数组,则将其转换为单元素数组
|
|
|
|
|
$orderList = array($orderList);
|
|
|
|
|
}
|
|
|
|
|
$insert_count=0;//成功插入数量
|
|
|
|
|
$insert_count = 0;//成功插入数量
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
foreach ($orderList as $key => $order){
|
|
|
|
|
$patient_type=null;
|
|
|
|
|
if(isset($Body["PATAdmInfo"]["PAADMTypeCode"])){
|
|
|
|
|
$p=$Body["PATAdmInfo"]["PAADMTypeCode"];
|
|
|
|
|
if($p=='O') $patient_type=1;
|
|
|
|
|
if($p=='H') $patient_type=3;
|
|
|
|
|
if($p=='E') $patient_type=2;
|
|
|
|
|
if($p=='I') $patient_type=0;
|
|
|
|
|
foreach ($orderList as $key => $order) {
|
|
|
|
|
$patient_type = null;
|
|
|
|
|
if (isset($Body["PATAdmInfo"]["PAADMTypeCode"])) {
|
|
|
|
|
$p = $Body["PATAdmInfo"]["PAADMTypeCode"];
|
|
|
|
|
if ($p == 'O') $patient_type = 1;
|
|
|
|
|
if ($p == 'H') $patient_type = 3;
|
|
|
|
|
if ($p == 'E') $patient_type = 2;
|
|
|
|
|
if ($p == 'I') $patient_type = 0;
|
|
|
|
|
}
|
|
|
|
|
$params = [
|
|
|
|
|
'list_status' => 0,
|
|
|
|
|
'reg_num' => $Body["PATPatientInfo"]["PATPatientID"] ?$Body["PATPatientInfo"]["PATPatientID"]: null,
|
|
|
|
|
'user_name' => $Body["PATPatientInfo"]["PATName"] ?$Body["PATPatientInfo"]["PATName"]: null,
|
|
|
|
|
'user_sex' => $Body["PATPatientInfo"]["PATName"]=='男'?1: 2,
|
|
|
|
|
'entrust_code' => $order["RISRCode"] ?$order["RISRCode"]: null,
|
|
|
|
|
'entrust' => $order["RISRDesc"] ?$order["RISRDesc"]: null,
|
|
|
|
|
'is_pay' => $order["OrdBillStatus"]=='已收费' ? 1: 0,
|
|
|
|
|
'reservation_department' => $order["AppDeptDesc"] ?$order["AppDeptDesc"]: null,
|
|
|
|
|
'entrust_date' =>$order["RISRSubmitTime"] ?substr($order["RISRSubmitTime"], 0, 10): null,
|
|
|
|
|
'entrust_time' => $order["RISRSubmitTime"] ?substr($order["RISRSubmitTime"], 11, 8): null,
|
|
|
|
|
'user_brithday' =>$Body["PATPatientInfo"]["PATDob"] ?$Body["PATPatientInfo"]["PATDob"]: null,
|
|
|
|
|
'docotr' => $Body["PATAdmInfo"]["PAADMDocDesc"] ?$Body["PATAdmInfo"]["PAADMDocDesc"]: null,
|
|
|
|
|
'patient_type' =>$patient_type,
|
|
|
|
|
'user_phone' => $Body["PATPatientInfo"]["PATTelephone"] ? $Body["PATPatientInfo"]["PATTelephone"]: null,
|
|
|
|
|
'implement_department' => $order["RISRAcceptDeptDesc"] ?$order["RISRAcceptDeptDesc"]: null,
|
|
|
|
|
'entrust_id' => $order["OEORIOrderItemID"] ?$order["OEORIOrderItemID"]: null,//his传过来的本地医嘱id
|
|
|
|
|
'episodeid' => $Body["PATAdmInfo"]["PAADMVisitNumber"] ?$Body["PATAdmInfo"]["PAADMVisitNumber"]: null, //就诊号
|
|
|
|
|
'RISRExamID' =>$order["RISRExamID"] ?$order["RISRExamID"]: null, //检查号
|
|
|
|
|
'RISRAcceptDeptCode' => $order["RISRAcceptDeptCode"] ?$order["RISRAcceptDeptCode"]: null, //接收科室代码
|
|
|
|
|
'warddesc' => $Body["PATAdmInfo"]["PAADMAdmWardDesc"]? $Body["PATAdmInfo"]["PAADMAdmWardDesc"] :null, //病区
|
|
|
|
|
'beddesc' => $Body["PATAdmInfo"]["PAADMCurBedNo"]? $Body["PATAdmInfo"]["PAADMCurBedNo"] :null, //病床号
|
|
|
|
|
'reg_num' => $Body["PATPatientInfo"]["PATPatientID"] ? $Body["PATPatientInfo"]["PATPatientID"] : null,
|
|
|
|
|
'user_name' => $Body["PATPatientInfo"]["PATName"] ? $Body["PATPatientInfo"]["PATName"] : null,
|
|
|
|
|
'user_sex' => $Body["PATPatientInfo"]["PATName"] == '男' ? 1 : 2,
|
|
|
|
|
'entrust_code' => $order["RISRCode"] ? $order["RISRCode"] : null,
|
|
|
|
|
'entrust' => $order["RISRDesc"] ? $order["RISRDesc"] : null,
|
|
|
|
|
'is_pay' => $order["OrdBillStatus"] == '已收费' ? 1 : 0,
|
|
|
|
|
'reservation_department' => $order["AppDeptDesc"] ? $order["AppDeptDesc"] : null,
|
|
|
|
|
'entrust_date' => $order["RISRSubmitTime"] ? substr($order["RISRSubmitTime"], 0, 10) : null,
|
|
|
|
|
'entrust_time' => $order["RISRSubmitTime"] ? substr($order["RISRSubmitTime"], 11, 8) : null,
|
|
|
|
|
'user_brithday' => $Body["PATPatientInfo"]["PATDob"] ? $Body["PATPatientInfo"]["PATDob"] : null,
|
|
|
|
|
'docotr' => $Body["PATAdmInfo"]["PAADMDocDesc"] ? $Body["PATAdmInfo"]["PAADMDocDesc"] : null,
|
|
|
|
|
'patient_type' => $patient_type,
|
|
|
|
|
'user_phone' => $Body["PATPatientInfo"]["PATTelephone"] ? $Body["PATPatientInfo"]["PATTelephone"] : null,
|
|
|
|
|
'implement_department' => $order["RISRAcceptDeptDesc"] ? $order["RISRAcceptDeptDesc"] : null,
|
|
|
|
|
'entrust_id' => $order["OEORIOrderItemID"] ? $order["OEORIOrderItemID"] : null,//his传过来的本地医嘱id
|
|
|
|
|
'episodeid' => $Body["PATAdmInfo"]["PAADMVisitNumber"] ? $Body["PATAdmInfo"]["PAADMVisitNumber"] : null, //就诊号
|
|
|
|
|
'RISRExamID' => $order["RISRExamID"] ? $order["RISRExamID"] : null, //检查号
|
|
|
|
|
'RISRAcceptDeptCode' => $order["RISRAcceptDeptCode"] ? $order["RISRAcceptDeptCode"] : null, //接收科室代码
|
|
|
|
|
'warddesc' => $Body["PATAdmInfo"]["PAADMAdmWardDesc"] ? $Body["PATAdmInfo"]["PAADMAdmWardDesc"] : null, //病区
|
|
|
|
|
'beddesc' => $Body["PATAdmInfo"]["PAADMCurBedNo"] ? $Body["PATAdmInfo"]["PAADMCurBedNo"] : null, //病床号
|
|
|
|
|
];
|
|
|
|
|
$requiredFields = [
|
|
|
|
|
'reg_num', 'user_name', 'user_sex', 'entrust', 'is_pay',
|
|
|
|
|
@ -79,21 +80,23 @@ class ShenQingDanService
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '失败');
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '失败');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(count($orderList)==$insert_count){
|
|
|
|
|
if (count($orderList) == $insert_count) {
|
|
|
|
|
DB::commit();
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],0,'成功');
|
|
|
|
|
}else{
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], 0, '成功');
|
|
|
|
|
} else {
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'],$Header['MessageID'],-1,'失败');
|
|
|
|
|
return \Yz::XMLReturn($Header['SourceSystem'], $Header['MessageID'], -1, '失败');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|