public async Task <Result <UpdateHeiDeliveryResponse> > Handle(UpdateHeiDeliveryCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    var heiEncounter = await _unitOfWork.Repository <HEIEncounter>().FindByIdAsync(request.Id);

                    if (heiEncounter != null)
                    {
                        heiEncounter.PlaceOfDeliveryId             = request.PlaceOfDeliveryId;
                        heiEncounter.ModeOfDeliveryId              = request.ModeOfDeliveryId;
                        heiEncounter.BirthWeight                   = request.BirthWeight;
                        heiEncounter.ArvProphylaxisId              = request.ArvProphylaxisId;
                        heiEncounter.ArvProphylaxisOther           = request.ArvProphylaxisOther;
                        heiEncounter.MotherRegisteredId            = request.MotherIsRegistered;
                        heiEncounter.MotherPersonId                = request.MotherPersonId;
                        heiEncounter.MotherStatusId                = request.MotherStatusId;
                        heiEncounter.PrimaryCareGiverID            = request.PrimaryCareGiverID;
                        heiEncounter.MotherName                    = request.MotherName;
                        heiEncounter.MotherCCCNumber               = request.MotherCCCNumber;
                        heiEncounter.MotherPMTCTDrugsId            = request.MotherPMTCTDrugsId;
                        heiEncounter.MotherPMTCTRegimenId          = request.MotherPMTCTRegimenId;
                        heiEncounter.MotherPMTCTRegimenOther       = request.MotherPMTCTRegimenOther;
                        heiEncounter.MotherArtInfantEnrolId        = request.MotherArtInfantEnrolId;
                        heiEncounter.MotherArtInfantEnrolRegimenId = request.MotherArtInfantEnrolRegimenId;

                        _unitOfWork.Repository <HEIEncounter>().Update(heiEncounter);
                        await _unitOfWork.SaveAsync();

                        return(Result <UpdateHeiDeliveryResponse> .Valid(new UpdateHeiDeliveryResponse()
                        {
                            Message = "Successfully updated heidelivery"
                        }));
                    }
                    else
                    {
                        return(Result <UpdateHeiDeliveryResponse> .Invalid($"Could not find heiencounter for Id: {request.Id}"));
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"Error updating heidelivery for Id: {request.Id}, Message: {e.Message}");
                    return(Result <UpdateHeiDeliveryResponse> .Invalid($"Error updating heidelivery for Id: {request.Id}, Message: {e.Message}"));
                }
            }
        }
        public async Task <Result <PatientIpt> > Handle(AddHeiPatientIptCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    await _unitOfWork.Repository <PatientIpt>().AddAsync(request.PatientIpt);

                    await _unitOfWork.SaveAsync();

                    return(Result <PatientIpt> .Valid(request.PatientIpt));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <PatientIpt> .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <VaccinationResponse> > Handle(AddImmunizationHistoryCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    List <Vaccination> vaccinations = new List <Vaccination>();

                    foreach (var vaccine in request.Vaccinations)
                    {
                        var vacinneItem = new Vaccination()
                        {
                            AppointmentId        = vaccine.AppointmentId,
                            Active               = vaccine.Active,
                            CreateDate           = vaccine.CreateDate,
                            CreatedBy            = vaccine.CreatedBy,
                            DeleteFlag           = vaccine.DeleteFlag,
                            PatientId            = vaccine.PatientId,
                            PatientMasterVisitId = vaccine.PatientMasterVisitId,
                            PeriodId             = vaccine.PeriodId,
                            VaccineDate          = vaccine.VaccineDate,
                            VaccineStage         = vaccine.VaccineStage,
                            Vaccine              = vaccine.Vaccine,
                        };
                        vaccinations.Add(vacinneItem);
                    }

                    await _unitOfWork.Repository <Vaccination>().AddRangeAsync(vaccinations);

                    await _unitOfWork.SaveAsync();

                    return(Result <VaccinationResponse> .Valid(new VaccinationResponse()
                    {
                        Message = "Vaccination Added successfully"
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <VaccinationResponse> .Invalid(e.Message));
                }
            }
        }
示例#4
0
        public async Task <Result <object> > Handle(AddPatientVitalCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var patientVital = _mapper.Map <PatientVital>(request);
                await _pmtctUnitOfWork.Repository <PatientVital>().AddAsync(patientVital);

                await _pmtctUnitOfWork.SaveAsync();

                return(Result <object> .Valid(new { patientVital.Id }));
            }
            catch (Exception ex)
            {
                string message =
                    $"An error occured while adding patient vital details for patient master visit {request.PatientMasterVisitId}";
                Log.Error(message, ex);
                return(Result <object> .Invalid(message));
            }
        }
