2023-08-31 17:11:14 +08:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2023-09-01 14:11:16 +08:00
|
|
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
|
|
import { ArchiveTask } from './entity/archiveTask.entity';
|
|
|
|
import { Repository } from 'typeorm';
|
2023-08-31 17:11:14 +08:00
|
|
|
|
|
|
|
@Injectable()
|
2023-09-01 14:11:16 +08:00
|
|
|
export class AppService {
|
|
|
|
constructor(
|
|
|
|
@InjectRepository(ArchiveTask)
|
|
|
|
private readonly archiveTaskRepository: Repository<ArchiveTask>,
|
|
|
|
) {}
|
|
|
|
async createArchiveTask(payload) {
|
2023-09-01 16:36:58 +08:00
|
|
|
const { username, study } = payload;
|
2023-09-01 14:11:16 +08:00
|
|
|
try {
|
|
|
|
for (let i = 0; i < study.length; i++) {
|
|
|
|
const { StudyInstanceUID, PatientID } = study[i];
|
|
|
|
for (let j = 0; j < study[i].subs.length; j++) {
|
|
|
|
const { SeriesInstanceUID } = study[i].subs[j];
|
|
|
|
await this.archiveTaskRepository.save({
|
2023-09-01 16:36:58 +08:00
|
|
|
username,
|
2023-09-01 14:11:16 +08:00
|
|
|
PatientID,
|
|
|
|
StudyInstanceUID,
|
|
|
|
SeriesInstanceUID,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return { success: true };
|
|
|
|
} catch (error) {
|
|
|
|
return { success: false, error };
|
|
|
|
}
|
|
|
|
}
|
2023-09-01 16:36:58 +08:00
|
|
|
|
|
|
|
async findArchiveTask({ username }) {
|
|
|
|
return await this.archiveTaskRepository.find({ where: { username } });
|
|
|
|
}
|
2023-09-01 14:11:16 +08:00
|
|
|
}
|