import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { ArchiveTask } from './entity/archiveTask.entity'; import { Repository } from 'typeorm'; @Injectable() export class AppService { constructor( @InjectRepository(ArchiveTask) private readonly archiveTaskRepository: Repository, ) {} async createArchiveTask(payload) { const { annotatorId, study } = payload; 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({ annotatorId, PatientID, StudyInstanceUID, SeriesInstanceUID, }); } } return { success: true }; } catch (error) { return { success: false, error }; } } }