export function toSchemePage(id?: string) { 
  if (!id) {
    wx.showToast({ title: '暂无调理方案', icon: 'none' });
    return
  }

  const route = 'module/health/pages/scheme/scheme';

  const pages = getCurrentPages();
  const historyIndex = pages.reverse().findIndex(page => page.route === route);
  if (historyIndex !== -1 && pages[historyIndex].options?.id === id) {
    wx.navigateBack({ delta: historyIndex });
  } else {
    wx.navigateTo({ url: `/${route}?id=${id}` });
  }
}

export function toReportPage(id?: string) {
  if (!id) {
    wx.showToast({ title: '暂无分析报告', icon: 'none' });
    return
  }

  const route = 'module/health/pages/report/report';

  const pages = getCurrentPages();
  const historyIndex = pages.reverse().findIndex(page => page.route === route);
  if (historyIndex !== -1 && pages[historyIndex].options?.id === id) {
    wx.navigateBack({ delta: historyIndex });
  } else {
    wx.navigateTo({ url: `/${route}?id=${id}` });
  }
}

export function toPatientPage() {
  return wx.navigateTo({ url: `/module/user/pages/user-record/user-record` });
}