public async Task <Result <EnrollClientResponse> > Handle(EnrollClientCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var transferIn = false;
                if (request.ClientEnrollment.transferIn)
                {
                    transferIn = true;
                }

                RegisterPersonService registerPersonService = new RegisterPersonService(_unitOfWork);
                await registerPersonService.DynamicEnrollment(request.ClientEnrollment.PatientId,
                                                              request.ClientEnrollment.ServiceAreaId, request.ClientEnrollment.CreatedBy,
                                                              request.ClientEnrollment.DateOfEnrollment, request.ClientEnrollment.ServiceIdentifiersList, transferIn);

                /*var patientIdentifier = await registerPersonService.EnrollPatient(request.ClientEnrollment.EnrollmentNo,
                 *  request.ClientEnrollment.PatientId, request.ClientEnrollment.ServiceAreaId,
                 *  request.ClientEnrollment.CreatedBy, request.ClientEnrollment.DateOfEnrollment);*/

                string cccNumber = String.Empty;
                int    moduleId  = 283;
                foreach (var item in request.ClientEnrollment.ServiceIdentifiersList)
                {
                    if (item.IdentifierId == 1)
                    {
                        cccNumber = item.IdentifierValue;
                        moduleId  = 203;
                    }
                }

                GetPatientDetails patientDetails = new GetPatientDetails(_unitOfWork);


                var patientLookup = await patientDetails.GetPatientByPatientId(request.ClientEnrollment.PatientId);

                if (patientLookup.Count > 0 && (patientLookup[0].ptn_pk == 0 || patientLookup[0].ptn_pk == null))
                {
                    var dobPrecision = "EXACT";
                    var dob          = DateTime.Now;
                    if (patientLookup[0].DobPrecision.HasValue)
                    {
                        dobPrecision = patientLookup[0].DobPrecision.Value ? "ESTIMATED" : "EXACT";
                    }

                    if (patientLookup[0].DateOfBirth.HasValue)
                    {
                        dob = patientLookup[0].DateOfBirth.Value;
                    }


                    var response = await registerPersonService.InsertIntoBlueCard(
                        patientLookup[0].FirstName,
                        patientLookup[0].LastName,
                        patientLookup[0].MidName,
                        request.ClientEnrollment.DateOfEnrollment,
                        cccNumber,
                        moduleId,
                        patientLookup[0].MaritalStatusName,
                        patientLookup[0].PhysicalAddress,
                        patientLookup[0].MobileNumber,
                        patientLookup[0].Gender,
                        dobPrecision,
                        dob,
                        request.ClientEnrollment.CreatedBy,
                        request.ClientEnrollment.PosId
                        );

                    if (response.Count > 0)
                    {
                        await registerPersonService.UpdatePatient(request.ClientEnrollment.PatientId,
                                                                  request.ClientEnrollment.DateOfEnrollment, request.ClientEnrollment.PosId);
                    }
                }
                else
                {
                    if (moduleId == 203)
                    {
                        await registerPersonService.UpdateBlueCard(patientLookup[0].ptn_pk, cccNumber, moduleId);
                    }
                }


                return(Result <EnrollClientResponse> .Valid(new EnrollClientResponse()
                {
                    Message = "Success"
                }));
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return(Result <EnrollClientResponse> .Invalid(e.Message));
            }
        }