Beispiel #1
0
        public async Task <TreatmentDiseaseDto> Add(TreatmentDiseaseDto model)
        {
            var entity = _mapper.Map <TTreatment>(model);

            entity.Code = string.Empty;
            if (model.Diseases != null && model.Diseases.Any())
            {
                entity.TTreatmentDisease = new List <TTreatmentDisease>();
                foreach (var disease in model.Diseases)
                {
                    entity.TTreatmentDisease.Add(new TTreatmentDisease
                    {
                        PatientId       = entity.PatientId,
                        MedicalRecordId = entity.MedicalRecordId,
                        DiseaseId       = disease.Id,
                        CreatedBy       = model.CreatedBy,
                        CreatedTime     = model.CreatedTime,
                        UpdatedBy       = model.UpdatedBy,
                        UpdatedTime     = model.UpdatedTime,
                        IsActived       = true,
                    });
                }
            }
            _treatmentRepository.Add(entity);
            await _treatmentRepository.SaveChangeAsync();

            var maxId = await _treatmentRepository.Repo.MaxAsync(c => c.Id);

            entity.Code = $"DT-{(maxId + 1):D10}";
            await _treatmentRepository.SaveChangeAsync();

            model.Id = entity.Id;
            return(model);
        }
        public ActionResult Create(TreatmentViewModel treatmentViewModel)
        {
            treatmentViewModel.MedicalRecordEntryViewModel = medicalRecordEntryRepository.GetById((int)TempData["medicalRecordId"]).ToViewModel();
            AddMedicalRecordToTempData(treatmentViewModel.MedicalRecordEntryViewModel.Id);

            if (ModelState.IsValid)
            {
                AddMedicalRecordToTempData(treatmentViewModel.MedicalRecordEntryViewModel.Id);
                treatmentRepository.Add(treatmentViewModel.ToDomainModel());
                return(RedirectToAction("Index", new { medicalRecordId = treatmentViewModel.MedicalRecordEntryViewModel.Id }));
            }
            AddMedicalRecordToTempData(treatmentViewModel.MedicalRecordEntryViewModel.Id);
            return(View(treatmentViewModel));
        }
Beispiel #3
0
        public void AddTreatment(Guid appointmentId, Guid clientId, Guid medicId, Guid equipmentId,
                                 Guid medicationId, int equipmentUsageTime, int medicationQuantityUsed, string diagnosis
                                 )
        {
            var appointment = appointmentRepository.GetAppointmentByID(appointmentId);
            var client      = clientRepository.GetById(clientId);
            var medic       = medicRepository.GetById(medicId);
            var equipment   = equipmentTypeRepository.GetEquipmentById(equipmentId);
            var medication  = medicationTypeRepository.GetMedicationById(medicationId);



            var treatment = treatmentRepository.Add(new Treatment()
            {
                Id                    = Guid.NewGuid(),
                Medic                 = medic,
                Client                = client,
                Diagnosis             = diagnosis,
                Equipments_Treatment  = new List <Equipment_Treatment>(),
                Medications_Treatment = new List <Medication_Treatment>()
            });

            var equipment_treatment = equipment_TreatmentRepository.Add(new Equipment_Treatment
            {
                Id        = Guid.NewGuid(),
                UsageTime = equipmentUsageTime,
            });

            var medication_treatment = medication_TreatmentRepository.Add(new Medication_Treatment
            {
                Id           = Guid.NewGuid(),
                QuantityUsed = medicationQuantityUsed
            });

            equipment.Equipment_Treatments.Add(equipment_treatment);
            equipmentTypeRepository.Update(equipment);
            medication.Medication_Treatments.Add(medication_treatment);
            medicationTypeRepository.Update(medication);
            treatment.Medications_Treatment.Add(medication_treatment);
            treatment.Equipments_Treatment.Add(equipment_treatment);
            treatmentRepository.Update(treatment);
            appointment.Treatment = treatment;
            appointmentRepository.Update(appointment);
        }
