Files
vueapp/dist/assets/cases.i-QLayjn.js
T
2026-06-15 18:04:01 +08:00

2 lines
3.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{D as e,s as t,P as n,C as r}from"./index-DGiVEDOl.js";import{a as i,A as c}from"./auth.vuBox8Gk.js";const a={recommended:"/case/mobile/recommended/",specialty:"/case/mobile/specialty/",weak:"/case/mobile/weak/",teaching:"/case/mobile/teaching/","teacher-task":"/case/mobile/teacher-task/"},o=["blue","teal","pink","orange","purple","green"];async function s(e="recommended",t={}){const n=a[e]||a.recommended,s=await function(e,t){return new Promise(((n,a)=>{r({url:`${i}${y(e,t)}`,method:"GET",timeout:1e4,header:f(),success:e=>{if(e.statusCode>=200&&e.statusCode<300)return void n(e.data);const t=e.data,r="string"==typeof(null==t?void 0:t.code)?t.code:void 0;a(new c(function(e,t){if(e&&"object"==typeof e){const t=e,n=t.message||t.detail||t.error;if("string"==typeof n&&n.trim())return n}return t}(e.data,`病例列表加载失败(${e.statusCode}`),r,e.statusCode))},fail:e=>{a(new c(e.errMsg||"无法连接服务"))}})}))}(n,t),u=function(e,t){const n=Array.isArray(e.results)?e.results:[];return{count:b(e.count,n.length),next:"string"==typeof e.next?e.next:null,previous:"string"==typeof e.previous?e.previous:null,results:n.map(((e,n)=>function(e,t,n){const r=h(e.id,`case-${n+1}`),i=h(e.title,"未命名病例"),c=(p=e.patient_gender,"female"===p||"女"===p?"女":"男"),a=h(e.department_name,"未配置科室"),s=h(e.case_type),u=h(e.case_type_display,s||"练习病例"),l=h(e.chief_complaint,i),m="teaching"===t||"teaching"===s?"teaching":"training";var p;return{id:r,title:i,patientName:"女"===c?"患者女士":"患者先生",gender:c,age:b(e.patient_age,0),department:a,departmentId:_(e.department),scene:u,caseNo:r,tone:o[n%o.length],mode:m,caseType:s,caseTypeDisplay:u,difficulty:h(e.difficulty),difficultyScore:_(e.difficulty_score),chiefComplaint:l,description:h(e.description),tags:h(e.tags),competencyTags:Array.isArray(e.competency_tags)?e.competency_tags.map(String):[],estimatedMinutes:_(e.estimated_minutes),osceEnabled:Boolean(e.osce_enabled),myBestScore:"number"==typeof e.my_best_score?e.my_best_score:null,myTrainCount:"number"==typeof e.my_train_count?e.my_train_count:null,createdAt:h(e.created_at),source:t}}(e,t,n)))}}(s,e);return u}function u(e){t("clinical-thinking-prefetched-case-list",e)}function l(){n("clinical-thinking-prefetched-case-list")}function m(t,n){const r=e("clinical-thinking-prefetched-case-list");if(!function(e){if(!e||"object"!=typeof e)return!1;const t=e;return function(e){return"recommended"===e||"specialty"===e||"weak"===e||"teaching"===e||"teacher-task"===e}(t.source)&&"object"==typeof t.query&&null!==t.query&&!!t.page&&"object"==typeof t.page&&Array.isArray(t.page.results)&&"number"==typeof t.cachedAt}(r))return null;return Date.now()-r.cachedAt<=6e4?r.source===t&&(i=r.query,c=n,["search","case_type","difficulty","department","page","page_size"].every((e=>g(i[e])===g(c[e]))))?(l(),r.page):null:(l(),null);var i,c}function p(){const t=e("clinical-thinking-selected-case");return t&&"object"==typeof t?t:null}function d(e){if(!e)return 0;const t=Number(e.id);if(Number.isInteger(t)&&t>0)return t;const n=Number(e.caseNo);if(Number.isInteger(n)&&n>0)return n;const r=String(e.id).match(/\d+/),i=r?Number(r[0]):0;return Number.isInteger(i)&&i>0?i:0}function f(){const t={"Content-Type":"application/json",Accept:"application/json"},n=function(){try{const t=e("clinical-thinking-access-token");return"string"==typeof t?t.trim():""}catch{return""}}();return n&&(t.Authorization=`Bearer ${n}`),t}function y(e,t){const n=Object.entries(t).filter((([,e])=>null!=e&&""!==e)).map((([e,t])=>`${encodeURIComponent(e)}=${encodeURIComponent(String(t))}`)).join("&");return n?`${e}?${n}`:e}function g(e){return null==e||""===e?"":String(e)}function h(e,t=""){return"string"==typeof e?e.trim()||t:"number"==typeof e?String(e):t}function b(e,t=0){const n=Number(e);return Number.isFinite(n)?n:t}function _(e){const t=Number(e);return Number.isFinite(t)?t:void 0}export{d as a,l as c,s as f,p as r,u as s,m as t};