request.ts 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { Get, Post } from "../../lib/request/method";
  2. export function getNotDealLists() {
  3. return Post('/surplus/getPatientPendingWorks', {}, {
  4. transform({ data }: AnyObject) {
  5. return Array.isArray(data) ? data.map(item => ({
  6. ...item,
  7. })) : [];
  8. }
  9. })
  10. }
  11. export function getPatients(id?: string) {
  12. id ??= wx.getStorageSync('patientId')
  13. const transform = ({ data }: AnyObject) => {
  14. const patient = void 0
  15. ?? data.find((item: AnyObject) => item.patientId == id)
  16. ?? data.find((item: AnyObject) => item.isDefault?.toUpperCase() === 'Y')
  17. ?? data[0];
  18. return { patient, patients: data }
  19. }
  20. return Post('/mobileAccountManage/getPatsByAid', {}, { transform })
  21. }
  22. export async function getPatientDescription(patient: { sex: '0' | '1'; patientId: string; }) {
  23. if (patient.sex === '0') return '';
  24. try {
  25. const transform = ({ data }: any) => data;
  26. const dict = await Get('/dict/getDicts', { transform });
  27. const options = dict.find((item: any) => item.dictType === 'women_special_period').items;
  28. const { womenSpecialPeriod } = await Post('/patientInfoManage/getPatientInfoDetail', {}, { transform });
  29. if (womenSpecialPeriod) return womenSpecialPeriod.split(',').map((k: string) => {
  30. const [key, value] = k.split(':')
  31. const label = options.find((option: any) => option.dictValue === key).dictLabel;
  32. return value ?? label !== '无' ? label : ''
  33. }).filter(Boolean).join(',')
  34. } catch (error) {
  35. return ''
  36. }
  37. }
  38. export function healthReportMethod() {
  39. const transform = ({ data }: AnyObject) => {
  40. if (Array.isArray(data?.conditProgram?.types)) {
  41. data.conditProgram.types = data.conditProgram.types.map((item: AnyObject) => (item.summary = item.summary?.replace(/null/g, '') || '', item))
  42. }
  43. return data;
  44. };
  45. return Post(`/analysisManage/getLastHealRepDetail`, {}, { transform })
  46. }
  47. export function healthIndexMethod() {
  48. const transform = ({ data }: AnyObject) => {
  49. return Array.isArray(data) ? data.map(item => ({ ...item, ...item.patientQuotaRecordDTOS?.slice(-1)[0] })) : [];
  50. };
  51. return Post(`/patientQuota/getCurQuoval`, {}, { transform })
  52. }
  53. export function getSolarTerms() {
  54. return Get(`/solarTerm/getCurSolarTerm`, {
  55. transform({ data }) { return { description: data }; }
  56. });
  57. }
  58. export function getShortScienceList(page = 1, size = 3) {
  59. return Post(`/psarticle/pagePsarticle?pageNum=${page}&pageSize=${size}`, void 0, {
  60. transform({ data }: AnyObject) {
  61. return {
  62. total: data.total, page: data?.current ?? page, size: data?.size ?? size,
  63. data: data.data.map((item: AnyObject) => (item.id = item.popularScienceArticleId, item))
  64. };
  65. }
  66. })
  67. }
  68. // 跳转聊天页面
  69. export function toChats(component: 'guide' | 'questionnaire') {
  70. const navigate = wx.navigateTo({ url: `/module/chats/pages/index/index?component=${component}` })
  71. return navigate;
  72. }