Search in sources :

Example 6 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project ab2d by CMSgov.

the class CoverageMappingCallableTest method testNullMbi.

@Test
void testNullMbi() {
    ContractDTO contract = new ContractDTO("TESTING", "TESTING", null, null);
    CoveragePeriod period = new CoveragePeriod();
    period.setContractNumber(contract.getContractNumber());
    period.setYear(2020);
    period.setMonth(1);
    CoverageSearchEvent cse = new CoverageSearchEvent();
    cse.setCoveragePeriod(period);
    CoverageSearch search = new CoverageSearch();
    search.setPeriod(period);
    CoverageMapping mapping = new CoverageMapping(cse, search);
    CoverageMappingCallable callable = new CoverageMappingCallable(STU3, mapping, bfdClient, mapping.getPeriod().getYear());
    Patient patient = new Patient();
    Identifiers ids = callable.extractPatientId(patient);
    assertNull(ids);
    Identifier beneId = new Identifier();
    beneId.setSystem(BENEFICIARY_ID);
    beneId.setValue("1");
    patient.getIdentifier().add(beneId);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertNull(ids.getCurrentMbi());
    assertEquals(0, ids.getHistoricMbis().size());
    Identifier mbiHist = new Identifier();
    mbiHist.setSystem(MBI_ID);
    mbiHist.setValue("HIST_MBI");
    Extension extension = new Extension();
    extension.setUrl(CURRENCY_IDENTIFIER);
    Coding code1 = new Coding();
    code1.setCode("historic");
    extension.setValue(code1);
    mbiHist.getExtension().add(extension);
    patient.getIdentifier().add(mbiHist);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertNull(ids.getCurrentMbi());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("HIST_MBI", ids.getHistoricMbis().stream().findAny().get());
    Identifier mbiCurrent = new Identifier();
    mbiCurrent.setSystem(MBI_ID);
    mbiCurrent.setValue("CURR_MBI");
    Extension extension2 = new Extension();
    extension2.setUrl(CURRENCY_IDENTIFIER);
    Coding code2 = new Coding();
    code2.setCode("current");
    extension2.setValue(code2);
    mbiCurrent.getExtension().add(extension2);
    patient.getIdentifier().add(mbiCurrent);
    ids = callable.extractPatientId(patient);
    assertEquals(1L, ids.getBeneficiaryId());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("CURR_MBI", ids.getCurrentMbi());
    assertEquals(1, ids.getHistoricMbis().size());
    assertEquals("HIST_MBI", ids.getHistoricMbis().stream().findAny().get());
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Identifier(org.hl7.fhir.dstu3.model.Identifier) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) Coding(org.hl7.fhir.dstu3.model.Coding) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) CoveragePeriod(gov.cms.ab2d.coverage.model.CoveragePeriod) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) Patient(org.hl7.fhir.dstu3.model.Patient) BundleUtils.createPatient(gov.cms.ab2d.worker.processor.BundleUtils.createPatient) CoverageSearchEvent(gov.cms.ab2d.coverage.model.CoverageSearchEvent) Identifiers(gov.cms.ab2d.coverage.model.Identifiers) Test(org.junit.jupiter.api.Test)

Example 7 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project ab2d by CMSgov.

the class JobProcessorIntegrationTest method setUp.

