AnimalBaseInfo.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. import React, { useEffect, useState } from 'react';
  2. import { Row, Col, Input, Select, Form } from 'antd';
  3. import { RootState, useAppSelector, useAppDispatch } from '@/states/store';
  4. import { FormattedMessage } from 'react-intl';
  5. import { useDiagnosticData } from '@/hooks/useDiagnosticData';
  6. import { updateReportField } from '@/states/patient/DiagnosticReport/slice';
  7. import { PlusOutlined } from '@ant-design/icons';
  8. import { DepartmentModal } from './DepartmentModal';
  9. import { getDepartment } from '@/API/report/ReportActions';
  10. import { setDepartments } from '@/states/patient/DiagnosticReport/departmentSlice';
  11. import { getOption } from '@/API/system/options';
  12. import { setOptionSex } from '@/states/system/optionSlice';
  13. export const AnimalBaseInfo: React.FC = () => {
  14. const dispatch = useAppDispatch();
  15. const [departmentOpen, setDepartmentOpen] = useState(false);
  16. // 报告信息
  17. const [name, setName] = useDiagnosticData('headers.name');
  18. const [sex, setSex] = useDiagnosticData('headers.sex');
  19. const [age, setAge] = useDiagnosticData('headers.age');
  20. const [ownerName, setOwnerName] = useDiagnosticData('headers.owner_name');
  21. const [requestingDepartment, setRequestingDepartment] = useDiagnosticData(
  22. 'headers.requesting_department'
  23. );
  24. const [inspectionNumber, setInspectionNumber] = useDiagnosticData(
  25. 'headers.inspection_number'
  26. );
  27. const [inspectionMethod, setInspectionMethod] = useDiagnosticData(
  28. 'headers.inspection_method'
  29. );
  30. const [radiologist, setRadiologist] = useDiagnosticData('radiologist');
  31. const [reviewPhysician, setReviewPhysician] =
  32. useDiagnosticData('review_physician');
  33. const reportInfo = useAppSelector((state) => state.diagnosticReport?.report);
  34. const selectedIds = useAppSelector(
  35. (s: RootState) => s.workSelection.selectedIds
  36. );
  37. const productName = useAppSelector((s: RootState) => s.product.productName);
  38. const departments = useAppSelector(
  39. (state: RootState) => state.department.departments
  40. );
  41. const optionSex = useAppSelector((state: RootState) => state.options.sex);
  42. console.log(`【诊断报告】:选中的study id :${selectedIds[0]}`);
  43. const getDepartmentData = async () => {
  44. const res = await getDepartment({});
  45. if (res.code === '0x000000') {
  46. dispatch(setDepartments(res?.data?.departments || []));
  47. }
  48. };
  49. const getSexOption = async () => {
  50. const res = await getOption({ group: 'patient', flag: 'sex' });
  51. if (res.code === '0x000000') {
  52. dispatch(setOptionSex(res?.data?.option || []));
  53. }
  54. };
  55. useEffect(() => {
  56. getDepartmentData();
  57. getSexOption();
  58. }, []);
  59. return (
  60. <>
  61. <Form layout="vertical">
  62. <Row gutter={12}>
  63. <Col span={6}>
  64. <Form.Item
  65. label={
  66. <FormattedMessage
  67. id={'animal.register.patientType'}
  68. defaultMessage={'animal.register.patientType'}
  69. />
  70. }
  71. >
  72. <Input
  73. disabled
  74. value={reportInfo?.headers?.patient_type}
  75. onChange={(e) =>
  76. dispatch(
  77. updateReportField({
  78. path: 'report.headers.patient_type',
  79. value: e.target.value,
  80. })
  81. )
  82. }
  83. />
  84. </Form.Item>
  85. </Col>
  86. <Col span={6}>
  87. <Form.Item
  88. label={
  89. <FormattedMessage
  90. id={
  91. productName === 'VETDROS'
  92. ? 'animal.register.patientName'
  93. : 'register.patientName'
  94. }
  95. defaultMessage={
  96. productName === 'VETDROS'
  97. ? 'animal.register.patientName'
  98. : 'register.patientName'
  99. }
  100. />
  101. }
  102. >
  103. <Input
  104. disabled
  105. value={name}
  106. onChange={(e) => setName(e.target.value)}
  107. />
  108. </Form.Item>
  109. </Col>
  110. <Col span={6}>
  111. <Form.Item
  112. label={
  113. <FormattedMessage
  114. id="register.gender"
  115. defaultMessage="register.gender"
  116. />
  117. }
  118. >
  119. <Select
  120. disabled
  121. value={sex}
  122. onChange={(v) => setSex(v)}
  123. fieldNames={{ label: 'text' }}
  124. options={optionSex}
  125. ></Select>
  126. </Form.Item>
  127. </Col>
  128. <Col span={6}>
  129. <Form.Item
  130. label={
  131. <FormattedMessage
  132. id="register.age"
  133. defaultMessage="register.age"
  134. />
  135. }
  136. >
  137. <Input
  138. disabled
  139. value={age}
  140. onChange={(e) => setAge(e.target.value)}
  141. />
  142. </Form.Item>
  143. </Col>
  144. <Col span={6}>
  145. <Form.Item
  146. label={
  147. <FormattedMessage
  148. id="register.owner_name"
  149. defaultMessage="register.owner_name"
  150. />
  151. }
  152. >
  153. <Input
  154. value={ownerName as string}
  155. onChange={(e) => setOwnerName(e.target.value)}
  156. />
  157. </Form.Item>
  158. </Col>
  159. <Col span={6}>
  160. <Form.Item
  161. label={
  162. <FormattedMessage
  163. id="report.requestingDepartment"
  164. defaultMessage="report.requestingDepartment"
  165. />
  166. }
  167. >
  168. <Select
  169. style={{ width: '90%' }}
  170. value={requestingDepartment}
  171. fieldNames={{ label: 'department', value: 'department' }}
  172. onChange={(v) => setRequestingDepartment(v)}
  173. options={departments}
  174. />
  175. </Form.Item>
  176. <PlusOutlined
  177. style={{
  178. position: 'absolute',
  179. top: '40px',
  180. right: '10px',
  181. cursor: 'pointer',
  182. transition: 'all 0.3s',
  183. }}
  184. onClick={() => setDepartmentOpen(true)}
  185. />
  186. </Col>
  187. <Col span={6}>
  188. <Form.Item
  189. label={
  190. <FormattedMessage
  191. id="report.inspectionNumber"
  192. defaultMessage="report.inspectionNumber"
  193. />
  194. }
  195. >
  196. <Input
  197. value={inspectionNumber}
  198. onChange={(e) => setInspectionNumber(e.target.value)}
  199. />
  200. </Form.Item>
  201. </Col>
  202. <Col span={6}>
  203. <Form.Item
  204. label={
  205. <FormattedMessage
  206. id="report.inspectionMethod"
  207. defaultMessage="report.inspectionMethod"
  208. />
  209. }
  210. >
  211. <Input
  212. value={inspectionMethod}
  213. onChange={(e) => setInspectionMethod(e.target.value)}
  214. />
  215. </Form.Item>
  216. </Col>
  217. <Col span={6}>
  218. <Form.Item
  219. label={
  220. <FormattedMessage
  221. id="report.radiologist"
  222. defaultMessage="report.radiologist"
  223. />
  224. }
  225. >
  226. <Input
  227. value={radiologist}
  228. onChange={(e) => setRadiologist(e.target.value)}
  229. />
  230. </Form.Item>
  231. </Col>
  232. <Col span={6}>
  233. <Form.Item
  234. label={
  235. <FormattedMessage
  236. id="report.reviewPhysician"
  237. defaultMessage="report.reviewPhysician"
  238. />
  239. }
  240. >
  241. <Input
  242. value={reviewPhysician}
  243. onChange={(e) => setReviewPhysician(e.target.value)}
  244. />
  245. </Form.Item>
  246. </Col>
  247. </Row>
  248. </Form>
  249. <DepartmentModal
  250. visible={departmentOpen}
  251. onClose={() => setDepartmentOpen(false)}
  252. />
  253. </>
  254. );
  255. };