public PatientScreening GetPatientScreening(int patientId, int patientMasterVisitId, int screeningId)
 {
     try
     {
         PatientScreening patientScreening = _unitOfWork.Repository <PatientScreening>().Get(x =>
                                                                                             x.PatientId == patientId && x.PatientMasterVisitId == patientMasterVisitId &&
                                                                                             x.ScreeningTypeId == screeningId).FirstOrDefault();
         return(patientScreening);
     }
     catch (Exception e)
     {
         Log.Error(e.Message + " " + e.InnerException);
         throw;
     }
 }
        public async Task <int> EditPatientScreening(PatientScreening patientScreening)
        {
            try
            {
                _unitOfWork.Repository <PatientScreening>().Update(patientScreening);
                await _unitOfWork.SaveAsync();

                return(patientScreening.Id);
            }
            catch (Exception e)
            {
                Log.Error(e.Message + " " + e.InnerException);
                throw;
            }
        }
Beispiel #3
0
        public async Task <Result <ClientMonitoringCommandResponse> > Handle(ClientMonitoringCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                int PatientScreeningResult = 0;
                try
                {
                    ClientMonitoringServices clientMonitoringService = new ClientMonitoringServices(_unitOfWork);

                    PatientWhoStage patientWhoStage = new PatientWhoStage()
                    {
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        WHOStage             = request.WhoStage
                    };

                    int vlSampleTypeId = await _commonUnitOfWork.Repository <LookupMaster>()
                                         .Get(x => x.Name == "ViralLoadSampleTaken").Select(x => x.Id).FirstOrDefaultAsync();

                    string yesNoId = await _commonUnitOfWork.Repository <LookupItem>()
                                     .Get(x => x.Id == request.ViralLoadSampleTaken).Select(x => x.Name).FirstOrDefaultAsync();

                    int patientWhoStageResult = await clientMonitoringService.AddPatientWhoStage(patientWhoStage);

                    int tbscreeningTypeId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItemView>().Get(x => x.MasterName == "TBScreeningPMTCT").Select(x => x.MasterId).FirstOrDefaultAsync();

                    int tbScreeningcaegoryId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItem>().Get(x => x.Name == "TBScreening").Select(x => x.Id).FirstOrDefaultAsync();

                    if (vlSampleTypeId > 0)
                    {
                        PatientScreening patientViralLoadScreening = new PatientScreening()
                        {
                            PatientId            = request.PatientId,
                            PatientMasterVisitId = request.PatientMasterVisitId,
                            ScreeningTypeId      = vlSampleTypeId,
                            ScreeningValueId     = request.ViralLoadSampleTaken,
                            ScreeningDone        = (yesNoId == "Yes")? true: false,
                            ScreeningDate        = DateTime.Now,
                            ScreeningCategoryId  = vlSampleTypeId,
                            Comment    = request.Comments,
                            CreateDate = DateTime.Now,
                            CreatedBy  = request.CreatedBy
                        };
                        PatientScreeningResult = await clientMonitoringService.AddPatientScreening(patientViralLoadScreening);
                    }
                    if (request.ScreeningDone)
                    {
                        int cacxTypeId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItemView>().Get(x => x.MasterName == "CaCxScreening").Select(x => x.MasterId).FirstOrDefaultAsync();

                        int cacxCategoryId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItem>().Get(x => x.Name == "CaCxMethod").Select(x => x.Id).FirstOrDefaultAsync();

                        // CACXMethod
                        PatientScreening patientScreeningCaCxMethod = new PatientScreening()
                        {
                            PatientId            = request.PatientId,
                            PatientMasterVisitId = request.PatientMasterVisitId,
                            ScreeningTypeId      = cacxTypeId,
                            ScreeningValueId     = request.cacxResult,
                            ScreeningDone        = request.ScreeningDone,
                            ScreeningDate        = DateTime.Now,
                            ScreeningCategoryId  = request.cacxMethod,
                            Comment    = request.ClinicalNotes,
                            CreateDate = DateTime.Now,
                            CreatedBy  = request.CreatedBy
                        };
                        PatientScreeningResult = await clientMonitoringService.AddPatientScreening(patientScreeningCaCxMethod);
                    }


                    //TB Screening
                    PatientScreening patientScreeningTb = new PatientScreening()
                    {
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        ScreeningTypeId      = tbscreeningTypeId,
                        ScreeningValueId     = request.screenedTB,
                        ScreeningDone        = true,
                        ScreeningDate        = DateTime.Now,
                        ScreeningCategoryId  = tbScreeningcaegoryId,
                        CreateDate           = DateTime.Now,
                        CreatedBy            = request.CreatedBy
                    };

                    await clientMonitoringService.AddPatientScreening(patientScreeningTb);

                    if (request.ClinicalNotes != "n/a")
                    {
                        PatientClinicalNotes patientClinicalNotes = new PatientClinicalNotes()
                        {
                            PatientId            = request.PatientId,
                            PatientMasterVisitId = request.PatientMasterVisitId,
                            ServiceAreaId        = request.ServiceAreaId,
                            ClinicalNotes        = request.ClinicalNotes,
                            CreateDate           = DateTime.Now,
                            CreatedBy            = request.CreatedBy,
                            Active = false
                        };

                        int clinicalNotesId = await clientMonitoringService.AddPatientClinicalNotes(patientClinicalNotes);
                    }

                    return(Result <ClientMonitoringCommandResponse> .Valid(new ClientMonitoringCommandResponse()
                    {
                        resultId = PatientScreeningResult
                    }));
                }
                catch (Exception e)
                {
                    Log.Error(e.Message + " " + e.InnerException);
                    return(Library.Result <ClientMonitoringCommandResponse> .Invalid(e.Message));
                }
            }
        }
