예제 #1
0
        public async Task SendPatientRegister(NewPatientReq req, MemoryStream positions)
        {
            var email = new EmailTemplate
            {
                To              = To,
                Bcc             = Bcc,
                Subject         = "EMECI - Registro de paciente",
                Title           = "Registro de paciente",
                TypeEmailToSend = EmailTemplate.TypeEmail.patientRegister,
                PatientReq      = req
            };

            email.Attach(new Attachment(positions, "PosicionesDeAcceso.pdf"));

            try
            {
                await email.SendAsync();
            }
            catch (Exception ex)
            {
                Log.Write($"EmailService, SendPatientRegister=> {ex.Message}");
            }
        }
예제 #2
0
 //POST /api/patient/1400
 public NewPatientRes Post(int doctorId, [FromBody] NewPatientReq req)
 {
     return(service.AddNewPatient(doctorId, req));
 }
예제 #3
0
        public NewPatientRes AddNewPatient(int doctorId, NewPatientReq req)
        {
            var          result = new NewPatientRes();
            string       emeci  = GetLastEmeci(doctorId);
            MemoryStream draw   = null;

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    var r = new Registro
                    {
                        Nombre          = req.Name,
                        Apellido        = req.LastName,
                        Telefono        = req.Phone,
                        Tipo            = "P",
                        Status          = "V",
                        FechaRegistro   = DateTime.Now.Date,
                        FechaExpiracion = DateTime.Now.AddMonths(1).Date,
                        Emails          = req.Emails,
                        clave           = req.Password,
                        Emeci           = emeci
                    };

                    Context.Registro.Add(r);
                    Context.SaveChanges();

                    var p = new Paciente
                    {
                        IdRegistro      = r.idRegistro,
                        Sexo            = req.Sex,
                        FechaNacimiento = DateTime.Parse(req.BirthDate),
                        NombreMadre     = req.MothersName,
                        NombrePadre     = req.FathersName,
                        AlergiaMedicina = req.Allergy
                    };

                    Context.Paciente.Add(p);
                    Context.SaveChanges();

                    draw = DrawDataInCard(emeci);

                    scope.Complete();
                    result.PatientId = p.idPaciente;
                }
            }
            catch (Exception ex)
            {
                Log.Write($"WebAPI.Services._Patient - AddNewPatient => ${ex.Message}");
            }

            if (result.PatientId.HasValue && draw != null)
            {
                var emailService = new EmailService(req.Emails);
                Task.Run(async() =>
                {
                    await emailService.SendPatientRegister(req, draw);
                });
            }

            return(result);
        }