123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- import { Series } from '@/domain/series';
- import axiosInstance from '../interceptor';
- import { Task } from '@/domain/work';
- import { dview } from '@/domain/dview';
- import { XImage } from '@/domain/xImage';
- interface View {
- view_id: string;
- procedure_id: string;
- }
- export interface RegisterInfo {
- accession_number: string;
- patient_id: string;
- patient_name: string;
- patient_size: string;
- patient_age: string;
- patient_dob: string;
- patient_sex: string;
- sex_neutered: string;
- pregnancy_status: string;
- chip_number: string;
- variety: string;
- patient_type: string;
- ref_physician: string;
- operator_id: string;
- modality: string;
- weight: number;
- thickness: number;
- length: number;
- study_type: 'Normal' | 'Emergency';
- comment: string;
- views: View[];
- }
- export interface RegisterWorkResponseData {
- study_instance_uid: string;
- study_id: string;
- public_study_id: string;
- specific_character_set: string;
- accession_number: string;
- ref_physician: string;
- patient_id: string;
- patient_name: string;
- patient_size: string;
- other_patient_ids: string;
- other_patient_names: string;
- owner_name: string;
- patient_age: string;
- patient_dob: string;
- patient_sex: string;
- patient_state: string;
- admitting_time: string | null;
- priority: string;
- reg_source: string;
- study_status: string;
- study_description: string;
- study_start_datetime: string | null;
- study_end_datetime: string | null;
- scheduled_procedure_step_start_date: string | null;
- performed_physician: string;
- study_lock: string;
- folder_path: string;
- operator_name: string;
- modality: string;
- weight: number;
- thickness: number;
- length: number;
- patient_type: string;
- study_type: string;
- mwl: string;
- is_exported: boolean;
- is_edited: boolean;
- is_appended: boolean;
- department: string;
- mapped_status: boolean;
- qc_result: boolean;
- comment: string;
- sort: number;
- product: string;
- series: Series[];
- }
- export interface RegisterWorkResponse {
- code: string;
- description: string;
- solution: string;
- data: RegisterWorkResponseData;
- }
- export interface AcquisitionContext {
- WorkStationID: number;
- PatientSize: string;
- KVP: number;
- MA: number;
- MAS: number;
- MS: number;
- TechMode: number;
- AECDensity: number;
- AECField: number;
- AECFilm: number;
- DAP: number;
- DOSE: number;
- FocalSpot: string;
- SID: number;
- TOD: number;
- TubeLoad: string;
- GridType: string;
- FilterType: string;
- EXI: number;
- DI: number;
- PositionNumber: string;
- CollimatorFilter: string;
- CollimatorLength: string;
- CollimatorWidth: string;
- CollimatorCenter: string;
- FpdAcquisitionMode: string;
- FrameRate: number;
- EntranceDoseInmGy: number;
- }
- export interface ImageFunctionParameter {
- Name: string;
- Min: number;
- Max: number;
- Step: number;
- Value: number;
- ValueType: string;
- IsEnabled: boolean;
- }
- export interface ImageFunction {
- FunctionName: string;
- ImageStyle: string;
- Parameters: ImageFunctionParameter[];
- CurveType: ImageFunctionParameter;
- WindowLevelGradeParameters: ImageFunctionParameter[];
- }
- export interface ImageProcessingContext {
- ImageFunction: ImageFunction;
- }
- export interface CopyPositionResponseData {
- series_instance_uid: string;
- study_instance_uid: string;
- study_id: string;
- procedure_id: string;
- body_part: string;
- performed_datetime: string | null;
- performed_protocol_code_meaning: string;
- performed_protocol_code_value: string;
- sort: number;
- product: string;
- is_pre_install: boolean;
- images: {
- sop_instance_id: string;
- series_instance_uid: string;
- study_instance_uid: string;
- secondary_sop_uid: string;
- study_id: string;
- view_id: string;
- view_description: string;
- image_status: string;
- image_file_path: string;
- acquisition_mode: string;
- acquisition_context: AcquisitionContext | null;
- img_proc_context: ImageProcessingContext | null;
- sort: number;
- product: string;
- is_pre_install: boolean;
- }[];
- }
- export interface CopyPositionResponse {
- code: string;
- description: string;
- solution: string;
- data: CopyPositionResponseData;
- }
- // 充当列表框架的filter
- export interface TaskListQuery {
- patient_id?: string;
- patient_name?: string;
- start_time?: string;
- end_time?: string;
- access_number?: string;
- status?: string;
- page?: number;
- page_size?: number;
- }
- const registerWork = async (
- work: RegisterInfo
- ): Promise<RegisterWorkResponse> => {
- console.log('Work object:', JSON.stringify(work, null, 2));
- try {
- const response = await axiosInstance.post('/auth/study', work);
- // response.data.code
- console.log(`0000${JSON.stringify(response)}`);
- return response.data;
- } catch (error) {
- console.warn(`注册出错:${error}`);
- throw error;
- }
- };
- const mapToTask = (study: RegisterWorkResponseData): Task => ({
- StudyInstanceUID: study.study_instance_uid,
- StudyID: study.study_id,
- SpecificCharacterSet: study.specific_character_set,
- AccessionNumber: study.accession_number,
- PatientID: study.patient_id,
- PatientName: study.patient_name,
- DisplayPatientName: study.patient_name,
- PatientSize: study.patient_size,
- PatientAge: study.patient_age,
- PatientSex: study.patient_sex,
- AdmittingTime: study.admitting_time ?? '',
- RegSource: study.reg_source,
- StudyStatus: study.study_status,
- RequestedProcedureID: '',
- PerformedProtocolCodeValue: '',
- PerformedProtocolCodeMeaning: '',
- PerformedProcedureStepID: '',
- StudyDescription: study.study_description,
- StudyStartDatetime: study.study_start_datetime ?? '',
- ScheduledProcedureStepStartDate:
- study.scheduled_procedure_step_start_date ?? '',
- StudyLock: study.study_lock,
- OperatorID: study.operator_name,
- Modality: study.modality,
- Views: [],
- Thickness: study.thickness,
- PatientType: study.patient_type,
- StudyType: study.study_type,
- QRCode: '',
- IsExported: study.is_exported,
- IsEdited: study.is_edited,
- WorkRef: '',
- IsAppended: study.is_appended,
- CreationTime: '',
- MappedStatus: study.mapped_status,
- IsDelete: false,
- });
- const fetchTaskList = async (
- page,
- pageSize,
- filter: TaskListQuery
- ): Promise<{ items: Task[]; total: number }> => {
- console.log(
- `Fetching task list with page: ${page}, pageSize: ${pageSize}, filter: ${JSON.stringify(filter)}`
- );
- const response = await axiosInstance.get('/auth/study', {
- params: {
- page: page,
- page_size: pageSize,
- id: filter.patient_id ?? '',
- name: filter.patient_name ?? '',
- start_time: filter.start_time,
- end_time: filter.end_time,
- acc_no: filter.access_number,
- status: filter.status,
- },
- });
- const { studies } = response.data.data;
- const tasks = studies.map(mapToTask);
- return { items: tasks, total: tasks.length };
- };
- export { registerWork, fetchTaskList };
- const fetchTaskDetails = async (
- studyId: string
- ): Promise<RegisterWorkResponseData> => {
- try {
- const response = await axiosInstance.get(`/auth/study/${studyId}`);
- return response.data.data;
- } catch (error) {
- console.error('Error fetching task details:', error);
- throw error;
- }
- };
- const copyImage = async (instanceUid: string): Promise<dview[]> => {
- try {
- const response = await axiosInstance.post('/auth/image/copy', {
- instance_uid: instanceUid,
- });
- const dviews: dview[] = response.data.series.flatMap((series: Series) =>
- series.images.map((image: XImage) => ({
- view_id: image.view_id,
- series_instance_uid: image.series_instance_uid,
- study_instance_uid: image.study_instance_uid,
- study_id: image.study_id,
- procedure_id: series.procedure_id,
- view_description: image.view_description,
- view_type: image.view_id, // Assuming view_type is the same as view_id
- }))
- );
- return dviews;
- } catch (error) {
- console.error('Error copying image:', error);
- throw error;
- }
- };
- export { copyImage, fetchTaskDetails };
- export interface DeleteStudiesResponse {
- code: string;
- description: string;
- solution: string;
- data: {
- total: number;
- exposed: number;
- };
- }
- const deleteStudies = async (
- studyIds: string[]
- ): Promise<DeleteStudiesResponse> => {
- try {
- const response = await axiosInstance.delete('/auth/study', {
- data: studyIds,
- });
- return response.data;
- } catch (error) {
- console.error('Error deleting studies:', error);
- throw error;
- }
- };
- export { deleteStudies };
- // eslint-disable-next-line
- const suspendOrCompleteStudy = async (studyId: string, studyStatus: 'InProgress' | 'Completed'): Promise<{ code: string; description: string; solution: string; data: {} }> => {
- try {
- const response = await axiosInstance.post('/auth/task/inspection/leave', {
- study_id: studyId,
- study_status: studyStatus,
- });
- return response.data;
- } catch (error) {
- console.error('Error suspending or completing study:', error);
- throw error;
- }
- };
- export { suspendOrCompleteStudy };
|