@BeforeEach
void setUp() {
    MockitoAnnotations.openMocks(this);
    LogManager logManager = new LogManager(sqlEventLogger, kinesisEventLogger, slackLogger);
    PdpClient pdpClient = createClient();
    contract = createContract();
    contractForCoverageDTO = mapping.map(contract);
    fail = new RuntimeException("TEST EXCEPTION");
    job = createJob(pdpClient);
    job.setContractNumber(contract.getContractNumber());
    job.setStatus(JobStatus.IN_PROGRESS);
    jobRepository.saveAndFlush(job);
    when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong())).thenAnswer((args) -> {
        ExplanationOfBenefit copy = EOB.copy();
        copy.getPatient().setReference("Patient/" + args.getArgument(1));
        return EobTestDataUtil.createBundle(copy);
    });
    when(mockBfdClient.requestEOBFromServer(eq(STU3), anyLong(), any())).thenAnswer((args) -> {
        ExplanationOfBenefit copy = EOB.copy();
        copy.getPatient().setReference("Patient/" + args.getArgument(1));
        return EobTestDataUtil.createBundle(copy);
    });
    when(mockCoverageDriver.numberOfBeneficiariesToProcess(any(Job.class), any(ContractDTO.class))).thenReturn(100);
    when(mockCoverageDriver.pageCoverage(any(CoveragePagingRequest.class))).thenReturn(new CoveragePagingResult(loadFauxMetadata(contractForCoverageDTO, 99), null));
    SearchConfig searchConfig = new SearchConfig(tmpEfsMountDir.getAbsolutePath(), STREAMING_DIR, FINISHED_DIR, 0, 0, MULTIPLIER, NUMBER_PATIENT_REQUESTS_PER_THREAD);
    PatientClaimsProcessor patientClaimsProcessor = new PatientClaimsProcessorImpl(mockBfdClient, logManager, searchConfig);
    ReflectionTestUtils.setField(patientClaimsProcessor, "earliestDataDate", "01/01/1900");
    ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
    pool.initialize();
    ContractProcessor contractProcessor = new ContractProcessorImpl(contractWorkerClient, jobRepository, mockCoverageDriver, patientClaimsProcessor, logManager, eobClaimRequestsQueue, jobChannelService, jobProgressService, mapping, pool, searchConfig);
    cut = new JobProcessorImpl(fileService, jobChannelService, jobProgressService, jobProgressUpdateService, jobRepository, jobOutputRepository, contractProcessor, logManager);
    ReflectionTestUtils.setField(cut, "efsMount", tmpEfsMountDir.toString());
    ReflectionTestUtils.setField(cut, "failureThreshold", 10);
}
Also used : SearchConfig(gov.cms.ab2d.worker.config.SearchConfig) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) PdpClient(gov.cms.ab2d.common.model.PdpClient) CoveragePagingRequest(gov.cms.ab2d.coverage.model.CoveragePagingRequest) CoveragePagingResult(gov.cms.ab2d.coverage.model.CoveragePagingResult) ContractDTO(gov.cms.ab2d.common.dto.ContractDTO) ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) Job(gov.cms.ab2d.common.model.Job) LogManager(gov.cms.ab2d.eventlogger.LogManager) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project ab2d by CMSgov.

the class EndToEndBfdTests method disableContractWeDontNeed.

/**
 * For all but the contract we want to use, disable them
 */