Beispiel #4
0
        public async Task <ActionResult <Treatment> > Add(Treatment treatment)
        {
            try
            {
                if (treatment == null)
                {
                    return(BadRequest());
                }

                var result = await treatmentRepository.Add(treatment);

                return(result);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error creating the new user record"));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Adds a Treatment with specific domain logic.
        /// </summary>
        /// <param name="treatment">The treatment that needs to be added.</param>
        public void Add(Treatment treatment)
        {
            try
            {
                ValidateTreatment(treatment);
                Animal animal = _animalRepository.FindByID(treatment.Stay.AnimalID);

                // Treatment of Type castration or Sterilasation updates the animal castration status
                if (treatment.TreatmentType == TreatmentType.Castration || treatment.TreatmentType == TreatmentType.Sterilasation)
                {
                    animal.Castrated = true;
                    _animalRepository.SaveAnimal(animal);
                }

                // If no error; treatment follows all business rules.
                _treatmentRepository.Add(treatment);
            } catch (InvalidOperationException e)
            {
                throw e;
            }
        }
 public Treatment AddTreatment(Treatment treatment)
 {
     return(_treatmentRepository.Add(treatment));
 }
Beispiel #7
0
        protected override void TakeFormAction()
        {
            var currentActvity = CurrentActivity();

            if (currentActvity.CurrAction.FormDataProcessing.IsSaveRequestData)
            {
                if (WorkflowInstance.Treatment != null)
                {
                    var  treatment = WorkflowInstance.Treatment;
                    bool isUpdate  = false;

                    if (RequestHeader.Id > 0)
                    {
                        var currentTreatment = _treatmentRepository.GetByRequestHeader(RequestHeader.Id);
                        if (currentTreatment != null)
                        {
                            currentTreatment.RequestHeaderId  = treatment.RequestHeaderId;
                            currentTreatment.FitToWork        = treatment.FitToWork;
                            currentTreatment.TimeArrived      = treatment.TimeArrived;
                            currentTreatment.TimeDeparted     = treatment.TimeDeparted;
                            currentTreatment.CheckOutDateTime = treatment.TimeDeparted; // treatment.CheckOutDateTime;
                            currentTreatment.Days             = (treatment.FitToWork == 0) ? treatment.Days : null;
                            currentTreatment.Remark           = (treatment.FitToWork == 0) ? treatment.Remark : string.Empty;
                            currentTreatment.Symptom          = treatment.Symptom;
                            currentTreatment.Diagnosis        = treatment.Diagnosis;
                            currentTreatment.Hours            = (treatment.FitToWork == 1) ? treatment.Hours : null;
                            currentTreatment.Comment          = treatment.Comment;
                            currentTreatment.WorkShift        = treatment.WorkShift;

                            _treatmentRepository.Update(currentTreatment);
                            treatment.RequestHeaderId = RequestHeader.Id;
                            isUpdate = true;
                        }
                    }

                    if (!isUpdate)
                    {
                        WorkflowInstance.Treatment.RequestHeaderId = RequestHeader.Id;
                        _treatmentRepository.Add(treatment);
                    }

                    if (treatment.FitToWork == 0)
                    {
                        ProcessUnfitToWorkData(WorkflowInstance.AddUnfitToWorks, DataOP.AddNew, RequestHeader);
                        ProcessUnfitToWorkData(WorkflowInstance.EditUnfitToWorks, DataOP.EDIT, RequestHeader);
                        ProcessUnfitToWorkData(WorkflowInstance.DelUnfitToWorks, DataOP.DEL, RequestHeader);

                        if (RequestHeader != null && RequestHeader.Id > 0)
                        {
                            _treatmentRepository.UpdateDayLeave(RequestHeader.Id);
                        }
                    }
                    else if (treatment.FitToWork == 1)
                    {
                        if (RequestHeader != null && RequestHeader.Id > 0)
                        {
                            _treatmentRepository.DeleteUniftTW(RequestHeader.Id);
                        }
                    }
                    else if (treatment.FitToWork == 1)
                    {
                        if (RequestHeader != null && RequestHeader.Id > 0)
                        {
                            _treatmentRepository.DeleteUniftTW(RequestHeader.Id);
                        }
                    }

                    // Process transaction data for request items
                    ProcessPrescriptionData(WorkflowInstance.AddPrescriptions, DataOP.AddNew, treatment);
                    ProcessPrescriptionData(WorkflowInstance.EditPrescriptions, DataOP.EDIT, treatment);
                    ProcessPrescriptionData(WorkflowInstance.DelPrescriptions, DataOP.DEL, treatment);

                    if (FORM_SUBMISSION.IsCaseInsensitiveEqual(CurrentActivity().ActivityName))
                    {
                        WorkflowInstance.Message = string.Format("Your request number is @FOLIO. <br/>{0}", _treatmentRepository.GetPendingTreamentMessage());
                    }
                }
                else
                {
                    throw new Exception("Medical treatment form has no request instance");
                }
            }
        }