request.ts 2.4 KB

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