import { Injectable } from '@nestjs/common' import { HttpService } from '../http' export type FoodPlanAIResult = { food_plan_id: string meal_time_adjusted: { Almoço: string 'Café da manhã': string Ceia: string Jantar: string 'Lanche da manhã': string 'Lanche da tarde': string } } export const STAG_MOCK_RESPONSE: FoodPlanAIResult = { food_plan_id: '3f05e7df-f425-4bcf-8df6-853a56844c61', meal_time_adjusted: { Almoço: '11:30', 'Café da manhã': '07:30', Ceia: '22:30', Jantar: '18:00', 'Lanche da manhã': '10:00', 'Lanche da tarde': '15:15', }, } @Injectable() export class FoodPlanAIService { constructor(private readonly httpService: HttpService) {} protected get endpoint(): string { return globalThis.secret.foodplan_ai.url } async getFromPatientId(patientId: string): Promise { if (process.env.STAGE !== 'prod' && !process.env.IS_TEST) return STAG_MOCK_RESPONSE try { return await this.httpService.post( this.endpoint, { patient_id: patientId, }, { name: this.constructor.name, headers: { 'Content-Type': 'application/json' }, }, ) } catch (error) { return null } } }