import { Injectable } from '@nestjs/common' import { isEmpty, isNil } from 'lodash' import { BioimpedanceNotificationService } from '../../../services' import { Patient } from '../../../models/patient.model' import { PatientRepository } from '../../../repositories' export const NOTIFICATION_TYPE_SMS = 'bio_importation_sms' @Injectable() export class Notification { constructor( private readonly patientRepository: PatientRepository, private readonly bioimpedanceNotificationService: BioimpedanceNotificationService, ) {} async checkPushConversion(patientIds: Array): Promise { if (isNil(patientIds) || isEmpty(patientIds)) return const patients = await this.patientRepository.getMany(patientIds) await Promise.all( patients.map( async (patient: Patient): Promise => this.bioimpedanceNotificationService.send(patient, null, NOTIFICATION_TYPE_SMS), ), ) } }