示例#5
0
        public async Task <Result <DeletePreventiveServiceCommandResult> > Handle(DeletePatientPreventiveServiceCommand request, CancellationToken cancellationToken)
        {
            using (_pmtctUnitOfWork)
            {
                try
                {
                    if (request.Id > 0)
                    {
                        var preventiveservices = _pmtctUnitOfWork.Repository <PreventiveService>().Get(x => x.Id == request.Id).FirstOrDefault();

                        if (preventiveservices != null)
                        {
                            preventiveservices.DeleteFlag = true;

                            _pmtctUnitOfWork.Repository <PreventiveService>().Update(preventiveservices);
                            await _pmtctUnitOfWork.SaveAsync();

                            preventiveServiceId = 1;
                        }
                        else
                        {
                            preventiveServiceId = 0;
                        }
                    }
                    else
                    {
                        preventiveServiceId = 0;
                    }


                    return(Result <DeletePreventiveServiceCommandResult> .Valid(new DeletePreventiveServiceCommandResult()
                    {
                        PreventiveServiceId = preventiveServiceId
                    }));
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                    return(Result <DeletePreventiveServiceCommandResult> .Invalid(ex.Message));
                }
            }
        }
示例#6
0
        public async Task <Result <AddMilestoneResponse> > Handle(AddMilestoneCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    List <HEIMilestone> heiMilestones = new List <HEIMilestone>();

                    foreach (var milestone in request.PatientMilestone)
                    {
                        HEIMilestone milestoneItem = new HEIMilestone()
                        {
                            PatientId            = milestone.PatientId,
                            PatientMasterVisitId = milestone.PatientMasterVisitId,
                            TypeAssessedId       = milestone.TypeAssessedId,
                            AchievedId           = milestone.AchievedId,
                            StatusId             = milestone.StatusId,
                            Comment      = milestone.Comment,
                            CreatedBy    = milestone.CreatedBy,
                            CreateDate   = milestone.CreateDate,
                            DeleteFlag   = milestone.DeleteFlag,
                            DateAssessed = milestone.DateAssessed
                        };
                        heiMilestones.Add(milestoneItem);
                    }

                    await _unitOfWork.Repository <HEIMilestone>().AddRangeAsync(heiMilestones);

                    await _unitOfWork.SaveAsync();

                    return(Result <AddMilestoneResponse> .Valid(new AddMilestoneResponse()
                    {
                        Message = "Milestone Added Successfully"
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Result <AddMilestoneResponse> .Invalid(e.Message));
                }
            }
        }
示例#7
0
        public async Task <Result <DeletePatientEducationCommandResult> > Handle(DeletePatientEducationCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    if (request.Id > 0)
                    {
                        var patientEducation = await _unitOfWork.Repository <PatientEducation>().Get(x => x.Id == request.Id)
                                               .FirstOrDefaultAsync();

                        if (patientEducation != null)
                        {
                            patientEducation.DeleteFlag = true;
                            _unitOfWork.Repository <PatientEducation>().Update(patientEducation);
                            educationresultId = 1;
                            await _unitOfWork.SaveAsync();
                        }

                        else
                        {
                            educationresultId = 0;
                        }
                    }
                    else
                    {
                        educationresultId = 0;
                    }
                    return(Result <DeletePatientEducationCommandResult> .Valid(new DeletePatientEducationCommandResult()
                    {
                        PatientCounsellingId = educationresultId
                    }));
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);

                    return(Result <DeletePatientEducationCommandResult> .Invalid(ex.Message));
                }
            }
        }
