public async Task <Result <EditPatientPhysicalExamResponse> > Handle(EditPatientPhysicalExaminationCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    PatientPhysicalExamination patientPhysicalExamination = await _unitOfWork.Repository <PatientPhysicalExamination>().FindAsync(x => x.Id == request.PatientPhysicalExamination.Id);

                    patientPhysicalExamination.PatientId            = request.PatientPhysicalExamination.PatientId;
                    patientPhysicalExamination.PatientMasterVisitId = request.PatientPhysicalExamination.PatientMasterVisitId;
                    patientPhysicalExamination.ExamId            = request.PatientPhysicalExamination.ExamId;
                    patientPhysicalExamination.ExaminationTypeId = request.PatientPhysicalExamination.ExaminationTypeId;
                    patientPhysicalExamination.FindingId         = request.PatientPhysicalExamination.FindingId;
                    patientPhysicalExamination.FindingsNotes     = request.PatientPhysicalExamination.FindingsNotes;

                    _unitOfWork.Repository <PatientPhysicalExamination>().Update(patientPhysicalExamination);
                    int result = await _unitOfWork.SaveChangesAsync();

                    _unitOfWork.Dispose();

                    return(Result <EditPatientPhysicalExamResponse> .Valid(new EditPatientPhysicalExamResponse()
                    {
                        PatientPhysicalExamId = result
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <EditPatientPhysicalExamResponse> .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <UpdatePhysicalExaminationResponse> > Handle(UpdatePatientPhysicalExaminationCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    PatientPhysicalExamination patientPhysicalExamination = new PatientPhysicalExamination()
                    {
                        PatientId            = request.PatientPhysicalExamination.PatientId,
                        PatientMasterVisitId = request.PatientPhysicalExamination.PatientMasterVisitId,
                        ExamId            = request.PatientPhysicalExamination.ExamId,
                        ExaminationTypeId = request.PatientPhysicalExamination.ExaminationTypeId,
                        FindingId         = (request.PatientPhysicalExamination.FindingId == null) ? request.PatientPhysicalExamination.FindingId : 0,
                        FindingsNotes     = (request.PatientPhysicalExamination.FindingsNotes == null) ? request.PatientPhysicalExamination.FindingsNotes : ""
                    };

                    await _unitOfWork.Repository <PatientPhysicalExamination>().AddAsync(patientPhysicalExamination);

                    int result = await _unitOfWork.SaveChangesAsync();

                    return(Result <UpdatePhysicalExaminationResponse> .Valid(new UpdatePhysicalExaminationResponse()
                    {
                        Id = result
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <UpdatePhysicalExaminationResponse> .Invalid(e.Message));
                }
            }
        }
        public async Task <PatientPhysicalExamination> AddPatientPhysicalExamination(PatientPhysicalExamination patientPhysicalExamination)
        {
            try
            {
                await _unitOfWork.Repository <PatientPhysicalExamination>().AddAsync(patientPhysicalExamination);

                await _unitOfWork.SaveAsync();

                return(patientPhysicalExamination);
            }
            catch (Exception e)
            {
                Log.Error(e.Message + " " + e.InnerException);
                throw e;
            }
        }