Example #1
0
        public Domain.Entities.Medications.Medication CreateMedication(Domain.Entities.Medications.Medication medication)
        {
            // TODO(Jovan): Handle bad request?
            Domain.Entities.Medications.Medication fullMedication = medication;
            _medicationRepository.Create(medication);

            return(medication);
        }
        public async Task <ResultDto <Guid, MedicationCreateStatus> > Create(MedicationEntity request, string externalId)
        {
            try
            {
                var model = _mapper.Map <MedicationEntity, MedicationCreateRequest>(request);

                try
                {
                    var _model = _mapper.Map <MedicationCreateRequest, Medication>(model);
                    _model.ExternalId    = externalId;
                    _model.EffectiveDate = DateTime.UtcNow;

                    //convert frequency string to numbers
                    var(frequncyNum, frequncyTimings) = MedicationHelper.GetMedicationFrequentyInNumber(_model.Frenquency);
                    _model.FrenquencyInDay            = frequncyNum;
                    var result = await _repository.Create(_model);

                    return(result);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(new ResultDto <Guid, MedicationCreateStatus>(MedicationCreateStatus.InternalServerError));
                }
                catch (Exception ex)
                {
                    return(new ResultDto <Guid, MedicationCreateStatus>(MedicationCreateStatus.InternalServerError));
                }
            }
            catch (Exception ex)
            {
                return(new ResultDto <Guid, MedicationCreateStatus>(MedicationCreateStatus.InternalServerError));
            }
        }
        public void Post_Creates_New_Medication()
        {
            var medication = new Medication();

            repo.Create(medication).Returns(true);

            var result = underTest.Post(medication);

            Assert.True(result);
        }
        public Medication CreateMedication(Medication medication)
        {
            Medication fullMedication = medication;

            medicationRepository.Create(medication);
            Specialization specialization = fullMedication.MedicationCategory[0].Specialization;

            notificationService.MedForValidationNotification(specialization);
            return(medication);
        }
        public bool Post([FromBody] Medication medication)
        {
            repo.Create(medication);

            return(true);
        }