示例#8
0
        public async Task <PatientPregnancy> AddPatientPregnancy(PatientPregnancy patientPregnancy)
        {
            try
            {
                await _unitOfWork.Repository <PatientPregnancy>().AddAsync(patientPregnancy);

                await _unitOfWork.SaveAsync();

                return(patientPregnancy);
            }catch (Exception e)
            {
                Log.Error(e.Message);
                throw e;
            }
        }
示例#9
0
        public async Task <Library.Result <PatientVisitDetailsCommandResult> > Handle(PatientVisitProfileCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    VisitNumber = Convert.ToInt32(request.VisitNumber);

                    PatientProfile patientProfile = new PatientProfile()
                    {
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        AgeMenarche          = request.AgeMenarche,
                        PregnancyId          = request.PregnancyId,
                        VisitNumber          = Convert.ToInt32(request.VisitNumber),
                        VisitType            = Convert.ToInt32(request.VisitType),

                        // CreatedBy = 2,
                        CreatedBy  = request.CreatedBy,
                        CreateDate = DateTime.Now,
                    };

                    await _unitOfWork.Repository <PatientProfile>().AddAsync(patientProfile);

                    await _unitOfWork.SaveAsync();

                    return(Library.Result <PatientVisitDetailsCommandResult> .Valid(new PatientVisitDetailsCommandResult()
                    {
                        PatientMasterVisitId = request.PatientMasterVisitId,
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Library.Result <PatientVisitDetailsCommandResult> .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <Core.Models.VisitDetails> > Handle(AddVisitDetailsCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    //PatientPregnancy patientPregnancy = _unitOfWork.Repository<PatientPregnancy>()
                    //    //.Get(x => x.PatientId == request.PatientId).FirstOrDefault();

                    Core.Models.VisitDetails visitDetails = new Core.Models.VisitDetails()
                    {
                        CreateDate           = DateTime.Now,
                        CreatedBy            = request.UserId,
                        DaysPostPartum       = request.DaysPostPartum,
                        DeleteFlag           = false,
                        PregnancyId          = request.PregnancyId,
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        VisitNumber          = request.VisitNumber,
                        VisitType            = request.VisitType,
                        VisitDate            = request.VisitDate,
                        ServiceAreaId        = request.ServiceAreaId
                    };

                    await _unitOfWork.Repository <Core.Models.VisitDetails>().AddAsync(visitDetails);

                    await _unitOfWork.SaveAsync();

                    return(Result <Core.Models.VisitDetails> .Valid(visitDetails));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <Core.Models.VisitDetails> .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <AddPatientEducationCommandResult> > Handle(AddPatientEducationCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    PatientEducation patientEducation = new PatientEducation(request.PatientId, request.PatientMasterVisitId, request.CounsellingTopicId, request.CounsellingDate, request.IsCounsellingDone, request.CreatedBy);

                    await _unitOfWork.Repository <PatientEducation>().AddAsync(patientEducation);

                    await _unitOfWork.SaveAsync();

                    return(Result <AddPatientEducationCommandResult> .Valid(new AddPatientEducationCommandResult()
                    {
                        PatientCounsellingId = patientEducation.Id
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message);
                    return(Result <AddPatientEducationCommandResult> .Invalid(e.Message));
                }
            }
        }
        public async Task <Result <PatientChronicIllness> > Handle(DeletePatientChronicIllnessCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                try
                {
                    PatientChronicIllness patientChronicIllness = await _unitOfWork.Repository <PatientChronicIllness>()
                                                                  .Get(x => x.Id == request.Id && !x.DeleteFlag).FirstOrDefaultAsync();

                    if (patientChronicIllness != null)
                    {
                        patientChronicIllness.DeleteFlag = true;
                        _unitOfWork.Repository <PatientChronicIllness>().Update(patientChronicIllness);
                        await _unitOfWork.SaveAsync();
                    }
                    return(Result <PatientChronicIllness> .Valid(patientChronicIllness));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + e.InnerException);
                    return(Result <PatientChronicIllness> .Invalid(e.Message));
                }
            }
        }