patient.api.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import { type List, type PatientModel, type PatientQuery, type PatientReportModel, type PatientTagModel, transformPatient } from '@/model';
  2. import request from '@/request/alova';
  3. import type { PatientTagVO, PatientTagDTO } from '@/model/patient.model';
  4. import { fromPatientTag } from '@/model/patient.model';
  5. export function patientsHistoryMethod(page: number, size: number, query?: PatientQuery) {
  6. return request.Post<List<PatientReportModel>, List<any>>(`/fdhb-pc/patientInfoManage/pageMyPatient`, query ?? {}, {
  7. params: { pageNum: page, pageSize: size },
  8. transform(data, headers) {
  9. return {
  10. total: data.total,
  11. data: data.data.map((item: any) =>
  12. Object.assign(transformPatient(item), {
  13. report: {
  14. id: item.healthAnalysisReportId,
  15. time: item.reportTime,
  16. },
  17. createTime: item.createTime,
  18. })
  19. ),
  20. };
  21. },
  22. });
  23. }
  24. export function appendPatientMethod(data: Record<string, any>) {
  25. const { disease: diagnosis, date: medicalTime, department: medicalDepartment, doctor: medicalDoctor, tags, ...patient } = data;
  26. return request.Post(`/fdhb-pc/patientMedicalManage/addPatientMedical`, { ...patient, diagnosis, medicalTime, medicalDepartment, medicalDoctor }, {});
  27. }
  28. export function patientsRoomMethod(query?: PatientQuery) {
  29. return request.Post<PatientReportModel[], any[]>(`/fdhb-pc/patientInfoManage/pendPatient`, query ?? {}, {
  30. params: {},
  31. transform(data, headers) {
  32. return data.map((item: any) =>
  33. Object.assign(transformPatient(item), {
  34. uid: item.healthAnalysisReportId,
  35. report: {
  36. id: item.healthAnalysisReportId,
  37. time: item.reportTime,
  38. },
  39. createTime: item.createTime,
  40. })
  41. );
  42. },
  43. cacheFor: 1000,
  44. });
  45. }
  46. export function patientMethod(id: string) {
  47. console.log(id, 'patientMethod-id');
  48. return request.Get<PatientModel, any>(`/fdhb-pc/patientInfoManage/getPatientInfoDetailById`, {
  49. name: 'patient-report',
  50. cacheFor: null,
  51. params: { patientId: id },
  52. transform(data, headers) {
  53. data.patientId ??= id;
  54. return transformPatient(data);
  55. },
  56. });
  57. }
  58. // 患者基本信息修改
  59. export function patientBasicInfoMethod(data: Record<string, any>) {
  60. return request.Post(`/fdhb-pc/patientInfoManage/updatePatientInfo`, data);
  61. }
  62. /**
  63. * @deprecated
  64. * @param id
  65. */
  66. export function patientTags(id: string) {
  67. return request.Get<PatientTagModel, any[]>(`/fdhb-pc/patientInfoManage/getPatientTag?old`, {
  68. hitSource: 'update-tags',
  69. params: { patientId: id },
  70. transform(data, headers) {
  71. return {
  72. id,
  73. tags: data.map(({ id, name }) => ({ id, name })),
  74. };
  75. },
  76. });
  77. }
  78. /**
  79. * @deprecated
  80. * @param id
  81. */
  82. export function patientTagsMethod(id: string) {
  83. return request.Get<PatientTagModel['tags'], any[]>(`/fdhb-pc/patientInfoManage/getPatientTag`, {
  84. hitSource: 'update-tags',
  85. params: { patientId: id },
  86. });
  87. }
  88. /**
  89. * @deprecated
  90. * @param id
  91. * @param data
  92. */
  93. export function updatePatientTagsMethod(id: string, data: string[]) {
  94. return request.Post(`/fdhb-pc/patientInfoManage/updatePatientTag`, { patientId: id, tagIds: data }, { name: 'update-tags' });
  95. }
  96. export function getPatientTagsMethod(id: string) {
  97. return request.Get<PatientTagVO[], PatientTagDTO[]>(`/fdhb-pc/patientInfoManage/getPatientTag`, {
  98. hitSource: 'update-tags',
  99. params: { patientId: id },
  100. transform(data) {
  101. return data.map(fromPatientTag);
  102. },
  103. });
  104. }
  105. export function updatePatientTagMethod(id: string, tags: PatientTagVO[]) {
  106. const tagIds = tags.map(({ id }) => id);
  107. return request.Post(
  108. `/fdhb-pc/patientInfoManage/updatePatientTag`,
  109. { patientId: id, tagIds },
  110. {
  111. name: 'update-tags',
  112. transform() {
  113. return tags;
  114. },
  115. }
  116. );
  117. }
  118. export function searchTagsFromSelectableMethod() {
  119. return request.Post<PatientTagVO[], PatientTagDTO[]>(
  120. `/fdhb-pc/tagManage/selectTag`,
  121. {},
  122. {
  123. hitSource: /tag$/,
  124. transform(data) {
  125. return data.map(fromPatientTag);
  126. },
  127. }
  128. );
  129. }
  130. export function patientAnalysisCountMethod(id: string) {
  131. return request.Get(`/fdhb-pc/patientInfoManage/rechargeUseDetail`, {
  132. hitSource: 'update-analysis-count',
  133. params: { patientId: id },
  134. transform(data: any) {
  135. return {
  136. total: Math.max(0, data.usedCou),
  137. count: Math.max(0, data.residuedCou),
  138. };
  139. },
  140. });
  141. }
  142. export function updatePatientAnalysisCountMethod(id: string, count: number) {
  143. return request.Get(`/fdhb-pc/patientInfoManage/rechargeUpdate`, {
  144. name: 'update-analysis-count',
  145. params: { patientId: id, residuedCou: count },
  146. cacheFor: null,
  147. });
  148. }
  149. // 调养
  150. export function carePatientMethod(id: string) {
  151. console.log(id, 'carePatientMethod-id');
  152. return request.Post(
  153. `/fdhb-pc/patientInfoManage/conditioning/${id}`,
  154. { patientId: id },
  155. {
  156. transform(data) {
  157. return data;
  158. },
  159. }
  160. );
  161. }