| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- import {checkReasonableSafeMedicinesMethod} from '@/api/prescription';
- const reasonableSafeMap = [{
- type: '2', label: `慎忌禁用药`, key: 'matsjj', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `(${{1: '慎用', 2: '忌用', 3: '禁用'}[value] || '---'})`,
- };
- },
- }, {
- type: '3', label: `孕妇慎忌禁`, key: 'matyfsjj', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `(${{1: '孕妇慎用', 2: '孕妇忌用', 3: '孕妇禁用'}[value] || '---'})`,
- signName: +value === 3,
- };
- },
- }, {
- type: '4', label: `服药饮食禁忌`, key: 'matysjj', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `(${value || '无'})`,
- };
- },
- }, {
- type: '5', label: `药物毒性说明`, key: 'matdxsm', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `(${value || '无'})`,
- signName: true,
- };
- },
- }, {
- type: '6', label: `病证用药禁忌`, key: 'matbzjj', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `(${value || '无'})`,
- };
- },
- }, {
- type: '7', label: `十八反`, key: 'matsbf', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `反 ${value}`, signName: true,
- };
- },
- }, {
- type: '8', label: `十九畏`, key: 'matsjw', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `畏 ${value}`, signName: true,
- };
- },
- }, {
- type: '9', label: `用药不宜`, key: 'matby', handle(medicine, value) {
- return {
- name: medicine['matname'] || medicine.$name,
- description: `不宜与 ${value} 同用`,
- };
- },
- }, {
- type: '10', label: `超剂量药品`, key: ['matmindosage', 'matmaxdosage', '$dosage'], handle(medicine, [min, max]) {
- const dosage = medicine.$baseDosage;
- return dosage < min || dosage > max ? {
- name: medicine['matname'] || medicine.$name, description: `(${min}~${max})`, signDescription: true,
- } : void 0;
- },
- }];
- /**
- * @description
- * 2:慎 忌 禁
- * 3:孕慎 孕忌 孕禁
- * 4:服药饮食禁忌
- * 5:药物毒性说明
- * 6:病证用药禁忌
- * 7:十八反
- * 8:十九畏
- * 9:用药不宜
- * 10:超剂量药品
- * @param medicines
- * @param {object} config
- * @param {string} [config.filter]
- * @param {string} [config.sort = '10,2,3,4,5,6,7,8,9']
- * @param {boolean} [config.force = true]
- * @param {object} [config.platform ]平台数据
- * @param {string} [config.platform.organization] 平台机构 - ID
- */
- export async function getReasonableSafeData(medicines, config = {}) {
- // const
- const filter = (config.filter || '').split(',').filter(Boolean);
- const sort = (config.filter || config.sort || '10,2,3,4,5,6,7,8,9').split(',').filter(Boolean);
- const {force = true} = config;
- if (force) await checkReasonableSafeMedicinesMethod(medicines, config.platform);
- const rs = {
- * [Symbol.iterator]() { for (const key of sort) if (this[key]) yield this[key]; },
- toString() {
- let html = ``;
- for (const {label, collection} of this) {
- html += `
- <div class="item"> \
- <div class="label">${label}:</div> \
- ${collection.map(item => `<div>
- <span class="name ${item.signName ? 'sign' : ''}">${item.name}</span> \
- <span class="description ${item.signDescription ? 'sign' : ''}">${item.description}</span> \
- </div>`).join('')}
- </div>
- `;
- }
- return html;
- },
- };
- for (const medicine of medicines) {
- if (medicine.editing) continue;
- for (const {key, type, label, handle, ...props} of reasonableSafeMap) {
- if (filter.length && !filter.includes(type)) continue;
- const keys = Array.isArray(key) ? key : [key];
- const values = keys.map(key => medicine[key]);
- if (values.some(value => !value)) continue;
- const data = handle(medicine, typeof key === 'string' ? values[0] : values);
- if (data == null) continue;
- const child = rs[type] || (rs[type] = {...props, type, label, collection: []});
- child.collection.push(data);
- }
- }
- return rs;
- }
|