public static MedicalEditsViewModel GetMedicalEditsServiceRequest()
        {
            var medicalEditsRequestParameter = new MedicalEditsViewModel
            {
                ActivityList = new List <MedicalEditsActivityViewModel>
                {
                    new MedicalEditsActivityViewModel
                    {
                        Id              = 1,
                        Quantity        = "6",
                        Duration        = "3",
                        ObservationList = new List <MedicalEditsObservationViewModel>(),
                        ActivityCode    = "2040-106618-1001",
                        ActivityType    = "5",
                        Unit            = "GRANULAR",
                    }
                },

                DiagnosisList = new List <MedicalEditsDiagnosisViewModel>
                {
                    new MedicalEditsDiagnosisViewModel
                    {
                        Code   = "R25.0",
                        TypeId = 1,
                        Type   = "Principal"
                    }
                },
                InsurancePlanId = 875,
                ClaimId         = "DHA-F-0045687-INS111-202002101627117-313"
            };

            return(medicalEditsRequestParameter);
        }
Ejemplo n.º 2
0
        public async Task <ProcessResult <MedicalEditsResult> > GetMedicalEditsAsync(MedicalEditsViewModel requestParameter)
        {
            var processResult = new ProcessResult <MedicalEditsResult>()
            {
                Succeeded  = false,
                StatusCode = HttpStatusCode.BadRequest
            };

            var prepareDataResult = await PrepareCdsParameterAsync(requestParameter).ConfigureAwait(false);

            if (!prepareDataResult.Succeeded)
            {
                processResult.AddRangeModelError(prepareDataResult.GetModelErrors());
                processResult.StatusCode = prepareDataResult.StatusCode;
                processResult.Succeeded  = prepareDataResult.Succeeded;
                return(await Task.FromResult(processResult).ConfigureAwait(false));
            }

            var result = await _medicalEditsService.GetClaimsEditsAsync(requestParameter).ConfigureAwait(false);

            if (result.Success)
            {
                processResult.DataResult = result;
                processResult.Succeeded  = true;
                processResult.StatusCode = HttpStatusCode.OK;

                return(await Task.FromResult(processResult).ConfigureAwait(false));
            }

            return(await Task.FromResult(processResult).ConfigureAwait(false));
        }
        public async Task <IActionResult> CheckMedicalEdits([FromBody] MedicalEditsViewModel requestParameter)
        {
            if (ModelState.IsValid)
            {
                var result = await _authorizationService.GetMedicalEditsAsync(requestParameter);

                return(await GetResponse(result));
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Ejemplo n.º 4
0
        private async Task <ProcessResult> PrepareCdsParameterAsync(MedicalEditsViewModel requestParameter)
        {
            var processResult = new ProcessResult()
            {
                Succeeded  = false,
                StatusCode = HttpStatusCode.BadRequest
            };


            if (requestParameter == null)
            {
                processResult.AddModelError("", "CdsRequest can't be null!");
                return(await Task.FromResult(processResult).ConfigureAwait(false));
            }
            if (requestParameter.ActivityList == null || requestParameter.ActivityList.Count == 0)
            {
                processResult.AddModelError("", "One activity at least is required");
                return(await Task.FromResult(processResult).ConfigureAwait(false));
            }

            if (requestParameter.DiagnosisList == null || requestParameter.DiagnosisList.Count == 0)
            {
                processResult.AddModelError("", "One diagnosis at least is required");
                return(await Task.FromResult(processResult).ConfigureAwait(false));
            }

            if (requestParameter.InsurancePlanId.HasValue)
            {
                var insurancePlan = _cacheService.CachedLists.Plans.FirstOrDefault(c => c.Id == requestParameter.InsurancePlanId);
                if (insurancePlan != null)
                {
                    requestParameter.PayerId = _cacheService.CachedLists.Payers.FirstOrDefault(c => c.Id == insurancePlan.PayerId).Code ?? null;
                }
            }

            requestParameter.ProviderId = _httpContextAccessor.HttpContext.User.GetCurrentFacilityCode();

            processResult.Succeeded  = true;
            processResult.StatusCode = HttpStatusCode.OK;

            return(await Task.FromResult(processResult).ConfigureAwait(false));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Used to get Medical Edits
        /// </summary>
        /// <param name="medicalEditsRequest"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <MedicalEditsResult> GetClaimsEditsAsync(MedicalEditsViewModel medicalEditsRequest,
                                                                   CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = new MedicalEditsResult();

            try
            {
                //check if medicalEditsService is enabled
                if (!medicalEditsSetting.IsEnabled)
                {
                    result.Success = false;
                    result.Message = "Medical Edits service not enabled!";
                    return(result);
                }

                //set cancellation time for medicalEdits Service
                // if cancellationToken parameter equals default CancellationToken, then set the cancel time from medialEditsSettings
                if (cancellationToken == default(CancellationToken))
                {
                    var cts = new CancellationTokenSource();
                    cts.CancelAfter(medicalEditsSetting.CancelTime.GetValueOrDefault());
                    cancellationToken = cts.Token;
                }

                //mapping medicalEditsViewModel to medicalEditsRequest
                var medicalEditsRequestData = ToMedicalEditsRequestModel(medicalEditsRequest);
                if (medicalEditsRequestData == null)
                {
                    result.Success = false;
                    result.Message = "An error occurred while mapping data to MedicalEdits Request";
                    return(result);
                }

                // call GetClaimEdits api and check the returned result
                var medicalEditsResult = await _medicalEditsClient.GetClaimsEditsAsync(medicalEditsRequestData, cancellationToken);

                if (medicalEditsResult != null)
                {
                    result.ResponseId = medicalEditsResult.ResponseId;
                    result.Message    = medicalEditsResult.Message;
                    result.Success    = medicalEditsResult.Success;

                    // mapping claimEdits to  MedicalEditsResponse object
                    if (medicalEditsResult.Success && medicalEditsResult.ClaimEdits != null)
                    {
                        var medicalEditsClaimActivityList =
                            medicalEditsRequestData.claims.FirstOrDefault().claimSubmissionActivityList;

                        var ClaimEdits = medicalEditsResult.ClaimEdits.Select(x => new MedicalEditsResponse
                        {
                            EditCode     = x.EditCode,
                            EditComment  = x.EditComment,
                            EditType     = x.EditType.Description,
                            ActivityId   = x.ActivityId,
                            ActivityCode = x.GetActivityCodeValue(), // get ActivityCode value
                            ActivityType = _cacheService.CachedLists?.ActivityTypes?.Find(a =>
                                                                                          a.Code == medicalEditsClaimActivityList
                                                                                          .FirstOrDefault(act => act.activityCode == x.GetActivityCodeValue())
                                                                                          ?.activityType)?.Name,
                            EditSource = x.EditSource,
                            // Set IsBlockingEdit = true ,when Drug or Generic quantity has exceeded the maximum limit that can be given for this age
                            IsBlockingEdit        = x.EditCode == "DRU_DOS_01",
                            EditCommentParameters = ExtractEditCommentParameters(x)
                        }).ToList();

                        // edits returned to current cliam data
                        result.CurrentEdits = ClaimEdits.Where(c => c.EditSource == "CURRENT").ToList();

                        //edits returned claim history data
                        result.HistoryEdits = ClaimEdits.Where(c => c.EditSource == "HISTORY").ToList();
                    }
                }
            }
            catch (MedicalEditsAPIException e)
            {
                result.Message = e.MedicalEditsExceptionMessage;
                result.Success = false;
            }
            catch (OperationCanceledException e)
            {
                result.Message = e.Message;
                result.Success = false;
            }
            catch (Exception e)
            {
                //log the exception
                result.Message = "MedicalEdits request failed.";
                result.Success = false;
            }

            return(result);
        }
Ejemplo n.º 6
0
        private MedicalEditsRequestModel ToMedicalEditsRequestModel(MedicalEditsViewModel request)
        {
            try
            {
                //set medical Service setting data
                var medicalEditsRequest = new MedicalEditsRequestModel
                {
                    password      = medicalEditsSetting.Password,
                    username      = medicalEditsSetting.UserName,
                    services      = string.Join(',', medicalEditsSetting.Services),
                    isStrictCheck = medicalEditsSetting.IsStrictCheck
                };

                // prepare claim data
                var claim = new Claim
                {
                    claimID    = request.ClaimId,
                    providerId = request.ProviderId,
                    payerId    = request.PayerId
                };

                // set claim activities
                claim.claimSubmissionActivityList = request.ActivityList?.Select(activity => new ClaimSubmissionActivity
                {
                    activityCode      = activity.ActivityCode,
                    activityId        = activity.Id.ToString(),
                    activitySource    = activity.ActivitySource,
                    activityStart     = activity.StartDate.ToLocalTime().ToString("dd/MM/yyyy"),
                    activityType      = activity.ActivityType,
                    clinician         = activity.Clinician,
                    orderingClinician = activity.OrderingClinician,
                    duration          = activity.Duration,
                    quantity          = activity.Quantity,
                    unit = activity.Unit,
                    claimSubmissionObservationList = activity.ObservationList != null
                            ? activity.ObservationList.Select(obs => new ClaimSubmissionObservation
                    {
                        observationCode      = obs.Code,
                        observationValue     = obs.Value,
                        observationValueType = obs.ValueType,
                        observationType      = obs.Type,
                    }).ToList()
                            : null
                }).ToList();

                // add ActiveDrugs as history for the patient
                if (request.ActiveDrugs?.Count > 0)
                {
                    var i = 1;
                    claim.claimSubmissionActivityList.AddRange(request.ActiveDrugs.Select(activity => new ClaimSubmissionActivity
                    {
                        activityCode      = activity.ActivityCode,
                        activityId        = $"ActiveDrug-{i++}",
                        activitySource    = "HISTORY",
                        activityStart     = activity.StartDate.ToLocalTime().ToString("dd/MM/yyyy"),
                        activityType      = activity.ActivityType,
                        clinician         = activity.Clinician,
                        orderingClinician = activity.OrderingClinician,
                        duration          = activity.Duration,
                        quantity          = activity.Quantity,
                        unit = activity.Unit,
                        claimSubmissionObservationList = activity.ObservationList != null
                                ? activity.ObservationList.Select(obs => new ClaimSubmissionObservation
                        {
                            observationCode      = obs.Code,
                            observationValue     = obs.Value,
                            observationValueType = obs.ValueType,
                            observationType      = obs.Type,
                        }).ToList()
                                : null
                    }));
                }

                // set claim diagnosis
                claim.claimSubmissionDiagnosisList = request.DiagnosisList != null
                    ? request.DiagnosisList.Select(x => new ClaimSubmissionDiagnosis()
                {
                    diagnosisCode   = x.Code,
                    diagnosisSource = x.Source,
                    diagnosisType   = x.Type
                }).ToList()
                    : null;

                // add ChronicDiseases as dignosis history for the patient
                if (request.ChronicDiseases?.Count > 0)
                {
                    var filteredChronicDiseases = request.ChronicDiseases.Where(a => !
                                                                                claim.claimSubmissionDiagnosisList.Select(c => c.diagnosisCode).Contains(a.Code))?.Select(c => new ClaimSubmissionDiagnosis
                    {
                        diagnosisCode   = c.Code,
                        diagnosisType   = "Secondary",       // set the type of dignosis as Secondary for ChronicDiseases
                        diagnosisSource = "HISTORY",
                    })
                                                  .ToList();

                    if (filteredChronicDiseases?.Count > 0)
                    {
                        claim.claimSubmissionDiagnosisList.AddRange(filteredChronicDiseases);
                    }
                }

                // set ClaimSubmissionPerson
                var patient = _repository.Find <Patient>(
                    p => p.Id == request.PatientId && !p.IsDeleted && p.DateOfBirth > DateTimeOffset.MinValue);

                if (patient != null)
                {
                    claim.claimSubmissionPerson = new ClaimSubmissionPerson
                    {
                        dateOfBirth = patient.DateOfBirth.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture),
                        nationalId  = patient.NationalId,
                        patientId   = patient.Code,
                        weight      = request.Weight,
                        height      = request.height
                    };
                }

                // set ClaimSubmissionAllergy
                if (request.AllergiesList != null && request.AllergiesList.Count != 0)
                {
                    claim.claimSubmissionAllergyList = request.AllergiesList.Select(p => new ClaimSubmissionAllergy()
                    {
                        allergyCode = p.Code,
                        allergyId   = p.Code
                    }).ToList();
                }

                medicalEditsRequest.claims = new List <Claim>();
                medicalEditsRequest.claims.Add(claim);

                return(medicalEditsRequest);
            }
            catch
            {
                return(null);
            }
        }
 public MedicalEditsServiceTest()
 {
     medicalEditsServiceRequest = MedicalEditsDataProvider.GetMedicalEditsServiceRequest();
 }