コード例 #1
0
        public PostTreatmentModel PostTratmentData(int treatmentRecordid)
        {
            var data = _treatmentRecordServices.GetPostTreatmentByTreatmentRecordId(treatmentRecordid);
            var postTreatmentData = new PostTreatmentModel();

            if (data != null)
            {
                postTreatmentData.TreatmentRecordId                = (int)data.TreatmentRecordId;
                postTreatmentData.IsBiohazardWasteDisposed         = data.IsBiohazardWasteDisposed;
                postTreatmentData.IsEquipmentCleanedAndDisinfected = data.IsEquipmentCleanedAndDisinfected;
                postTreatmentData.IsPostCVCCarePerPolicy           = data.IsPostCVCCarePerPolicy;
                postTreatmentData.IsRinseBackComplete              = data.IsRinseBackComplete;
                postTreatmentData.IsSideRailsUp  = data.IsSideRailsUp;
                postTreatmentData.MedicationList = data.Medications.Select(a =>
                                                                           new MedicationModel
                {
                    Comments        = a.Comments,
                    Dosage          = a.Dosage,
                    Id              = a.Id,
                    Name            = a.Name,
                    PostTreatmentId = a.PostTreatmentId,
                    Route           = a.Route
                }).ToList();
                postTreatmentData.Id = data.Id;
            }


            return(postTreatmentData);
        }
        public IActionResult GetById(int Id)
        {
            ResultModel resultModel = new ResultModel();

            try
            {
                var postTreatment = _treatmentRecordServices.GetPostTreatmentById(Id);
                var model         = new PostTreatmentModel();
                model.Id = postTreatment.Id;
                model.IsBiohazardWasteDisposed         = postTreatment.IsBiohazardWasteDisposed;
                model.IsEquipmentCleanedAndDisinfected = postTreatment.IsEquipmentCleanedAndDisinfected;
                model.IsPostCVCCarePerPolicy           = postTreatment.IsPostCVCCarePerPolicy;
                model.IsRinseBackComplete = postTreatment.IsRinseBackComplete;
                model.IsSideRailsUp       = postTreatment.IsSideRailsUp;
                model.TreatmentRecordId   = postTreatment.TreatmentRecordId;
                var data = postTreatment.Medications.Select(a =>
                                                            new MedicationModel
                {
                    PostTreatmentId = a.PostTreatmentId,
                    Comments        = a.Comments,
                    Dosage          = a.Dosage,
                    Id    = a.Id,
                    Name  = a.Name,
                    Route = a.Route
                });
                model.MedicationList = data.ToList();
                resultModel.Message  = ValidationMessages.Success;
                resultModel.Status   = 1;
                resultModel.Response = model;
                return(Ok(resultModel));
            }
            catch (Exception e)
            {
                resultModel.Message  = ValidationMessages.Failure;
                resultModel.Status   = 0;
                resultModel.Response = null;
                return(Ok(resultModel));
            }
        }
        public IActionResult Create(PostTreatmentModel model)
        {
            ResultModel resultModel = new ResultModel();

            try
            {
                if (model.Id == 0)
                {
                    var postTreatment = new PostTreatment();
                    postTreatment.IsBiohazardWasteDisposed         = model.IsBiohazardWasteDisposed;
                    postTreatment.IsEquipmentCleanedAndDisinfected = model.IsEquipmentCleanedAndDisinfected;
                    postTreatment.IsPostCVCCarePerPolicy           = model.IsPostCVCCarePerPolicy;
                    postTreatment.IsRinseBackComplete = model.IsRinseBackComplete;
                    postTreatment.IsSideRailsUp       = model.IsSideRailsUp;
                    postTreatment.TreatmentRecordId   = model.TreatmentRecordId;
                    //Mark Complete
                    postTreatment.MarkComplete = model.MarkComplete;
                    _treatmentRecordServices.InsertPostTreatment(postTreatment);
                    //Bhawana(09/10/2019)
                    //Change treatment Record Status
                    _reportService.UpdateTreatmentStatusID((int)postTreatment.TreatmentRecordId);


                    foreach (var medicationData in model.MedicationList)
                    {
                        var medication = new Medication();
                        medication.PostTreatmentId = postTreatment.Id;
                        medication.Dosage          = medicationData.Dosage;
                        medication.Comments        = medicationData.Comments;
                        medication.Route           = medicationData.Route;
                        medication.Name            = medicationData.Name;
                        postTreatment.Medications.Add(medication);
                        _treatmentRecordServices.UpdatePostTreatment(postTreatment);
                    }
                    //12/10/19 aakansha
                    //model response
                    model.Id = postTreatment.Id;
                    model.TreatmentRecordId = postTreatment.TreatmentRecordId;
                    var postTreatment1 = _treatmentRecordServices.GetPostTreatmentById(postTreatment.Id);
                    foreach (var Medication in postTreatment.Medications)
                    {
                        var MEdication = new MedicationModel();

                        MEdication.Id              = Medication.Id;
                        MEdication.Name            = Medication.Name;
                        MEdication.PostTreatmentId = Medication.PostTreatmentId;
                        MEdication.Route           = Medication.Route;
                        model.MedicationList.Clear();
                        model.MedicationList.Add(MEdication);
                    }

                    resultModel.Message  = ValidationMessages.Success;
                    resultModel.Status   = 1;
                    resultModel.Response = model;
                    return(Ok(resultModel));
                }
                else
                {
                    var postTreatment = _treatmentRecordServices.GetPostTreatmentById(model.Id);
                    postTreatment.IsBiohazardWasteDisposed         = model.IsBiohazardWasteDisposed;
                    postTreatment.IsEquipmentCleanedAndDisinfected = model.IsEquipmentCleanedAndDisinfected;
                    postTreatment.IsPostCVCCarePerPolicy           = model.IsPostCVCCarePerPolicy;
                    postTreatment.IsRinseBackComplete = model.IsRinseBackComplete;
                    postTreatment.IsSideRailsUp       = model.IsSideRailsUp;
                    postTreatment.TreatmentRecordId   = model.TreatmentRecordId;
                    postTreatment.Id           = model.Id;
                    postTreatment.MarkComplete = model.MarkComplete;
                    _treatmentRecordServices.UpdatePostTreatment(postTreatment);
                    //Bhawana(09/10/2019)
                    //Change treatment Record Status
                    _reportService.UpdateTreatmentStatusID((int)postTreatment.TreatmentRecordId);
                    foreach (var medicationList in model.MedicationList)
                    {
                        if (medicationList.Id == 0)
                        {
                            var medication = new Medication();
                            medication.PostTreatmentId = postTreatment.Id;
                            medication.Dosage          = medicationList.Dosage;
                            medication.Comments        = medicationList.Comments;
                            medication.Route           = medicationList.Route;
                            medication.Name            = medicationList.Name;
                            postTreatment.Medications.Add(medication);
                            _treatmentRecordServices.UpdatePostTreatment(postTreatment);
                        }
                        else
                        {
                            var medication = _treatmentRecordServices.GetMedicationById(medicationList.Id);
                            medication.PostTreatmentId = postTreatment.Id;
                            medication.Dosage          = medicationList.Dosage;
                            medication.Comments        = medicationList.Comments;
                            medication.Route           = medicationList.Route;
                            medication.Name            = medicationList.Name;

                            _treatmentRecordServices.UpdateMedication(medication);
                        }
                    }
                    //12/10/19 aakansha
                    //model response
                    model.Id = postTreatment.Id;
                    model.TreatmentRecordId = postTreatment.TreatmentRecordId;
                    var postTreatment1 = _treatmentRecordServices.GetPostTreatmentById(postTreatment.Id);
                    foreach (var Medication in postTreatment.Medications)
                    {
                        var MEdication = new MedicationModel();

                        MEdication.Id              = Medication.Id;
                        MEdication.Name            = Medication.Name;
                        MEdication.PostTreatmentId = Medication.PostTreatmentId;
                        MEdication.Route           = Medication.Route;
                        model.MedicationList.Clear();
                        model.MedicationList.Add(MEdication);
                    }
                    resultModel.Message  = ValidationMessages.Success;
                    resultModel.Status   = 1;
                    resultModel.Response = model;
                    return(Ok(resultModel));
                }
            }
            catch (Exception e)
            {
                resultModel.Message  = ValidationMessages.Failure;
                resultModel.Status   = 0;
                resultModel.Response = null;
                return(Ok(resultModel));
            }
        }