更新
This commit is contained in:
@@ -49,7 +49,7 @@ class PrescriptionController extends BaseAdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 修正处方患者姓名手机号
|
||||
* @notes 修正处方患者姓名手机性别
|
||||
*/
|
||||
public function patchPatient()
|
||||
{
|
||||
@@ -58,6 +58,7 @@ class PrescriptionController extends BaseAdminController
|
||||
(int) $params['id'],
|
||||
(string) $params['patient_name'],
|
||||
(string) $params['phone'],
|
||||
(int) $params['gender'],
|
||||
(int) $this->adminId,
|
||||
$this->adminInfo
|
||||
);
|
||||
|
||||
@@ -495,7 +495,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
if ($prescriptionIds !== []) {
|
||||
$prescriptions = \app\common\model\tcm\Prescription::whereIn('id', $prescriptionIds)
|
||||
->whereNull('delete_time')
|
||||
->field(['id', 'creator_id', 'doctor_name', 'phone'])
|
||||
->field(['id', 'creator_id', 'doctor_name', 'phone', 'assistant_id'])
|
||||
->select()
|
||||
->toArray();
|
||||
$doctorIds = [];
|
||||
@@ -508,6 +508,7 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
'doctor_id' => $doctorId,
|
||||
'doctor_name' => $doctorName,
|
||||
'phone' => (string) ($rx['phone'] ?? ''),
|
||||
'assistant_id' => (int) ($rx['assistant_id'] ?? 0),
|
||||
];
|
||||
if ($doctorId > 0) {
|
||||
$doctorIds[] = $doctorId;
|
||||
@@ -533,7 +534,20 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
if ($diagIdsForAssist !== []) {
|
||||
$assistantByDiag = Diagnosis::whereIn('id', $diagIdsForAssist)->whereNull('delete_time')->column('assistant_id', 'id');
|
||||
}
|
||||
$assistantIds = array_values(array_unique(array_filter(array_map('intval', array_values($assistantByDiag)))));
|
||||
$assistantIds = [];
|
||||
foreach (array_values($assistantByDiag) as $v) {
|
||||
$vid = (int) $v;
|
||||
if ($vid > 0) {
|
||||
$assistantIds[] = $vid;
|
||||
}
|
||||
}
|
||||
foreach ($prescriptionCreators as $pc) {
|
||||
$aid = (int) ($pc['assistant_id'] ?? 0);
|
||||
if ($aid > 0) {
|
||||
$assistantIds[] = $aid;
|
||||
}
|
||||
}
|
||||
$assistantIds = array_values(array_unique($assistantIds));
|
||||
$assistantNames = $assistantIds !== []
|
||||
? \app\common\model\auth\Admin::whereIn('id', $assistantIds)->column('name', 'id')
|
||||
: [];
|
||||
@@ -558,16 +572,18 @@ class PrescriptionOrderLists extends BaseAdminDataLists implements ListsSearchIn
|
||||
$creatorId = (int) ($item['creator_id'] ?? 0);
|
||||
$item['creator_name'] = $creatorId > 0 ? ($creatorNames[$creatorId] ?? '') : '';
|
||||
|
||||
// 添加医助(来自诊单 assistant_id)
|
||||
// 医助:与处方列表一致优先关联处方 assistant_id,否则诊单 assistant_id(见 PrescriptionOrderLogic::resolveAssistantAdminIdForPrescriptionOrderRow)
|
||||
$diagIdForAssist = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$assistantIdForItem = (int) ($assistantByDiag[$diagIdForAssist] ?? 0);
|
||||
$diagAst = (int) ($assistantByDiag[$diagIdForAssist] ?? 0);
|
||||
$rxId = (int) ($item['prescription_id'] ?? 0);
|
||||
$rxAst = $rxId > 0 ? (int) (($prescriptionCreators[$rxId] ?? [])['assistant_id'] ?? 0) : 0;
|
||||
$assistantIdForItem = PrescriptionOrderLogic::resolveAssistantAdminIdForPrescriptionOrderRow($rxAst, $diagAst);
|
||||
$item['assistant_id'] = $assistantIdForItem;
|
||||
$item['assistant_name'] = $assistantIdForItem > 0
|
||||
? ($assistantNames[$assistantIdForItem] ?? '')
|
||||
: '';
|
||||
|
||||
// 添加开方人姓名、处方登记手机(与业务订单收货手机比对用)
|
||||
$rxId = (int) ($item['prescription_id'] ?? 0);
|
||||
$item['doctor_name'] = $rxId > 0 ? ($prescriptionCreators[$rxId]['doctor_name'] ?? '') : '';
|
||||
$item['prescription_phone'] = $rxId > 0 ? ($prescriptionCreators[$rxId]['phone'] ?? '') : '';
|
||||
}
|
||||
|
||||
@@ -437,9 +437,9 @@ class PrescriptionLogic
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅修正处方笺展示用患者姓名与手机号(zyt_tcm_prescription),不改变审核状态与其它字段
|
||||
* 仅修正处方笺展示用患者姓名、手机号与性别(zyt_tcm_prescription),不改变审核状态与其它字段
|
||||
*/
|
||||
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $adminId, array $adminInfo): bool
|
||||
public static function patchPatientContact(int $rxId, string $patientName, string $phone, int $gender, int $adminId, array $adminInfo): bool
|
||||
{
|
||||
self::$error = '';
|
||||
$prescription = Prescription::find($rxId);
|
||||
@@ -476,20 +476,38 @@ class PrescriptionLogic
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!in_array($gender, [0, 1], true)) {
|
||||
self::setError('性别无效');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$oldName = trim((string) ($prescription->patient_name ?? ''));
|
||||
$oldPhone = trim((string) ($prescription->phone ?? ''));
|
||||
$oldGender = (int) ($prescription->gender ?? 0);
|
||||
|
||||
if ($oldName === $patientName && $oldPhone === $phone) {
|
||||
if ($oldName === $patientName && $oldPhone === $phone && $oldGender === $gender) {
|
||||
self::setError('信息未变更');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$genderText = static function (int $g): string {
|
||||
if ($g === 1) {
|
||||
return '男';
|
||||
}
|
||||
if ($g === 0) {
|
||||
return '女';
|
||||
}
|
||||
|
||||
return '未知';
|
||||
};
|
||||
|
||||
try {
|
||||
$prescription->save([
|
||||
'patient_name' => $patientName,
|
||||
'phone' => $phone,
|
||||
'gender' => $gender,
|
||||
]);
|
||||
|
||||
$latestPo = PrescriptionOrder::where('prescription_id', $rxId)
|
||||
@@ -500,13 +518,17 @@ class PrescriptionLogic
|
||||
|
||||
$nameFrom = $oldName === '' ? '—' : $oldName;
|
||||
$phoneFrom = $oldPhone === '' ? '—' : $oldPhone;
|
||||
$genderFrom = $genderText($oldGender);
|
||||
$genderTo = $genderText($gender);
|
||||
$summary = sprintf(
|
||||
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」',
|
||||
'处方 #%d:患者姓名「%s」→「%s」,手机「%s」→「%s」,性别「%s」→「%s」',
|
||||
$rxId,
|
||||
$nameFrom,
|
||||
$patientName,
|
||||
$phoneFrom,
|
||||
$phone
|
||||
$phone,
|
||||
$genderFrom,
|
||||
$genderTo
|
||||
);
|
||||
PrescriptionOrderLogic::appendRxPatientPatchLog($logOrderId, $adminId, $adminInfo, $summary);
|
||||
|
||||
|
||||
@@ -2486,6 +2486,25 @@ class PrescriptionOrderLogic
|
||||
return $m[$fs] ?? ('状态' . (string) $fs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务订单列表/导出:「诊单医助」admin id。
|
||||
* 与 {@see PrescriptionLists} 一致优先 {@see Prescription::$assistant_id}(开方时从诊单快照到处方表);
|
||||
* 为 0 时再取诊单当前 {@see Diagnosis::$assistant_id}(兼容历史处方或未写入快照列的数据)。
|
||||
*/
|
||||
public static function resolveAssistantAdminIdForPrescriptionOrderRow(
|
||||
int $prescriptionAssistantId,
|
||||
int $diagnosisAssistantId
|
||||
): int {
|
||||
if ($prescriptionAssistantId > 0) {
|
||||
return $prescriptionAssistantId;
|
||||
}
|
||||
if ($diagnosisAssistantId > 0) {
|
||||
return $diagnosisAssistantId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用:诊单医助在 admin_dept 中的部门路径(多部门「;」、路径内「 / 」)
|
||||
*/
|
||||
@@ -2656,7 +2675,7 @@ class PrescriptionOrderLogic
|
||||
$rxById = [];
|
||||
if ($rxIdList !== []) {
|
||||
$rxRows = Prescription::whereIn('id', $rxIdList)->whereNull('delete_time')
|
||||
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit'])
|
||||
->field(['id', 'prescription_type', 'need_decoction', 'dose_unit', 'assistant_id'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($rxRows as $xr) {
|
||||
@@ -2697,13 +2716,17 @@ class PrescriptionOrderLogic
|
||||
|
||||
$diagId = (int) ($item['diagnosis_id'] ?? 0);
|
||||
$dg = $diagById[$diagId] ?? null;
|
||||
$rxId = (int) ($item['prescription_id'] ?? 0);
|
||||
$rx = $rxById[$rxId] ?? [];
|
||||
$item['export_patient_name'] = \is_array($dg) ? (string) ($dg['patient_name'] ?? '') : '';
|
||||
if (\is_array($dg)) {
|
||||
$g = (int) ($dg['gender'] ?? 0);
|
||||
$item['export_patient_gender'] = $g === 1 ? '男' : '女';
|
||||
$item['export_patient_age'] = (string) ($dg['age'] ?? '');
|
||||
$item['export_patient_phone'] = (string) ($dg['phone'] ?? '');
|
||||
$astId = (int) ($dg['assistant_id'] ?? 0);
|
||||
$rxAst = \is_array($rx) ? (int) ($rx['assistant_id'] ?? 0) : 0;
|
||||
$diagAst = (int) ($dg['assistant_id'] ?? 0);
|
||||
$astId = self::resolveAssistantAdminIdForPrescriptionOrderRow($rxAst, $diagAst);
|
||||
if ($astId > 0) {
|
||||
if (!isset($assistantDeptCache[$astId])) {
|
||||
$assistantDeptCache[$astId] = self::formatAssistantDeptPathForExport($astId);
|
||||
@@ -2719,8 +2742,6 @@ class PrescriptionOrderLogic
|
||||
$item['export_assistant_dept'] = '';
|
||||
}
|
||||
|
||||
$rxId = (int) ($item['prescription_id'] ?? 0);
|
||||
$rx = $rxById[$rxId] ?? [];
|
||||
$item['export_medication_form'] = self::formatMedicationFormForExport(\is_array($rx) ? $rx : []);
|
||||
|
||||
$item['export_channel'] = (string) ($item['service_channel'] ?? '');
|
||||
|
||||
@@ -15,6 +15,7 @@ class PrescriptionValidate extends BaseValidate
|
||||
'dosage_bag_count' => 'integer|between:1,5',
|
||||
'patient_name' => 'require',
|
||||
'phone' => 'require|max:20',
|
||||
'gender' => 'require|in:0,1',
|
||||
'clinical_diagnosis' => 'require',
|
||||
'herbs' => 'require|array',
|
||||
'action' => 'require|in:approve,reject',
|
||||
@@ -27,6 +28,8 @@ class PrescriptionValidate extends BaseValidate
|
||||
'patient_name.require' => '患者姓名不能为空',
|
||||
'phone.require' => '手机号不能为空',
|
||||
'phone.max' => '手机号过长',
|
||||
'gender.require' => '请选择性别',
|
||||
'gender.in' => '性别无效',
|
||||
'clinical_diagnosis.require' => '临床诊断不能为空',
|
||||
'herbs.require' => '请添加中药',
|
||||
];
|
||||
@@ -68,7 +71,7 @@ class PrescriptionValidate extends BaseValidate
|
||||
|
||||
public function scenePatchPatient()
|
||||
{
|
||||
return $this->only(['id', 'patient_name', 'phone']);
|
||||
return $this->only(['id', 'patient_name', 'phone', 'gender']);
|
||||
}
|
||||
|
||||
public function sceneAudit()
|
||||
|
||||
Reference in New Issue
Block a user