|
|
@@ -72,6 +72,18 @@ class TcmExam < ActiveRecord::Base
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ # 格式化内容,处理换行和 markdown 格式
|
|
|
+ def format_content(content)
|
|
|
+ return "-" if content.blank?
|
|
|
+ # 处理换行符
|
|
|
+ formatted = content.to_s
|
|
|
+ .gsub(/\\n/, "<br>")
|
|
|
+ .gsub(/\n/, "<br>")
|
|
|
+ .gsub(/\*\*([^*]+)\*\*/, '<strong>\1</strong>') # **粗体**
|
|
|
+ .gsub(/\*([^*]+)\*/, '<em>\1</em>') # *斜体*
|
|
|
+ formatted
|
|
|
+ end
|
|
|
+
|
|
|
rails_admin do
|
|
|
navigation_label '中医诊疗记录'
|
|
|
parent ScaleDevice
|
|
|
@@ -185,7 +197,7 @@ class TcmExam < ActiveRecord::Base
|
|
|
exam = bindings[:object]
|
|
|
summary = exam.parsed_ai_summary
|
|
|
content = summary['general'] || summary['summary'] || '-'
|
|
|
- %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{content.to_s.gsub("\n", "<br>")}</div>}.html_safe
|
|
|
+ %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -196,7 +208,7 @@ class TcmExam < ActiveRecord::Base
|
|
|
exam = bindings[:object]
|
|
|
summary = exam.parsed_ai_summary
|
|
|
content = summary['inquiry'] || '-'
|
|
|
- %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{content.to_s.gsub("\n", "<br>")}</div>}.html_safe
|
|
|
+ %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -207,7 +219,7 @@ class TcmExam < ActiveRecord::Base
|
|
|
exam = bindings[:object]
|
|
|
summary = exam.parsed_ai_summary
|
|
|
content = summary['observation'] || '-'
|
|
|
- %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{content.to_s.gsub("\n", "<br>")}</div>}.html_safe
|
|
|
+ %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -218,7 +230,7 @@ class TcmExam < ActiveRecord::Base
|
|
|
exam = bindings[:object]
|
|
|
summary = exam.parsed_ai_summary
|
|
|
content = summary['constitution'] || '-'
|
|
|
- %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{content.to_s.gsub("\n", "<br>")}</div>}.html_safe
|
|
|
+ %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
end
|
|
|
end
|
|
|
|
|
|
@@ -229,7 +241,19 @@ class TcmExam < ActiveRecord::Base
|
|
|
exam = bindings[:object]
|
|
|
summary = exam.parsed_ai_summary
|
|
|
content = summary['advice'] || '-'
|
|
|
- %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{content.to_s.gsub("\n", "<br>")}</div>}.html_safe
|
|
|
+ %Q{<div style="background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ # 总结
|
|
|
+ field :model do
|
|
|
+ label '陆 · 总结'
|
|
|
+ pretty_value do
|
|
|
+ exam = bindings[:object]
|
|
|
+ summary = exam.parsed_ai_summary
|
|
|
+ content = summary['summary']
|
|
|
+ return "-" if content.blank?
|
|
|
+ %Q{<div style="background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: 14px; margin: 10px 0; line-height: 1.7; color: #9a3412;">#{exam.format_content(content)}</div>}.html_safe
|
|
|
end
|
|
|
end
|
|
|
|