更新
This commit is contained in:
@@ -132,10 +132,13 @@ class WebSettingLogic extends BaseLogic
|
||||
{
|
||||
$serviceContent = clear_file_domain($params['service_content'] ?? '');
|
||||
$privacyContent = clear_file_domain($params['privacy_content'] ?? '');
|
||||
$healthContent = clear_file_domain($params['health_content'] ?? '');
|
||||
ConfigService::set('agreement', 'service_title', $params['service_title'] ?? '');
|
||||
ConfigService::set('agreement', 'service_content', $serviceContent);
|
||||
ConfigService::set('agreement', 'privacy_title', $params['privacy_title'] ?? '');
|
||||
ConfigService::set('agreement', 'privacy_content', $privacyContent);
|
||||
ConfigService::set('agreement', 'health_title', $params['health_title'] ?? '');
|
||||
ConfigService::set('agreement', 'health_content', $healthContent);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,11 +155,13 @@ class WebSettingLogic extends BaseLogic
|
||||
'service_content' => ConfigService::get('agreement', 'service_content'),
|
||||
'privacy_title' => ConfigService::get('agreement', 'privacy_title'),
|
||||
'privacy_content' => ConfigService::get('agreement', 'privacy_content'),
|
||||
'health_title' => ConfigService::get('agreement', 'health_title'),
|
||||
'health_content' => ConfigService::get('agreement', 'health_content'),
|
||||
];
|
||||
|
||||
$config['service_content'] = get_file_domain($config['service_content']);
|
||||
$config['privacy_content'] = get_file_domain($config['privacy_content']);
|
||||
|
||||
$config['health_content'] = get_file_domain($config['health_content']);
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
@@ -403,6 +403,50 @@ class DiagnosisLogic extends BaseLogic
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 补全身份证号(自动计算年龄并更新)
|
||||
* @param array $params id, id_card
|
||||
* @return bool
|
||||
*/
|
||||
public static function fillIdCard(array $params): bool
|
||||
{
|
||||
try {
|
||||
$diagnosis = Diagnosis::find($params['id']);
|
||||
if (!$diagnosis) {
|
||||
self::setError('诊单不存在');
|
||||
return false;
|
||||
}
|
||||
$idCard = trim($params['id_card']);
|
||||
$len = strlen($idCard);
|
||||
if ($len === 15) {
|
||||
$birthYear = 1900 + (int)substr($idCard, 6, 2);
|
||||
$birthMonth = (int)substr($idCard, 8, 2);
|
||||
$birthDay = (int)substr($idCard, 10, 2);
|
||||
} elseif ($len === 18 && preg_match('/^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/', $idCard)) {
|
||||
$birthYear = (int)substr($idCard, 6, 4);
|
||||
$birthMonth = (int)substr($idCard, 10, 2);
|
||||
$birthDay = (int)substr($idCard, 12, 2);
|
||||
} else {
|
||||
self::setError('身份证号格式不正确');
|
||||
return false;
|
||||
}
|
||||
// 从身份证提取出生日期计算年龄
|
||||
$today = getdate();
|
||||
$age = $today['year'] - $birthYear;
|
||||
if ($today['mon'] < $birthMonth || ($today['mon'] == $birthMonth && $today['mday'] < $birthDay)) {
|
||||
$age--;
|
||||
}
|
||||
$age = max(0, min(150, $age));
|
||||
$diagnosis->id_card = $idCard;
|
||||
$diagnosis->age = $age;
|
||||
$diagnosis->save();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 指派医助
|
||||
* @param array $params
|
||||
@@ -954,21 +998,28 @@ class DiagnosisLogic extends BaseLogic
|
||||
*/
|
||||
public static function generateMiniProgramQrcode(array $params)
|
||||
{
|
||||
|
||||
try {
|
||||
$diagnosisId = $params['diagnosis_id'];
|
||||
$diagnosisId = $params['diagnosis_id'] ?? '';
|
||||
$doctorId = $params['doctor_id'] ?? '';
|
||||
$patientId = $params['patient_id'];
|
||||
$shareUserId = $params['share_user_id'];
|
||||
|
||||
// 视频登录页(pages/login/login)需要传挂号医生id,其余场景传诊单id
|
||||
$page = !empty($params['mini_program_path']) ? $params['mini_program_path'] : 'pages/order/monad/monad';
|
||||
$sceneId = ($page === 'pages/login/login' && !empty($doctorId)) ? $doctorId : $diagnosisId;
|
||||
if (empty($sceneId)) {
|
||||
throw new \Exception($page === 'pages/login/login' ? '挂号医生ID不能为空' : '诊单ID不能为空');
|
||||
}
|
||||
|
||||
// 获取小程序配置
|
||||
$config = self::getMiniProgramConfig();
|
||||
if (!$config) {
|
||||
throw new \Exception('小程序配置未设置');
|
||||
}
|
||||
|
||||
// 构建小程序路径和参数(前端可传 mini_program_path 覆盖默认路径)
|
||||
$page = !empty($params['mini_program_path']) ? $params['mini_program_path'] : 'pages/order/monad/monad';
|
||||
$scene = "id={$diagnosisId}&share_user={$shareUserId}";
|
||||
|
||||
$scene = "id={$sceneId}&share_user={$shareUserId}";
|
||||
|
||||
// 调用微信接口生成小程序码
|
||||
$qrcodeUrl = self::generateWxQrcode($config, $page, $scene);
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ class PrescriptionLogic
|
||||
'clinical_diagnosis' => $params['clinical_diagnosis'] ?? '',
|
||||
'herbs' => $herbs,
|
||||
'dose_count' => (int)($params['dose_count'] ?? 1),
|
||||
'dose_unit' => $params['dose_unit'] ?? '剂',
|
||||
'usage_instruction' => $params['usage_instruction'] ?? '水煎服一日二次',
|
||||
'amount' => (float)($params['amount'] ?? 0),
|
||||
'doctor_name' => $params['doctor_name'] ?? '',
|
||||
@@ -121,4 +122,25 @@ class PrescriptionLogic
|
||||
->find();
|
||||
return $row ? $row->toArray() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 作废处方
|
||||
*/
|
||||
public static function void(int $id, int $adminId, string $adminName): bool
|
||||
{
|
||||
$row = Prescription::find($id);
|
||||
if (!$row) {
|
||||
self::setError('处方不存在');
|
||||
return false;
|
||||
}
|
||||
if ((int)($row->void_status ?? 0) === 1) {
|
||||
self::setError('该处方已作废');
|
||||
return false;
|
||||
}
|
||||
$row->void_status = 1;
|
||||
$row->void_time = time();
|
||||
$row->void_by = $adminId;
|
||||
$row->void_by_name = $adminName;
|
||||
return $row->save();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user