request.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import { Get, Post } from "../../lib/request/method";
  2. export function getNotDealLists() {
  3. return Post(
  4. "/surplus/getPatientPendingWorks",
  5. {},
  6. {
  7. transform({ data }: AnyObject) {
  8. return Array.isArray(data)
  9. ? data.map((item) => ({
  10. ...item,
  11. }))
  12. : [];
  13. },
  14. }
  15. );
  16. }
  17. // 获取调养计划
  18. export function getCareList() {
  19. return Post(
  20. "/patientCrManage/getCurrentPcrs",
  21. {},
  22. {
  23. transform({ data }: AnyObject) {
  24. return data;
  25. },
  26. }
  27. );
  28. }
  29. export function getPatients(id?: string) {
  30. id ??= wx.getStorageSync("patientId");
  31. const transform = ({ data }: AnyObject) => {
  32. const patient =
  33. void 0 ??
  34. data.find((item: AnyObject) => item.patientId == id) ??
  35. data.find((item: AnyObject) => item.isDefault?.toUpperCase() === "Y") ??
  36. data[0];
  37. return { patient, patients: data };
  38. };
  39. return Post("/mobileAccountManage/getPatsByAid", {}, { transform }).then(res => {
  40. const patientId = res.patient?.patientId;
  41. if (patientId) wx.setStorageSync("patientId", patientId);
  42. else wx.removeStorageSync("patientId");
  43. return res;
  44. });
  45. }
  46. export async function getPatientDescription(patient: {
  47. sex: "0" | "1";
  48. patientId: string;
  49. }) {
  50. if (patient.sex === "0") return "";
  51. try {
  52. const transform = ({ data }: any) => data;
  53. const dict = await Get("/dict/getDicts", { transform });
  54. const options = dict.find(
  55. (item: any) => item.dictType === "women_special_period"
  56. ).items;
  57. const { womenSpecialPeriod } = await Post(
  58. "/patientInfoManage/getPatientInfoDetail",
  59. {},
  60. { transform }
  61. );
  62. if (womenSpecialPeriod)
  63. return womenSpecialPeriod
  64. .split(",")
  65. .map((k: string) => {
  66. const [key, value] = k.split(":");
  67. const label = options.find(
  68. (option: any) => option.dictValue === key
  69. ).dictLabel;
  70. return value ?? label !== "无" ? label : "";
  71. })
  72. .filter(Boolean)
  73. .join(",");
  74. } catch (error) {
  75. return "";
  76. }
  77. }
  78. export function healthReportMethod() {
  79. const transform = ({ data }: AnyObject) => {
  80. if (Array.isArray(data?.conditProgram?.types)) {
  81. data.conditProgram.types = data.conditProgram.types.map(
  82. (item: AnyObject) => (
  83. (item.summary = item.summary?.replace(/null/g, "") || ""), item
  84. )
  85. );
  86. }
  87. return data;
  88. };
  89. return Post(`/analysisManage/getLastHealRepDetail`, {}, { transform });
  90. }
  91. export function healthIndexMethod() {
  92. const transform = ({ data }: AnyObject) => {
  93. // console.log(data, "healthIndexMethod",Array.isArray(data), data.map((item: any) => ({
  94. // ...item,
  95. // ...item.patientQuotaRecordDTOS?.slice(-1)[0],
  96. // })));
  97. return Array.isArray(data)
  98. ? data.map((item) => ({
  99. ...item,
  100. ...item.patientQuotaRecordDTOS?.slice(-1)[0],
  101. }))
  102. : [];
  103. };
  104. return Post(`/patientQuota/getCurQuoval`, {}, { transform });
  105. }
  106. export function getSolarTerms() {
  107. return Get(`/solarTerm/getCurSolarTerm`, {
  108. transform({ data }) {
  109. return { description: data };
  110. },
  111. });
  112. }
  113. export function getShortScienceList(page = 1, size = 3) {
  114. return Post(
  115. `/psarticle/pagePsarticle?pageNum=${page}&pageSize=${size}`,
  116. void 0,
  117. {
  118. transform({ data }: AnyObject) {
  119. return {
  120. total: data.total,
  121. page: data?.current ?? page,
  122. size: data?.size ?? size,
  123. data: data.data.map(
  124. (item: AnyObject) => (
  125. (item.id = item.popularScienceArticleId), item
  126. )
  127. ),
  128. };
  129. },
  130. }
  131. );
  132. }
  133. // 跳转聊天页面
  134. export function toChats(component: "guide" | "questionnaire") {
  135. const navigate = wx.navigateTo({
  136. url: `/module/chats/pages/index/index?component=${component}`,
  137. });
  138. return navigate;
  139. }
  140. export function getPatientPhone() {
  141. return Post(
  142. `/patientInfoManage/getPatientInfoDetail`,
  143. {},
  144. {
  145. transform({ data }: AnyObject) {
  146. return data;
  147. },
  148. }
  149. );
  150. }
  151. // 获取订单列表
  152. export function getOrderList(patientId: string | number, progress: string | number) {
  153. return Post(
  154. `/patientCrManage/pagePcrOrders`,
  155. { patientId, status: 0, progress },
  156. {
  157. transform({ data }: AnyObject) {
  158. return data;
  159. },
  160. }
  161. );
  162. }
  163. // 获取各状态调理记录数量
  164. export function getRecordCountMethod() {
  165. return Post(`/patientCrManage/getDiffProgressPcrCount`, {
  166. transform({ data }: AnyObject) {
  167. return data;
  168. },
  169. });
  170. }
  171. // 获取患者线上调理方案打卡记录
  172. export function getPatientOnlineRecord(id: string | number, startDate: string, endDate: string) {
  173. return Get(`/patientCrManage/ponlineCp/${id}`, {
  174. params: { startDate, endDate },
  175. transform({ data }: AnyObject) {
  176. return data;
  177. },
  178. });
  179. }
  180. // 线上调理方案补卡
  181. export function addPatientOnlineRecord(id: string | number) {
  182. return Post(`/patientCrManage/clockIn/repair/${id}`, {}, {
  183. transform({ data }: AnyObject) {
  184. return data;
  185. },
  186. });
  187. }
  188. // 线上调理方案打卡
  189. export function addPatientOnlineRecordClockIn(id: string | number) {
  190. return Post(`/patientCrManage/clockIn/${id}`, {}, {
  191. transform({ data }: AnyObject) {
  192. return data;
  193. },
  194. });
  195. }