|
|
@@ -431,7 +431,7 @@ module.exports = class extends Base { |
|
|
async saveMyInfoAction() { |
|
|
async saveMyInfoAction() { |
|
|
const mpUser = this.mpUser; |
|
|
const mpUser = this.mpUser; |
|
|
if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); |
|
|
if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); |
|
|
const { gender, province_code, city_code, district_code, address, hospital, emergency_contact, emergency_phone, documents, tag, sample_types, wax_return, return_name, return_phone, return_province_code, return_city_code, return_district_code, return_address, report_email, sample_tracking_no, sample_photos, sign_income, sign_privacy, sign_privacy_jhr, sign_promise, income_amount, guardian_name, guardian_id_card, guardian_relation, mp_env_version } = this.post(); |
|
|
|
|
|
|
|
|
const { gender, province_code, city_code, district_code, address, hospital, emergency_contact, emergency_phone, documents, tag, sign_income, sign_privacy, sign_privacy_jhr, sign_promise, income_amount, guardian_name, guardian_id_card, guardian_relation, mp_env_version } = this.post(); |
|
|
const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); |
|
|
const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); |
|
|
if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); |
|
|
if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); |
|
|
if (!province_code || !city_code || !district_code) return this.json({ code: 1, msg: '请选择省市区' }); |
|
|
if (!province_code || !city_code || !district_code) return this.json({ code: 1, msg: '请选择省市区' }); |
|
|
@@ -451,17 +451,6 @@ module.exports = class extends Base { |
|
|
emergency_contact: emergency_contact || '', emergency_phone: emergency_phone || '', |
|
|
emergency_contact: emergency_contact || '', emergency_phone: emergency_phone || '', |
|
|
tag: tag || '', |
|
|
tag: tag || '', |
|
|
documents: JSON.stringify(documents || []), |
|
|
documents: JSON.stringify(documents || []), |
|
|
sample_types: JSON.stringify(sample_types || []), |
|
|
|
|
|
wax_return: (sample_types && sample_types.length && wax_return) ? 1 : 0, |
|
|
|
|
|
return_name: (sample_types && sample_types.length && wax_return) ? (return_name || '') : '', |
|
|
|
|
|
return_phone: (sample_types && sample_types.length && wax_return) ? (return_phone || '') : '', |
|
|
|
|
|
return_province_code: (sample_types && sample_types.length && wax_return) ? (return_province_code || '') : '', |
|
|
|
|
|
return_city_code: (sample_types && sample_types.length && wax_return) ? (return_city_code || '') : '', |
|
|
|
|
|
return_district_code: (sample_types && sample_types.length && wax_return) ? (return_district_code || '') : '', |
|
|
|
|
|
return_address: (sample_types && sample_types.length && wax_return) ? (return_address || '') : '', |
|
|
|
|
|
report_email: (sample_types && sample_types.length) ? (report_email || '') : '', |
|
|
|
|
|
sample_tracking_no: (sample_types && sample_types.length) ? (sample_tracking_no || '') : '', |
|
|
|
|
|
sample_photos: (sample_types && sample_types.length) ? JSON.stringify(sample_photos || []) : '[]', |
|
|
|
|
|
sign_income: sign_income || '', |
|
|
sign_income: sign_income || '', |
|
|
sign_privacy: sign_privacy || '', |
|
|
sign_privacy: sign_privacy || '', |
|
|
sign_privacy_jhr: sign_privacy_jhr || '', |
|
|
sign_privacy_jhr: sign_privacy_jhr || '', |
|
|
@@ -656,6 +645,97 @@ module.exports = class extends Base { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取送检信息(回显) |
|
|
|
|
|
* GET /api/mp/sampleInfo |
|
|
|
|
|
*/ |
|
|
|
|
|
async sampleInfoAction() { |
|
|
|
|
|
const mpUser = this.mpUser; |
|
|
|
|
|
if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); |
|
|
|
|
|
try { |
|
|
|
|
|
const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); |
|
|
|
|
|
if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); |
|
|
|
|
|
const patient = await this.model('patient').where({ id: user.patient_id, is_deleted: 0 }).find(); |
|
|
|
|
|
if (think.isEmpty(patient)) return this.json({ code: 1, msg: '患者信息不存在' }); |
|
|
|
|
|
if (patient.status !== 1) return this.json({ code: 1, msg: '请先通过审核' }); |
|
|
|
|
|
|
|
|
|
|
|
// 查省市区名称 |
|
|
|
|
|
const codes = [patient.province_code, patient.city_code, patient.district_code].filter(Boolean); |
|
|
|
|
|
const regionMap = {}; |
|
|
|
|
|
if (codes.length) { |
|
|
|
|
|
const regions = await this.model('sys_region').where({ code: ['in', codes] }).select(); |
|
|
|
|
|
regions.forEach(r => { regionMap[r.code] = r.name; }); |
|
|
|
|
|
} |
|
|
|
|
|
const regionText = [regionMap[patient.province_code], regionMap[patient.city_code], regionMap[patient.district_code]].filter(Boolean).join(' '); |
|
|
|
|
|
|
|
|
|
|
|
let sampleTypes = []; |
|
|
|
|
|
try { sampleTypes = JSON.parse(patient.sample_types || '[]'); } catch (e) { sampleTypes = []; } |
|
|
|
|
|
let samplePhotos = []; |
|
|
|
|
|
try { samplePhotos = JSON.parse(patient.sample_photos || '[]'); } catch (e) { samplePhotos = []; } |
|
|
|
|
|
|
|
|
|
|
|
return this.json({ code: 0, data: { |
|
|
|
|
|
patient: { |
|
|
|
|
|
name: patient.name, gender: patient.gender, id_card: patient.id_card, |
|
|
|
|
|
phone: patient.phone, address: patient.address, hospital: patient.hospital || '', |
|
|
|
|
|
tag: patient.tag || '', region_text: regionText, |
|
|
|
|
|
province_code: patient.province_code, city_code: patient.city_code, district_code: patient.district_code |
|
|
|
|
|
}, |
|
|
|
|
|
sample_types: sampleTypes, |
|
|
|
|
|
wax_return: patient.wax_return || 0, |
|
|
|
|
|
return_name: patient.return_name || '', |
|
|
|
|
|
return_phone: patient.return_phone || '', |
|
|
|
|
|
return_province_code: patient.return_province_code || '', |
|
|
|
|
|
return_city_code: patient.return_city_code || '', |
|
|
|
|
|
return_district_code: patient.return_district_code || '', |
|
|
|
|
|
return_address: patient.return_address || '', |
|
|
|
|
|
report_email: patient.report_email || '', |
|
|
|
|
|
sample_tracking_no: patient.sample_tracking_no || '', |
|
|
|
|
|
sample_photos: samplePhotos |
|
|
|
|
|
}}); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
think.logger.error('sampleInfo error:', error); |
|
|
|
|
|
return this.json({ code: 1, msg: '获取失败' }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 保存送检信息(不改变审核状态) |
|
|
|
|
|
* POST /api/mp/saveSampleInfo |
|
|
|
|
|
*/ |
|
|
|
|
|
async saveSampleInfoAction() { |
|
|
|
|
|
const mpUser = this.mpUser; |
|
|
|
|
|
if (!mpUser) return this.json({ code: 1009, msg: '请先登录' }); |
|
|
|
|
|
const { sample_types, wax_return, return_name, return_phone, return_province_code, return_city_code, return_district_code, return_address, report_email, sample_tracking_no, sample_photos } = this.post(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const user = await this.model('wechat_user').where({ id: mpUser.id, status: 1 }).find(); |
|
|
|
|
|
if (think.isEmpty(user) || !user.patient_id) return this.json({ code: 1, msg: '请先完成实名认证' }); |
|
|
|
|
|
const patient = await this.model('patient').where({ id: user.patient_id, is_deleted: 0 }).find(); |
|
|
|
|
|
if (think.isEmpty(patient)) return this.json({ code: 1, msg: '患者信息不存在' }); |
|
|
|
|
|
if (patient.status !== 1) return this.json({ code: 1, msg: '请先通过审核' }); |
|
|
|
|
|
|
|
|
|
|
|
const hasSample = sample_types && sample_types.length > 0; |
|
|
|
|
|
await this.model('patient').where({ id: user.patient_id }).update({ |
|
|
|
|
|
sample_types: JSON.stringify(sample_types || []), |
|
|
|
|
|
wax_return: (hasSample && wax_return) ? 1 : 0, |
|
|
|
|
|
return_name: (hasSample && wax_return) ? (return_name || '') : '', |
|
|
|
|
|
return_phone: (hasSample && wax_return) ? (return_phone || '') : '', |
|
|
|
|
|
return_province_code: (hasSample && wax_return) ? (return_province_code || '') : '', |
|
|
|
|
|
return_city_code: (hasSample && wax_return) ? (return_city_code || '') : '', |
|
|
|
|
|
return_district_code: (hasSample && wax_return) ? (return_district_code || '') : '', |
|
|
|
|
|
return_address: (hasSample && wax_return) ? (return_address || '') : '', |
|
|
|
|
|
report_email: hasSample ? (report_email || '') : '', |
|
|
|
|
|
sample_tracking_no: hasSample ? (sample_tracking_no || '') : '', |
|
|
|
|
|
sample_photos: hasSample ? JSON.stringify(sample_photos || []) : '[]' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return this.json({ code: 0, data: {}, msg: '提交成功' }); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
think.logger.error('saveSampleInfo error:', error); |
|
|
|
|
|
return this.json({ code: 1, msg: '保存失败: ' + error.message }); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 批量重新生成声明与承诺签署图并更新数据库 |
|
|
* 批量重新生成声明与承诺签署图并更新数据库 |
|
|
* GET /api/mp/regenerateSign |
|
|
* GET /api/mp/regenerateSign |
|
|
|