Beispiel #4
0
        public async Task <Result <ClientMonitoringCommandEditResponse> > Handle(ClientMonitoringEditCommand request, CancellationToken cancellationToken)
        {
            using (_unitOfWork)
            {
                ClientMonitoringServices clientMonitoringService = new ClientMonitoringServices(_unitOfWork);
                PatientWhoStage          patientWhoStage         =
                    clientMonitoringService.GetPatientWhoStage(request.PatientId, request.PatientMasterVisitId);

                patientWhoStage.WHOStage = request.WhoStage;
                int whoId = await clientMonitoringService.EditPatientWhoStage(patientWhoStage);

                int pmtctScreeningId = 0;
                int vlSampleTakenId  = 0;
                int tbScreeingId     = 0;
                int cacxScreeingId   = 0;
                int vlSampleTypeId   = await _commonUnitOfWork.Repository <LookupMaster>()
                                       .Get(x => x.Name == "ViralLoadSampleTaken").Select(x => x.Id).FirstOrDefaultAsync();

                string yesNoId = await _commonUnitOfWork.Repository <LookupItem>()
                                 .Get(x => x.Id == request.ViralLoadSampleTaken).Select(x => x.Name).FirstOrDefaultAsync();

                int patientWhoStageResult = await clientMonitoringService.EditPatientWhoStage(patientWhoStage);

                int tbscreeningTypeId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItemView>().Get(x => x.MasterName == "TBScreeningPMTCT").Select(x => x.MasterId).FirstOrDefaultAsync();

                int tbScreeningcaegoryId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItem>().Get(x => x.Name == "TBScreening").Select(x => x.Id).FirstOrDefaultAsync();


                PatientScreening viralLoadSamplePatientScreening =
                    clientMonitoringService.GetPatientScreening(request.PatientId, request.PatientMasterVisitId, vlSampleTypeId);

                if (viralLoadSamplePatientScreening != null)
                {
                    viralLoadSamplePatientScreening.ScreeningTypeId     = vlSampleTypeId;
                    viralLoadSamplePatientScreening.ScreeningValueId    = request.ViralLoadSampleTaken;
                    viralLoadSamplePatientScreening.ScreeningDone       = (yesNoId == "Yes") ? true : false;
                    viralLoadSamplePatientScreening.ScreeningCategoryId = vlSampleTypeId;
                    viralLoadSamplePatientScreening.Comment             = request.Comments;
                    vlSampleTypeId =
                        await clientMonitoringService.EditPatientScreening(viralLoadSamplePatientScreening);
                }
                else
                {
                    vlSampleTypeId = 0;
                }

                PatientScreening tbScreeningPmtctPatientScreening =
                    clientMonitoringService.GetPatientScreening(request.PatientId, request.PatientMasterVisitId, tbscreeningTypeId);
                if (tbScreeningPmtctPatientScreening != null)
                {
                    tbScreeningPmtctPatientScreening.ScreeningTypeId     = tbscreeningTypeId;
                    tbScreeningPmtctPatientScreening.ScreeningValueId    = request.screenedTB;
                    tbScreeningPmtctPatientScreening.ScreeningDone       = (yesNoId == "Yes") ? true : false;
                    tbScreeningPmtctPatientScreening.ScreeningCategoryId = tbScreeningcaegoryId;
                    tbScreeningPmtctPatientScreening.Comment             = request.Comments;
                    pmtctScreeningId =
                        await clientMonitoringService.EditPatientScreening(tbScreeningPmtctPatientScreening);
                }
                else
                {
                    pmtctScreeningId = 0;
                }

                PatientScreening tbScreeningPatientScreening =
                    clientMonitoringService.GetPatientScreening(request.PatientId, request.PatientMasterVisitId, tbScreeningcaegoryId);
                if (tbScreeningPatientScreening != null)
                {
                    tbScreeningPatientScreening.ScreeningTypeId     = tbScreeningcaegoryId;
                    tbScreeningPatientScreening.ScreeningValueId    = request.screenedTB;
                    tbScreeningPatientScreening.ScreeningDone       = (yesNoId == "Yes") ? true : false;
                    tbScreeningPatientScreening.ScreeningCategoryId = tbScreeningcaegoryId;
                    tbScreeningPatientScreening.Comment             = request.Comments;
                    tbScreeingId =
                        await clientMonitoringService.EditPatientScreening(tbScreeningPatientScreening);
                }

                if (tbScreeningPatientScreening == null && tbScreeningPmtctPatientScreening == null)
                {
                    //TB Screening
                    PatientScreening patientScreeningTb = new PatientScreening()
                    {
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        ScreeningTypeId      = tbscreeningTypeId,
                        ScreeningValueId     = request.screenedTB,
                        ScreeningDone        = true,
                        ScreeningDate        = DateTime.Now,
                        ScreeningCategoryId  = tbScreeningcaegoryId,
                        CreateDate           = DateTime.Now,
                        CreatedBy            = request.CreatedBy
                    };

                    tbScreeingId = await clientMonitoringService.AddPatientScreening(patientScreeningTb);
                }



                int cacxTypeId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItemView>().Get(x => x.MasterName == "CaCxScreening").Select(x => x.MasterId).FirstOrDefaultAsync();

                int cacxCategoryId = await _commonUnitOfWork.Repository <Common.Core.Models.LookupItem>().Get(x => x.Name == "CaCxMethod").Select(x => x.Id).FirstOrDefaultAsync();

                PatientScreening cacxScreeningPatientScreening =
                    clientMonitoringService.GetPatientScreening(request.PatientId, request.PatientMasterVisitId, cacxTypeId);
                if (cacxScreeningPatientScreening != null)
                {
                    cacxScreeningPatientScreening.ScreeningTypeId     = cacxTypeId;
                    cacxScreeningPatientScreening.ScreeningValueId    = request.cacxResult;
                    cacxScreeningPatientScreening.ScreeningDone       = (yesNoId == "Yes") ? true : false;
                    cacxScreeningPatientScreening.ScreeningCategoryId = request.cacxMethod;
                    cacxScreeningPatientScreening.Comment             = request.ClinicalNotes;
                    cacxScreeingId =
                        await clientMonitoringService.EditPatientScreening(cacxScreeningPatientScreening);
                }
                else
                {
                    //TB Screening
                    PatientScreening patientScreeningcacx = new PatientScreening()
                    {
                        PatientId            = request.PatientId,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        ScreeningTypeId      = cacxTypeId,
                        ScreeningValueId     = request.cacxResult,
                        ScreeningDone        = request.ScreeningDone,
                        ScreeningDate        = DateTime.Now,
                        ScreeningCategoryId  = request.cacxMethod,
                        Comment    = request.ClinicalNotes,
                        CreateDate = DateTime.Now,
                        CreatedBy  = request.CreatedBy
                    };

                    cacxScreeingId = await clientMonitoringService.AddPatientScreening(patientScreeningcacx);
                }



                if (tbScreeingId > 0 & pmtctScreeningId > 0 & vlSampleTypeId > 0 & cacxScreeingId > 0)
                {
                    return(Result <ClientMonitoringCommandEditResponse> .Valid(new ClientMonitoringCommandEditResponse { resultId = 1 }));
                }
                return(Result <ClientMonitoringCommandEditResponse> .Valid(new ClientMonitoringCommandEditResponse { resultId = 0 }));
            }
        }