Exemple #1
0
        public async Task <PatientConsent> addPatientConsent(int patientId, int patientMasterVisitId, int serviceAreaId, int consentValue, int consentTypeId, DateTime consentDate, int userId, int?declineReason)
        {
            try
            {
                PatientConsent patientConsent = new PatientConsent()
                {
                    PatientId            = patientId,
                    PatientMasterVisitId = patientMasterVisitId,
                    ServiceAreaId        = serviceAreaId,
                    ConsentValue         = consentValue,
                    ConsentType          = consentTypeId,
                    DeclineReason        = declineReason,
                    ConsentDate          = consentDate,
                    DeleteFlag           = false,
                    CreatedBy            = userId,
                    CreateDate           = DateTime.Now
                };

                await _unitOfWork.Repository <PatientConsent>().AddAsync(patientConsent);

                await _unitOfWork.SaveAsync();

                return(patientConsent);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #2
0
        public async Task <Result <AddConsentResponse> > Handle(AddConsentCommand request, CancellationToken cancellationToken)
        {
            try
            {
                for (int i = 0; i < request.ConsentType.Count; i++)
                {
                    var consent     = request.ConsentType[i];
                    var consentType = await _unitOfWork.Repository <LookupItemView>().Get(x => x.MasterName == "ConsentType" && x.ItemName == consent.Key).FirstOrDefaultAsync();

                    int consentTypeId = consentType != null ? consentType.ItemId : 0;


                    var consentList = await _unitOfWork.Repository <PatientConsent>().Get(x =>
                                                                                          x.PatientId == request.PatientID && x.PatientMasterVisitId == request.PatientMasterVisitId &&
                                                                                          x.ServiceAreaId == request.ServiceAreaId && x.ConsentType == consentTypeId).ToListAsync();

                    if (consentList.Count > 0)
                    {
                        consentList[0].ConsentValue = consent.Value;
                        _unitOfWork.Repository <PatientConsent>().Update(consentList[0]);
                        await _unitOfWork.SaveAsync();

                        return(Result <AddConsentResponse> .Valid(new AddConsentResponse()
                        {
                            IsConsentAdded = true
                        }));
                    }

                    PatientConsent patientConsent = new PatientConsent()
                    {
                        PatientId            = request.PatientID,
                        PatientMasterVisitId = request.PatientMasterVisitId,
                        ServiceAreaId        = request.ServiceAreaId,
                        ConsentValue         = consent.Value,
                        ConsentType          = consentTypeId,
                        DeclineReason        = request.DeclineReason,
                        ConsentDate          = request.ConsentDate,
                        DeleteFlag           = false,
                        CreatedBy            = request.UserId,
                        CreateDate           = DateTime.Now
                    };

                    await _unitOfWork.Repository <PatientConsent>().AddAsync(patientConsent);

                    await _unitOfWork.SaveAsync();
                }

                return(Result <AddConsentResponse> .Valid(new AddConsentResponse()
                {
                    IsConsentAdded = true
                }));
            }
            catch (Exception e)
            {
                return(Result <AddConsentResponse> .Invalid(e.Message));
            }
        }
Exemple #3
0
 public void DeletePatientConsent(int id)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext()))
     {
         PatientConsent consent = unitOfWork.PatientConsentRepository.GetById(id);
         unitOfWork.PatientConsentRepository.Remove(consent);
         _result = unitOfWork.Complete();
         unitOfWork.Dispose();
     }
 }
Exemple #4
0
 public int AddPatientConsents(PatientConsent p)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext()))
     {
         unitOfWork.PatientConsentRepository.Add(p);
         _result = unitOfWork.Complete();
         unitOfWork.Dispose();
         return(_result);
     }
 }
Exemple #5
0
        public async Task <PatientConsent> UpdatePatientConsent(PatientConsent patientConsent)
        {
            try
            {
                _unitOfWork.Repository <PatientConsent>().Update(patientConsent);
                await _unitOfWork.SaveAsync();

                return(patientConsent);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public int UpdatePatientConsent(PatientConsent p)
        {
            PatientConsent consent = new PatientConsent()
            {
                PatientId            = p.PatientId,
                PatientMasterVisitId = p.PatientMasterVisitId,
                ServiceAreaId        = p.ServiceAreaId,
                ConsentType          = p.ConsentType,
                ConsentDate          = p.ConsentDate,
                DeclineReason        = p.DeclineReason
            };

            return(_consent.UpdatePatientConsent(consent));
        }
Exemple #7
0
 public int UpdatePatientConsent(PatientConsent p)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new GreencardContext()))
     {
         PatientConsent consent = new PatientConsent()
         {
             ConsentType   = p.ConsentType,
             ConsentDate   = p.ConsentDate,
             DeclineReason = p.DeclineReason
         };
         unitOfWork.PatientConsentRepository.Update(consent);
         _result = unitOfWork.Complete();
         unitOfWork.Dispose();
         return(_result);
     }
 }
