request.ts 5.1 KB

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