public void savePatientWhoStage(int whoStage) { PatientWhoStageManager whoStageManager = new PatientWhoStageManager(); int patientId = Convert.ToInt32(Session["PatientPK"].ToString()); int patientMasterVisitId = Convert.ToInt32(Session["ExistingRecordPatientMasterVisitID"].ToString() == "0" ? Session["PatientMasterVisitID"].ToString() : Session["ExistingRecordPatientMasterVisitID"].ToString()); PatientWhoStage PatientWhoStage = whoStageManager.GetPatientWhoStage(patientId, patientMasterVisitId); if (PatientWhoStage != null) { PatientWhoStage.WHOStage = whoStage; whoStageManager.UpdatePatientWhoStage(PatientWhoStage); } else { int whoResult = whoStageManager.addPatientWhoStage(patientId, patientMasterVisitId, whoStage); if (whoResult > 0) { int facilityId = Convert.ToInt32(Session["AppPosID"]); MessageEventArgs args = new MessageEventArgs() { PatientId = patientId, EntityId = whoResult, MessageType = MessageType.ObservationResult, EventOccurred = "Patient Observation Result", FacilityId = facilityId, ObservationType = ObservationType.WhoStage }; Publisher.RaiseEventAsync(this, args).ConfigureAwait(false); } } }
public int UpdatePatientWhoStage(PatientWhoStage patientWhoStage) { using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext())) { unitOfWork.PatientWhoStageRepository.Update(patientWhoStage); unitOfWork.Complete(); unitOfWork.Dispose(); return(patientWhoStage.Id); } }
public int UpdatePatientWhoStage(PatientWhoStage patientWhoStage) { try { return(_mgr.UpdatePatientWhoStage(patientWhoStage)); } catch (Exception e) { throw new Exception(e.Message); } }
public async Task <int> EditPatientWhoStage(PatientWhoStage patientWHOStage) { try { _unitOfWork.Repository <PatientWhoStage>().Update(patientWHOStage); await _unitOfWork.SaveAsync(); return(patientWHOStage.Id); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); throw; } }
public PatientWhoStage GetPatientWhoStage(int patientId, int patientMasterVisitId) { try { PatientWhoStage patientWhoStage = _unitOfWork.Repository <PatientWhoStage>() .Get(x => x.PatientId == patientId && x.PatientMasterVisitId == patientMasterVisitId) .FirstOrDefault(); return(patientWhoStage); } catch (Exception e) { Log.Error(e.Message + " " + e.InnerException); throw; } }
public int addPatientWhoStage(int patientId, int patientMasterVisitId, int whoStage) { try { PatientWhoStage patientWhoStage = new PatientWhoStage() { PatientId = patientId, PatientMasterVisitId = patientMasterVisitId, WHOStage = whoStage }; return(_mgr.addPatientWhoStage(patientWhoStage)); } catch (Exception e) { throw new Exception(e.Message); } }
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)); } } }
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 })); } }