Exemple #8
0
        private PatientConsentDisplay MapConsent(PatientConsent pc)
        {
            ILookupManager        mgr         = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC");
            string                consentType = "";
            List <LookupItemView> type        = mgr.GetLookItemByGroup("ConsentType");
            var s = type.FirstOrDefault(n => n.ItemId == pc.ConsentType);

            if (s != null)
            {
                consentType = s.ItemDisplayName;
            }

            PatientConsentDisplay patientConsentDisplay = new PatientConsentDisplay()
            {
                ConsentDate = pc.ConsentDate,
                ConsentType = consentType
            };

            return(patientConsentDisplay);
        }
Exemple #9
0
        public string AddPatientConsent(int patientId, int patientMasterVisitId, int consentType, DateTime consentDate)
        {
            // Todo properly save service area. Remove hack
            ILookupManager        mgr         = (ILookupManager)ObjectFactory.CreateInstance("BusinessProcess.CCC.BLookupManager, BusinessProcess.CCC");
            int                   serviceArea = 0;
            List <LookupItemView> areas       = mgr.GetLookItemByGroup("ServiceArea");
            var                   sa          = areas.FirstOrDefault();

            if (sa != null)
            {
                serviceArea = sa.ItemId;
            }

            PatientConsent patientConsent = new PatientConsent()
            {
                PatientId            = patientId,
                PatientMasterVisitId = patientMasterVisitId,
                ServiceAreaId        = serviceArea,
                ConsentType          = consentType,
                ConsentDate          = consentDate
            };

            try
            {
                var consent = new PatientConsentManager();
                Result = consent.AddPatientConsents(patientConsent);
                if (Result > 0)
                {
                    Msg = "Patient consent added successfully!";
                }
            }
            catch (Exception e)
            {
                Msg = e.Message;
            }
            return(Msg);
        }
        public async Task <Result <AddPersonEmergencyContactResponse> > Handle(PersonEmergencyContactCommand request, CancellationToken cancellationToken)
        {
            try
            {
                RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
                PersonContactsService personContactsService = new PersonContactsService(_unitOfWork);

                for (int i = 0; i < request.Emergencycontact.Count; i++)
                {
                    Facility clientFacility = await _unitOfWork.Repository <Facility>().Get(x => x.PosID == request.Emergencycontact[i].PosId.ToString()).FirstOrDefaultAsync();

                    if (clientFacility == null)
                    {
                        clientFacility = await _unitOfWork.Repository <Facility>().Get(x => x.DeleteFlag == 0).FirstOrDefaultAsync();
                    }

                    int emergencyPersonId = 0;
                    if (request.Emergencycontact[i].RegisteredPersonId > 0)
                    {
                        emergencyPersonId = request.Emergencycontact[i].RegisteredPersonId;
                    }
                    else
                    {
                        //add new person
                        var contactPerson = await registerPersonService.RegisterPerson(request.Emergencycontact[i].Firstname, request.Emergencycontact[i].Middlename,
                                                                                       request.Emergencycontact[i].Lastname, request.Emergencycontact[i].Gender, request.Emergencycontact[i].CreatedBy, clientFacility.FacilityID, null, DateTime.Now);

                        emergencyPersonId = contactPerson.Id;
                    }


                    //make the person an emergency contact
                    await personContactsService.Add(request.Emergencycontact[i].PersonId, emergencyPersonId,
                                                    request.Emergencycontact[i].CreatedBy, request.Emergencycontact[i].ContactCategory,
                                                    request.Emergencycontact[i].RelationshipType);

                    //add the person mobile contact
                    await registerPersonService.addPersonContact(emergencyPersonId, "", request.Emergencycontact[i].MobileContact,
                                                                 "", "", request.Emergencycontact[i].CreatedBy);

                    var consentTypeList = await _unitOfWork.Repository <LookupItemView>()
                                          .Get(x => x.MasterName == "ConsentType" && x.ItemName == "ConsentToSendSMS").ToListAsync();

                    int consentType = 0;
                    if (consentTypeList.Count > 0)
                    {
                        consentType = consentTypeList[0].ItemId;
                    }

                    //add person consent to sms
                    PatientConsent patientConsent = new PatientConsent()
                    {
                        PatientMasterVisitId = 0,
                        PatientId            = 0,
                        ServiceAreaId        = 0,
                        ConsentType          = consentType,
                        ConsentValue         = request.Emergencycontact[i].Consent,
                        ConsentDate          = DateTime.Now,
                        DeclineReason        = null,
                        DeleteFlag           = false,
                        CreatedBy            = request.Emergencycontact[i].CreatedBy,
                        CreateDate           = DateTime.Now,
                        PersonId             = emergencyPersonId,
                        Comments             = request.Emergencycontact[i].ConsentDecline
                    };

                    await registerPersonService.AddPatientConsent(patientConsent);
                }

                return(Result <AddPersonEmergencyContactResponse> .Valid(new AddPersonEmergencyContactResponse()
                {
                    Message = "Successfully registered emergency contact",
                    PersonEmergencyContactId = 1
                }));
            }
            catch (Exception e)
            {
                return(Result <AddPersonEmergencyContactResponse> .Invalid(e.Message));
            }
        }