tongue-analysis,model.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * 解析舌象异常数据
  3. * @param {{title: string; cover: string; descriptions: string[]; tags: string[];}[]} exception
  4. * @param {{actualList: Record<string, any>[]}} [data]
  5. * @return {string}
  6. */
  7. function fromReportTongueExceptionData(exception, data) {
  8. if (data == null || !Array.isArray(data.actualList)) return '';
  9. return data.actualList.map(item => {
  10. if (!item) return '';
  11. let title = item.actualValue || '';
  12. const suffix = item.contrast || 's';
  13. if (suffix !== 's') {
  14. title += ` (${suffix || ''}) `;
  15. exception.push({
  16. title, cover: item.splitImage,
  17. descriptions: [
  18. item.features ? `【特征】${item.features}` : '',
  19. item.clinicalSignificance ? `【临床意义】${item.clinicalSignificance}` : '',
  20. ].filter(Boolean),
  21. tags: item.attrs ?? [],
  22. });
  23. }
  24. return title;
  25. }).join('<br>');
  26. }
  27. /**
  28. * 解析舌面象数据
  29. * @param {Record<string, any>} data
  30. */
  31. export function fromTongueAndFaceAnalysisModel(data) {
  32. if (data == null || typeof data !== 'object') data = {};
  33. const tongueException = [];
  34. const fromTongueException = fromReportTongueExceptionData.bind(null, tongueException);
  35. const fromTongueValue = (data) => data && typeof data === 'object' ? data.standardValue || '' : '';
  36. return {
  37. tongueTable: {
  38. column: ['舌象维度', '检测结果', '标准值'],
  39. data: [
  40. ['舌色', fromTongueException(data.tongueColor), fromTongueValue(data.tongueColor)],
  41. ['苔色', fromTongueException(data.tongueCoatingColor), fromTongueValue(data.tongueCoatingColor)],
  42. ['舌形', fromTongueException(data.tongueShape), fromTongueValue(data.tongueShape)],
  43. ['苔质', fromTongueException(data.tongueCoating), fromTongueValue(data.tongueCoating)],
  44. ['津液', fromTongueException(data.bodyFluid), fromTongueValue(data.bodyFluid)],
  45. ['舌下', fromTongueException(data.sublingualVein), fromTongueValue(data.sublingualVein)],
  46. ],
  47. },
  48. tongueException,
  49. tongueAnalysis: {
  50. ['结果']: data.tongueAnalysisResult,
  51. ['舌上']: data.upImg,
  52. ['舌下']: data.downImg,
  53. },
  54. faceAnalysis: {
  55. ['结果']: data.faceAnalysisResult,
  56. ['面象']: data.faceImg,
  57. },
  58. }
  59. }