request.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. // console.log(data, "healthIndexMethod",Array.isArray(data), data.map((item: any) => ({
  96. // ...item,
  97. // ...item.patientQuotaRecordDTOS?.slice(-1)[0],
  98. // })));
  99. return Array.isArray(data)
  100. ? data.map((item) => ({
  101. ...item,
  102. ...item.patientQuotaRecordDTOS?.slice(-1)[0],
  103. }))
  104. : [];
  105. };
  106. return Post(`/patientQuota/getCurQuoval`, {}, { transform });
  107. }
  108. export function getSolarTerms() {
  109. return Get(`/solarTerm/getCurSolarTerm`, {
  110. transform({ data }) {
  111. return { description: data };
  112. },
  113. });
  114. }
  115. export function getShortScienceList(page = 1, size = 3) {
  116. return Post(
  117. `/psarticle/pagePsarticle?pageNum=${page}&pageSize=${size}`,
  118. void 0,
  119. {
  120. transform({ data }: AnyObject) {
  121. return {
  122. total: data.total,
  123. page: data?.current ?? page,
  124. size: data?.size ?? size,
  125. data: data.data.map(
  126. (item: AnyObject) => (
  127. (item.id = item.popularScienceArticleId), item
  128. )
  129. ),
  130. };
  131. },
  132. }
  133. );
  134. }
  135. // 跳转聊天页面
  136. export function toChats(component: "guide" | "questionnaire") {
  137. const navigate = wx.navigateTo({
  138. url: `/module/chats/pages/index/index?component=${component}`,
  139. });
  140. return navigate;
  141. }
  142. export function getPatientPhone() {
  143. return Post(
  144. `/patientInfoManage/getPatientInfoDetail`,
  145. {},
  146. {
  147. transform({ data }: AnyObject) {
  148. return data;
  149. },
  150. }
  151. );
  152. }
  153. // 获取订单列表
  154. export function getOrderList(
  155. patientId: string | number,
  156. progress: string | number
  157. ) {
  158. return Post(
  159. `/patientCrManage/pagePcrOrders`,
  160. { patientId, status: 0, progress },
  161. {
  162. transform({ data }: AnyObject) {
  163. return data;
  164. },
  165. }
  166. );
  167. }
  168. // 获取各状态调理记录数量
  169. export function getRecordCountMethod() {
  170. return Post(`/patientCrManage/getDiffProgressPcrCount`, {
  171. transform({ data }: AnyObject) {
  172. return data;
  173. },
  174. });
  175. }
  176. // 获取患者线上调理方案打卡记录
  177. export function getPatientOnlineRecord(
  178. id: string | number,
  179. startDate: string,
  180. endDate: string
  181. ) {
  182. return Get(`/patientCrManage/ponlineCp/${id}`, {
  183. params: { startDate, endDate },
  184. transform({ data }: AnyObject) {
  185. return data;
  186. },
  187. });
  188. }
  189. // 线上调理方案补卡
  190. export function addPatientOnlineRecord(id: string | number) {
  191. return Post(
  192. `/patientCrManage/clockIn/repair/${id}`,
  193. {},
  194. {
  195. transform({ data }: AnyObject) {
  196. return data;
  197. },
  198. }
  199. );
  200. }
  201. // 线上调理方案打卡
  202. export function addPatientOnlineRecordClockIn(id: string | number) {
  203. return Post(
  204. `/patientCrManage/clockIn/${id}`,
  205. {},
  206. {
  207. transform({ data }: AnyObject) {
  208. return data;
  209. },
  210. }
  211. );
  212. }