private void disableContractWeDontNeed() {
    List<PdpClient> clients = pdpClientRepository.findAllByEnabledTrue().stream().filter(client -> client.getContract().getAttestedOn() != null).collect(toList());
    for (PdpClient pdp : clients) {
        if (!pdp.getContract().getContractNumber().equals(CONTRACT_TO_USE)) {
            pdp.setEnabled(false);
            pdpClientRepository.save(pdp);
        }
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JobPreProcessor(gov.cms.ab2d.worker.processor.JobPreProcessor) Autowired(org.springframework.beans.factory.annotation.Autowired) STU3(gov.cms.ab2d.fhir.FhirVersion.STU3) JobProgressService(gov.cms.ab2d.worker.processor.JobProgressService) Constants(gov.cms.ab2d.common.util.Constants) R4(gov.cms.ab2d.fhir.FhirVersion.R4) ContractRepository(gov.cms.ab2d.common.repository.ContractRepository) PdpClientRepository(gov.cms.ab2d.common.repository.PdpClientRepository) JobProcessor(gov.cms.ab2d.worker.processor.JobProcessor) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) LoggerEventSummary(gov.cms.ab2d.eventlogger.reports.sql.LoggerEventSummary) PropertiesDTO(gov.cms.ab2d.common.dto.PropertiesDTO) EOB(gov.cms.ab2d.fhir.BundleUtils.EOB) JobOutput(gov.cms.ab2d.common.model.JobOutput) Path(java.nio.file.Path) MethodSource(org.junit.jupiter.params.provider.MethodSource) Resource(org.springframework.core.io.Resource) CoverageProcessorImpl(gov.cms.ab2d.worker.processor.coverage.CoverageProcessorImpl) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) JobChannelService(gov.cms.ab2d.worker.service.JobChannelService) CoverageDriver(gov.cms.ab2d.worker.processor.coverage.CoverageDriver) Contract(gov.cms.ab2d.common.model.Contract) CoverageSearchRepository(gov.cms.ab2d.coverage.repository.CoverageSearchRepository) BlockingQueue(java.util.concurrent.BlockingQueue) ContractProcessor(gov.cms.ab2d.worker.processor.ContractProcessor) UUID(java.util.UUID) IdentifierUtils(gov.cms.ab2d.fhir.IdentifierUtils) Arguments(org.junit.jupiter.params.provider.Arguments) FhirVersion(gov.cms.ab2d.fhir.FhirVersion) Collectors(java.util.stream.Collectors) CoverageService(gov.cms.ab2d.coverage.service.CoverageService) Test(org.junit.jupiter.api.Test) JobOutputService(gov.cms.ab2d.common.service.JobOutputService) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) IDomainResource(org.hl7.fhir.instance.model.api.IDomainResource) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) PatientIdentifier(gov.cms.ab2d.fhir.PatientIdentifier) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TempDir(org.junit.jupiter.api.io.TempDir) JobPreProcessorImpl(gov.cms.ab2d.worker.processor.JobPreProcessorImpl) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PropertiesService(gov.cms.ab2d.common.service.PropertiesService) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) PdpClientService(gov.cms.ab2d.common.service.PdpClientService) Optional(java.util.Optional) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) BFDClient(gov.cms.ab2d.bfd.client.BFDClient) CoverageDriverImpl(gov.cms.ab2d.worker.processor.coverage.CoverageDriverImpl) FileServiceImpl(gov.cms.ab2d.worker.service.FileServiceImpl) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) PdpClient(gov.cms.ab2d.common.model.PdpClient) UrlResource(org.springframework.core.io.UrlResource) Mock(org.mockito.Mock) AB2DPostgresqlContainer(gov.cms.ab2d.common.util.AB2DPostgresqlContainer) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) PostgreSQLContainer(org.testcontainers.containers.PostgreSQLContainer) JobRepository(gov.cms.ab2d.common.repository.JobRepository) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) InvalidContractException(gov.cms.ab2d.common.service.InvalidContractException) ArrayList(java.util.ArrayList) CoverageLockWrapper(gov.cms.ab2d.worker.processor.coverage.CoverageLockWrapper) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) SinceSource(gov.cms.ab2d.common.model.SinceSource) Container(org.testcontainers.junit.jupiter.Container) JobService(gov.cms.ab2d.common.service.JobService) JobProgressUpdateService(gov.cms.ab2d.worker.processor.JobProgressUpdateService) ContractWorkerClient(gov.cms.ab2d.worker.service.ContractWorkerClient) LogManager(gov.cms.ab2d.eventlogger.LogManager) JobProcessorImpl(gov.cms.ab2d.worker.processor.JobProcessorImpl) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) Job(gov.cms.ab2d.common.model.Job) BundleUtils(gov.cms.ab2d.fhir.BundleUtils) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) CoverageProcessor(gov.cms.ab2d.worker.processor.coverage.CoverageProcessor) File(java.io.File) JobStatus(gov.cms.ab2d.common.model.JobStatus) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Collectors.toList(java.util.stream.Collectors.toList) JobOutputRepository(gov.cms.ab2d.common.repository.JobOutputRepository) Paths(java.nio.file.Paths) Assertions(org.junit.jupiter.api.Assertions) JobServiceImpl(gov.cms.ab2d.common.service.JobServiceImpl) PdpClient(gov.cms.ab2d.common.model.PdpClient)

Example 9 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeContractValuedItemComponent.

