request.ts 5.7 KB

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