patient.api.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. return request.Get<PatientModel, any>(`/fdhb-pc/patientInfoManage/getPatientInfoDetailById`, {
  48. name: 'patient-report',
  49. params: { patientId: id },
  50. transform(data, headers) {
  51. data.patientId ??= id;
  52. return transformPatient(data);
  53. },
  54. });
  55. }
  56. /**
  57. * @deprecated
  58. * @param id
  59. */
  60. export function patientTags(id: string) {
  61. return request.Get<PatientTagModel, any[]>(`/fdhb-pc/patientInfoManage/getPatientTag`, {
  62. hitSource: 'update-tags',
  63. params: { patientId: id },
  64. transform(data, headers) {
  65. return {
  66. id,
  67. tags: data.map(({ id, name }) => ({ id, name })),
  68. };
  69. },
  70. });
  71. }
  72. /**
  73. * @deprecated
  74. * @param id
  75. */
  76. export function patientTagsMethod(id: string) {
  77. return request.Get<PatientTagModel['tags'], any[]>(`/fdhb-pc/patientInfoManage/getPatientTag`, {
  78. hitSource: 'update-tags',
  79. params: { patientId: id },
  80. });
  81. }
  82. /**
  83. * @deprecated
  84. * @param id
  85. * @param data
  86. */
  87. export function updatePatientTagsMethod(id: string, data: string[]) {
  88. return request.Post(`/fdhb-pc/patientInfoManage/updatePatientTag`, { patientId: id, tagIds: data }, { name: 'update-tags' });
  89. }
  90. export function getPatientTagsMethod(id: string) {
  91. return request.Get<PatientTagVO[], PatientTagDTO[]>(`/fdhb-pc/patientInfoManage/getPatientTag`, {
  92. hitSource: 'update-tags',
  93. params: { patientId: id },
  94. transform(data) {
  95. return data.map(fromPatientTag);
  96. },
  97. });
  98. }
  99. export function updatePatientTagMethod(id: string, tags: PatientTagVO[]) {
  100. const tagIds = tags.map(({ id }) => id);
  101. return request.Post(
  102. `/fdhb-pc/patientInfoManage/updatePatientTag`,
  103. { patientId: id, tagIds },
  104. {
  105. name: 'update-tags',
  106. transform() {
  107. return tags;
  108. },
  109. }
  110. );
  111. }
  112. export function searchTagsFromSelectableMethod() {
  113. return request.Post<PatientTagVO[], PatientTagDTO[]>(
  114. `/fdhb-pc/tagManage/selectTag`,
  115. {},
  116. {
  117. hitSource: /tag$/,
  118. transform(data) {
  119. return data.map(fromPatientTag);
  120. },
  121. }
  122. );
  123. }
  124. export function patientAnalysisCountMethod(id: string) {
  125. return request.Get(`/fdhb-pc/patientInfoManage/rechargeUseDetail`, {
  126. hitSource: 'update-analysis-count',
  127. params: { patientId: id },
  128. transform(data: any) {
  129. return {
  130. total: Math.max(0, data.usedCou),
  131. count: Math.max(0, data.residuedCou),
  132. };
  133. },
  134. });
  135. }
  136. export function updatePatientAnalysisCountMethod(id: string, count: number) {
  137. return request.Get(`/fdhb-pc/patientInfoManage/rechargeUpdate`, {
  138. name: 'update-analysis-count',
  139. params: { patientId: id, residuedCou: count },
  140. cacheFor: null,
  141. });
  142. }
  143. // 调养
  144. export function carePatientMethod(id: string) {
  145. console.log(id, 'carePatientMethod-id');
  146. return request.Post(`/fdhb-pc/patientInfoManage/conditioning/${id}`, { patientId: id }, {
  147. transform(data) {
  148. return data;
  149. },
  150. });
  151. }