protected void composeContractValuedItemComponent(Complex parent, String parentType, String name, Contract.ValuedItemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "valuedItem", name, element, index);
    if (element.hasEntity())
        composeType(t, "Contract", "entity", element.getEntity(), -1);
    if (element.hasIdentifier())
        composeIdentifier(t, "Contract", "identifier", element.getIdentifier(), -1);
    if (element.hasEffectiveTimeElement())
        composeDateTime(t, "Contract", "effectiveTime", element.getEffectiveTimeElement(), -1);
    if (element.hasQuantity())
        composeQuantity(t, "Contract", "quantity", element.getQuantity(), -1);
    if (element.hasUnitPrice())
        composeQuantity(t, "Contract", "unitPrice", element.getUnitPrice(), -1);
    if (element.hasFactorElement())
        composeDecimal(t, "Contract", "factor", element.getFactorElement(), -1);
    if (element.hasPointsElement())
        composeDecimal(t, "Contract", "points", element.getPointsElement(), -1);
    if (element.hasNet())
        composeQuantity(t, "Contract", "net", element.getNet(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 10 with Contract

use of org.hl7.fhir.dstu3.model.Contract in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCoverage.

protected void composeCoverage(Complex parent, String parentType, String name, Coverage element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Coverage", name, element, index);
    if (element.hasIssuer())
        composeType(t, "Coverage", "issuer", element.getIssuer(), -1);
    if (element.hasBinElement())
        composeString(t, "Coverage", "bin", element.getBinElement(), -1);
    if (element.hasPeriod())
        composePeriod(t, "Coverage", "period", element.getPeriod(), -1);
    if (element.hasType())
        composeCoding(t, "Coverage", "type", element.getType(), -1);
    if (element.hasPlanholder())
        composeType(t, "Coverage", "planholder", element.getPlanholder(), -1);
    if (element.hasBeneficiary())
        composeType(t, "Coverage", "beneficiary", element.getBeneficiary(), -1);
    if (element.hasRelationship())
        composeCoding(t, "Coverage", "relationship", element.getRelationship(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Coverage", "identifier", element.getIdentifier().get(i), i);
    if (element.hasGroupElement())
        composeString(t, "Coverage", "group", element.getGroupElement(), -1);
    if (element.hasPlanElement())
        composeString(t, "Coverage", "plan", element.getPlanElement(), -1);
    if (element.hasSubPlanElement())
        composeString(t, "Coverage", "subPlan", element.getSubPlanElement(), -1);
    if (element.hasDependentElement())
        composePositiveInt(t, "Coverage", "dependent", element.getDependentElement(), -1);
    if (element.hasSequenceElement())
        composePositiveInt(t, "Coverage", "sequence", element.getSequenceElement(), -1);
    for (int i = 0; i < element.getException().size(); i++) composeCoding(t, "Coverage", "exception", element.getException().get(i), i);
    if (element.hasSchoolElement())
        composeString(t, "Coverage", "school", element.getSchoolElement(), -1);
    if (element.hasNetworkElement())
        composeString(t, "Coverage", "network", element.getNetworkElement(), -1);
    for (int i = 0; i < element.getContract().size(); i++) composeReference(t, "Coverage", "contract", element.getContract().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Aggregations

Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)17 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)12 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)12 Timer (com.codahale.metrics.Timer)6 Test (org.junit.jupiter.api.Test)6 ContractDTO (gov.cms.ab2d.common.dto.ContractDTO)4 CoverageMapping (gov.cms.ab2d.coverage.model.CoverageMapping)4 CoverageSearch (gov.cms.ab2d.coverage.model.CoverageSearch)4 ContractToContractCoverageMapping (gov.cms.ab2d.worker.config.ContractToContractCoverageMapping)4 ArrayList (java.util.ArrayList)4 CoveragePeriod (gov.cms.ab2d.coverage.model.CoveragePeriod)3 CoverageSearchEvent (gov.cms.ab2d.coverage.model.CoverageSearchEvent)3 Coverage (org.hl7.fhir.dstu3.model.Coverage)3 Job (gov.cms.ab2d.common.model.Job)2 PdpClient (gov.cms.ab2d.common.model.PdpClient)2 Identifiers (gov.cms.ab2d.coverage.model.Identifiers)2 LogManager (gov.cms.ab2d.eventlogger.LogManager)2 BundleUtils.createPatient (gov.cms.ab2d.worker.processor.BundleUtils.createPatient)2 CcwCodebookVariable (gov.cms.bfd.model.codebook.data.CcwCodebookVariable)2 HashMap (java.util.HashMap)2