diagnosis.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. import request from '@/utils/request.js'
  2. import {fromAnalysisModel} from "@/model/tongue-analysis.model";
  3. import {removeRedundantSemicolons} from '@/api/hack';
  4. import {generateUUID} from '@/utils';
  5. // 获取就诊病人信息
  6. export function getPatiiensMsg(data) {
  7. return request({
  8. url: `/outpatient/recordsMgr/${data}`,
  9. method: 'get',
  10. })
  11. };
  12. // 获取中医电子病历回显信息
  13. export function getEmrShowMsg(data) {
  14. return request({
  15. url: `/outpatient/electronicmedicalrecordMgr/infoByRecordsId?recordsId=${data.recordsId}`,
  16. method: 'post',
  17. data
  18. })
  19. };
  20. // 获取自然语义分析 中医电子病历回显信息
  21. export function getNLP_TemplateResult(text) {
  22. const [_, method, url ] = (window.SIX_config.NLP_GET_URL || '').match(/^(?:\[(\w*)])?\s*(.*)?/) || [];
  23. return request({
  24. url: url || `https://dev.hzliuzhi.com:62006/tcm_chat/json/record`,
  25. method: method || 'post',
  26. data: {
  27. message: text,
  28. },
  29. meta: { ignoreResponse: true },
  30. }).then(res => {
  31. if (res.code === 200) {
  32. const {fourmedicine: value, ...data} = res.data;
  33. return {
  34. ...data,
  35. echoData: value ? typeof value === 'string' ? value : JSON.stringify(value) : '{}',
  36. };
  37. }
  38. throw new Error(res.message);
  39. });
  40. }
  41. export function getASR_Token() {
  42. try {
  43. let token = localStorage.getItem('ASR_TOKEN');
  44. if (token) {
  45. const proof = JSON.parse(token);
  46. if (Math.round(Date.now() / 1000) < proof.expireTime) return proof;
  47. }
  48. } catch (e) {}
  49. const [_, method, url ] = (window.SIX_config.SST_TOKEN_URL || '').match(/^(?:\[(\w*)])?\s*(.*)?/) || [];
  50. return request({
  51. url: url || `https://dev.hzliuzhi.com:62006/tcm_chat/asr/token`,
  52. method: method || 'get',
  53. meta: { ignoreResponse: true },
  54. }).then(res => {
  55. if (res.code === 200) {
  56. if (!res.data.appKey) res.data.appKey = `zF5fGsgjoAXnL7F3`;
  57. localStorage.setItem('ASR_TOKEN', JSON.stringify(res.data));
  58. return res.data;
  59. }
  60. localStorage.removeItem('ASR_TOKEN');
  61. throw new Error(res.message);
  62. });
  63. }
  64. export function connectASR_WebSocket(proof) {
  65. return new WebSocket(`wss://nls-gateway.cn-shanghai.aliyuncs.com/ws/v1?token=${proof.token}`);
  66. }
  67. // 提交诊断页面数据
  68. export function addDiagnosisData(data) {
  69. return request({
  70. url: '/outpatient/diagnosisMgr/Add',
  71. method: 'post',
  72. data
  73. })
  74. };
  75. export function addDiagnosisData2(data) {
  76. return request({
  77. url: '/outpatient/diagnosisMgr/Add',
  78. method: 'post',
  79. data,
  80. }).then(res => {
  81. if (res.ResultCode !== 0) throw Error(res.ResultInfo || `错误`);
  82. if (!res.Data.mainDiagnosis) return {mainDiagnosis: res.Data};
  83. return res.Data;
  84. });
  85. }
  86. // 修改诊断页面数据
  87. export function editDiagnosisData(data) {
  88. return request({
  89. url: '/outpatient/diagnosisMgr/update',
  90. method: 'post',
  91. data
  92. })
  93. };
  94. // 开方获取患者基本信息
  95. export function getPatiensBasisM(data) {
  96. return request({
  97. url: '/test/outpatient/patientBaseInfo?patientId=' + data.patientId,
  98. method: 'post',
  99. // data
  100. }).then(res => removeRedundantSemicolons(res));
  101. };
  102. // 刷新电子病历信息
  103. export function refreshElectronicInfo(data) {
  104. return request({
  105. url: '/test/outpatient/refreshElectronicInfo?patientId=' + data.patientId,
  106. method: 'post',
  107. ignoreErrorMessage: '请重试',
  108. }).then(res => {
  109. if (res.ResultCode !== 0) throw Error(res.ResultInfo || `请重试`);
  110. if (res.Data == null) throw Error(`暂无新数据,请稍后刷新`);
  111. const {pulseDiagnosisReportVo, ..._data} = res.Data;
  112. const data = removeRedundantSemicolons(_data);
  113. return data.outpatientElectronicmedicalrecord != null ? data : {
  114. outpatientElectronicmedicalrecord: data,
  115. pulseDiagnosisReportVo,
  116. };
  117. });
  118. }
  119. // 获取表格 药品列表
  120. export function getTableDrug(data, isPurposeType = false) {
  121. if (isPurposeType) {
  122. data.name = data.key;
  123. return request({
  124. url: '/basis/stitutionsdrugMgr/materialQuery',
  125. method: 'post',
  126. data
  127. }).then(res => {
  128. const data = Array.isArray(res.Data) ? res.Data : [];
  129. res.Data = {
  130. TotalRecordCount: data.length,
  131. TotalPageCount: 1,
  132. PageSize: data.length,
  133. ButtonRight: "",
  134. CurrentPageSize: data.length,
  135. PageIndex: 1,
  136. Items: data.map(item => {
  137. return {
  138. pid: item.drugId,
  139. matid: item.drugId,
  140. ypmc: item.name,
  141. gg: item.gg,
  142. dw: item.dw,
  143. price: item.price || '',
  144. }
  145. })
  146. };
  147. return res;
  148. })
  149. }
  150. return request({
  151. url: '/test/outpatient/selectDrug?page=' + data.page + '&limit=' + data.limit,
  152. method: 'post',
  153. data
  154. })
  155. };
  156. //添加处方
  157. export function addRecipe(data) {
  158. return request({
  159. url: '/test/outpatient/addOutPatient',
  160. method: 'post',
  161. data
  162. })
  163. };
  164. //获取诊断页 回显数据
  165. export function getDiagnosisShowData(data) {
  166. return request({
  167. url: '/outpatient/diagnosisMgr/infoByRecordsId?recordsId=' + data.recordsId,
  168. method: 'post',
  169. })
  170. };
  171. // 获取处方回显数据
  172. export function getRecipeShowData(data) {
  173. return request({
  174. url: '/test/outpatient/getPrescription/' + data,
  175. method: 'get'
  176. })
  177. };
  178. // 通过 处方id 获取处方回显数据
  179. export function getRecipeDataByid(data) {
  180. return request({
  181. url: `/outpatient/patientprescriptionMgr/${data.pid}`,
  182. method: 'get'
  183. })
  184. };
  185. // 添加中医电子病历
  186. export function addEMR(data) {
  187. return request({
  188. url: '/outpatient/electronicmedicalrecordMgr/Add',
  189. method: 'post',
  190. data: removeRedundantSemicolons(data),
  191. })
  192. };
  193. // 修改中医电子病历信息
  194. export function editEMR(data) {
  195. return request({
  196. url: '/outpatient/electronicmedicalrecordMgr/update',
  197. method: 'post',
  198. data: removeRedundantSemicolons(data),
  199. })
  200. };
  201. // 回传his
  202. export function backToHis(data) {
  203. return request({
  204. url: '/outpatient/electronicmedicalrecordMgr/electronicmedicalRecordsReturnHis',
  205. method: 'post',
  206. data
  207. })
  208. }
  209. // 寄到本院 获取地址
  210. export function getAddressForHospital(data) {
  211. return request({
  212. url: '/test/outpatient/getAddress',
  213. method: 'post',
  214. data
  215. })
  216. }
  217. // 获取体质辨识列表接口
  218. export function getPhysicalList(data) {
  219. return request({
  220. url: '/outpatient/identificationMgr/listPain?page=' + data.page + '&limit=' + data.limit + '&name=' + data.name,
  221. method: 'post',
  222. data
  223. })
  224. };
  225. // 获取某i个用户的体质辨识记录
  226. export function getUserPhysicList(data) {
  227. return request({
  228. url: '/outpatient/identificationMgr/listPainInfo?patientId=' + data.patientId + '&limit=' + data.limit + '&page=' + data.page,
  229. method: 'post',
  230. data
  231. })
  232. };
  233. //体质辨识 添加
  234. export function addPhysicalList(data) {
  235. return request({
  236. url: '/outpatient/identificationMgr/Add',
  237. method: 'post',
  238. data
  239. })
  240. };
  241. // 获取体质辨识 详情
  242. export function getPhysicalDetail(data) {
  243. return request({
  244. url: `/outpatient/identificationresultMgr/${data.identid}`,
  245. method: 'get'
  246. })
  247. };
  248. // 获取体质辨识 详情
  249. export function getPhysicalDetailGy(data) {
  250. return request({
  251. url: `/outpatient/identificationMgr/selecthealthInterventionBydentificationId?dentificationId=${data.dentificationId}`,
  252. method: 'post',
  253. data
  254. })
  255. };
  256. // 提交体质辨识 医生建议
  257. export function submitDoctorjy(data) {
  258. return request({
  259. url: '/outpatient/identificationresultMgr/update',
  260. method: 'post',
  261. data
  262. })
  263. };
  264. // 提交健康干预
  265. export function submitDoctorGy(data) {
  266. return request({
  267. url: '/outpatient/identificationMgr/SavehealthIntervention',
  268. method: 'post',
  269. data
  270. })
  271. }
  272. // 删除体质辨识记录
  273. export function deletePhysicRecord(data) {
  274. return request({
  275. url: '/outpatient/identificationMgr/BatchDelete?ids=' + data.ids,
  276. method: 'post',
  277. data
  278. })
  279. };
  280. //根据选择的中药类型查询所属药房id
  281. export function getPharmacyID(data) {
  282. return request({
  283. url: '/basis/pharmacyMgr/getPidBytype?type=' + data.type,
  284. method: 'post',
  285. data
  286. })
  287. };
  288. // 切换药房 id
  289. export function changePharmacy(data) {
  290. if (data && Array.isArray(data.drugIds) && data.drugIds.length === 0) return Promise.resolve({
  291. "Data": [],
  292. "ResultInfo": "操作成功",
  293. "ResultCode": 0
  294. });
  295. return request({
  296. url: '/test/outpatient/changeDrug',
  297. method: 'post',
  298. data
  299. })
  300. };
  301. // 获取开方界面协定方数据
  302. export function getAgreeRecipe(data) {
  303. return request({
  304. url: '/test/outpatient/getPres?page=' + data.pageId + '&limit=' + data.pageSize,
  305. method: 'post',
  306. data
  307. })
  308. };
  309. // 根绝就诊记录id 获取就诊信息
  310. export function getSeeDByID(data) {
  311. return request({
  312. url: '/test/outpatient/byRecId',
  313. method: 'get',
  314. params: data
  315. })
  316. };
  317. // 获取病历详情数据
  318. export function getRecordDetail(data) {
  319. return request({
  320. url: '/outpatient/CaseManagement/' + data.id,
  321. method: 'get',
  322. params: data
  323. })
  324. }
  325. // 获取药品详细信息
  326. export function getDrugDetail(data) {
  327. return request({
  328. url: '/basis/stitutionsdrugMgr/stiDrugInfo?stiDrugId=' + data.stiDrugId,
  329. method: 'post',
  330. data
  331. })
  332. };
  333. //开方界面获取协定方详细信息
  334. export function getAccordDetail(data) {
  335. return request({
  336. url: '/test/outpatient/preInfo',
  337. method: 'get',
  338. params: data
  339. })
  340. };
  341. // 获取我最常用
  342. export function getMyOfenUse(data) {
  343. return request({
  344. url: '/test/outpatient/myused',
  345. method: 'get',
  346. params: data
  347. })
  348. };
  349. //协定方 转方 判断
  350. export function changeBasisPre(data) {
  351. return request({
  352. url: '/test/outpatient/changeBasisPre',
  353. method: 'post',
  354. data
  355. })
  356. };
  357. //专家经验转方判断
  358. export function changeExpre(data) {
  359. return request({
  360. url: '/test/outpatient/changeExpPre',
  361. method: 'post',
  362. data
  363. })
  364. }
  365. // 处方修改
  366. export function updateRecipe(data) {
  367. return request({
  368. url: '/test/outpatient/update',
  369. method: 'post',
  370. data
  371. })
  372. };
  373. // 开方页面选择药房
  374. export function customerQuery(data) {
  375. return request({
  376. url: "/basis/pharmacyMgr/customerQuery?type=" + data.type,
  377. method: 'post',
  378. data
  379. })
  380. }
  381. //智能辨证 问卷临时存储
  382. export function znQuestionSave(data) {
  383. return request({
  384. url: '/smartDialecticalQuestionnaireTempSave/tempSave',
  385. method: 'post',
  386. data
  387. })
  388. }
  389. // 只能辨证 问卷回显
  390. export function znQusetionShow(data) {
  391. return request({
  392. url: `/smartDialecticalQuestionnaireTempSave/echoData/${data.recordId}`,
  393. method: 'get',
  394. params: data
  395. })
  396. };
  397. // 处方是否支付
  398. export function recipeIsPay(params) {
  399. return request({
  400. url: `/outpatient/pay/checkPrescriptionPaymentStatus`, //params.preId // ${JSON.stringify(params)}
  401. method: 'post',
  402. // params
  403. data: params
  404. })
  405. }
  406. // 根据就诊记录id 查询 是否有处方
  407. export function getPreNumber(params) {
  408. return request({
  409. url: `/outpatient/recordsMgr/getPrescriptionNumberByRecordId/${params.pid}`,
  410. method: 'get',
  411. params
  412. })
  413. }
  414. // 获取药房 共享药房和 本地药房id
  415. export function getPharmacyIDS(params) {
  416. return request({
  417. url: `/basis/pharmacyMgr/getPharmacyIds`,
  418. method: 'get',
  419. params
  420. })
  421. }
  422. // 提交处方预览
  423. export function getRecipePriview(data) {
  424. return request({
  425. url: `/test/outpatient/addOutPatientPreview`,
  426. method: 'post',
  427. data
  428. })
  429. }
  430. // 获取中药制剂 包装单位
  431. export function getBzdw(params) {
  432. return request({
  433. url: '/test/outpatient/getBZDW',
  434. method: 'get',
  435. params
  436. })
  437. }
  438. // 获取健康跟踪记录 详情
  439. export function getHealthTrack(data) {
  440. return request({
  441. url: '/outpatient/identificationMgr/getHealthTrackingRecordBydentificationId?page=' + data.page + '&limit=' + data.limit + '&dentificationId=' + data.dentificationId,
  442. method: 'post',
  443. data
  444. })
  445. }
  446. // 新增健康跟踪记录
  447. export function addHealthTrack(data) {
  448. return request({
  449. url: '/outpatient/identificationMgr/addHealthTrackingRecord',
  450. method: 'post',
  451. data
  452. })
  453. }
  454. // 获取主要体质
  455. export function getMainPhysical(data) {
  456. return request({
  457. url: '/outpatient/identificationMgr/getAnalysisGroupItemName',
  458. method: 'get'
  459. })
  460. }
  461. // 中医体质统计分析
  462. export function getPhysicalTotalList(data) {
  463. return request({
  464. url: '/outpatient/identificationMgr/statisticalList?page=' + data.page + '&limit=' + data.limit,
  465. method: 'post',
  466. data
  467. })
  468. }
  469. // 中医体质统计分析导出
  470. export function exportPhysicalTotal(data) {
  471. return request({
  472. url: '/outpatient/identificationMgr/statisticalListExport?page=' + data.page + '&limit=' + data.limit,
  473. method: 'post',
  474. data
  475. })
  476. }
  477. // 中医体质分析详情 生成PDF
  478. export function createPdf(data) {
  479. return request({
  480. url: '/PDF/PDF',
  481. method: 'post',
  482. data
  483. })
  484. }
  485. // 查询是否健康干预锅
  486. export function findIsHealthGY(data) {
  487. return request({
  488. url: `/outpatient/identificationresultMgr/healthInterventionOrNot/${data.identid}`,
  489. method: 'get',
  490. params: data
  491. })
  492. }
  493. // 获取医保规则最大(最小)药味数
  494. export function getMaxMinDoaseNumber(data) {
  495. return request({
  496. url: '/basis/medicalInsuranceRegulationMgr/minimumAndMaximumDosageNumber',
  497. method: 'post',
  498. data
  499. })
  500. }
  501. // 获取合理安全用药规则
  502. export async function getRationalSafeUse() {
  503. return request({
  504. url: '/basis/medicalInsuranceRegulationMgr/minimumAndMaximumDosageNumber',
  505. method: 'post',
  506. })
  507. }
  508. export function getTongueAndFaceAnalysis(data) {
  509. return request({
  510. url: '/outpatient/electronicmedicalrecordMgr/getTongueFaceAnalysisResult',
  511. method: 'post',
  512. data,
  513. params: {recordsId: data.recordsId},
  514. }).then(res => {
  515. if (res.ResultCode == 0) {
  516. const tongue = fromAnalysisModel('tongue', res.Data);
  517. const face = fromAnalysisModel('face', res.Data);
  518. return res.Data = {
  519. id: res.Data.recordsid,
  520. time: res.Data.recordstime,
  521. tongue,
  522. face,
  523. cover: [tongue ? tongue.cover : null, face ? face.cover : null].filter(Boolean).flatMap(item => item),
  524. }, res;
  525. } else {
  526. throw res
  527. }
  528. })
  529. }
  530. export function getTongueAndFaceAnalysisRecords(patientId, page = 1, limit = 6) {
  531. // patientId = '8d12c55e-7a29-45f3-804d-ed12b0e27660'
  532. return request({
  533. url: '/outpatient/electronicmedicalrecordMgr/getRecordTfs',
  534. method: 'post',
  535. params: {patientId, page, limit},
  536. }).then(res => {
  537. if (res.ResultCode == 0) {
  538. return {
  539. total: res.Data.TotalRecordCount,
  540. data: res.Data.Items.map(item => {
  541. const tongue = fromAnalysisModel('tongue', item);
  542. const face = fromAnalysisModel('face', item);
  543. return {
  544. id: item.recordsid,
  545. time: item.recordstime,
  546. tongue,
  547. face,
  548. cover: [tongue ? tongue.cover : null, face ? face.cover : null].filter(Boolean).flatMap(item => item),
  549. }
  550. }),
  551. }
  552. } else {
  553. throw res
  554. }
  555. })
  556. }