Search in sources :

Example 91 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method checkCoverageClassExistsWithCorrectValueAndName.

// Checks that a Coverage.Class with the right Value and Name and Type exist in the list
private void checkCoverageClassExistsWithCorrectValueAndName(List<ClassComponent> classes_, String value, String name) {
    for (ClassComponent c : classes_) {
        // Find our class in the list
        if (c.getValue().equals(value)) {
            // Value is required
            assertThat(c.getValue()).isEqualTo(value);
            if (name != null) {
                assertThat(c.getName()).isEqualTo(name);
            } else {
                assertThat(c.getName()).isNull();
            }
            DatatypeUtils.checkCommonCodeableConceptVersionedAssertions(c.getType(), "group", "Group", "http://terminology.hl7.org/CodeSystem/coverage-class", null, null);
            return;
        }
    }
    // if our class is not in the list, fail the check
    fail("No Coverage.Class with value: " + value);
}
Also used : ClassComponent(org.hl7.fhir.r4.model.Coverage.ClassComponent)

Example 92 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageFromIN2Self.

@Test
// Tests IN2.72 as backup IN1.17 coverage. Case of self. Code '01' is self. No related person should be created.
void testInsuranceCoverageFromIN2Self() throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||DFT^P03^DFT_P03|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (Tested in testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "||||||||||||||||||||" + // IN1.37 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||||||||||||\n" + // IN2.1 through IN2.71 NOT REFERENCED
    "IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // Code 01 (self) should create relationship of ONESELF, and reference to patient
    "01|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(1);
    Organization org = (Organization) organizations.get(0);
    // Check organization Id's
    assertThat(org.getIdentifier()).hasSize(1);
    // Organization identifiers checked deeply in other tests
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    // XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(4);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Confirm Coverage Subscriber references to Patient
    assertThat(coverage.getSubscriber().getReference()).isEqualTo(patientId);
    // Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
    // Expect no RelatedPerson because IN2.72 was 01 (self)
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN2.72 was 01 (self)
    assertThat(relatedPersons).isEmpty();
    // Check coverage.relationship (from SubscriberRelationship mapping)
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "self", "Self", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN2.72
    null);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter
    assertThat(e).hasSize(4);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 93 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project elexis-server by elexis.

the class CoverageTest method getOrganizationProperties.

/**
 * Test all properties set by
 * {@link TestDatabaseInitializer#initializeFall()}.
 *
 * @throws FHIRException
 */
@Test
public void getOrganizationProperties() throws FHIRException {
    Coverage readCoverage = client.read().resource(Coverage.class).withId(TestDatabaseInitializer.getFall().getId()).execute();
    assertNotNull(readCoverage);
    Reference beneficiary = readCoverage.getBeneficiary();
    assertNotNull(beneficiary);
    assertEquals("Patient/" + AllTests.getTestDatabaseInitializer().getPatient().getId(), beneficiary.getReference());
    List<Reference> payors = readCoverage.getPayor();
    assertNotNull(payors);
    assertFalse(payors.isEmpty());
    assertEquals("Organization/" + TestDatabaseInitializer.getOrganization().getId(), payors.get(0).getReference());
    Period period = readCoverage.getPeriod();
    assertNotNull(period);
    assertEquals(LocalDate.of(2016, Month.SEPTEMBER, 1), AllTests.getLocalDateTime(period.getStart()).toLocalDate());
    assertTrue(period.getEnd() == null);
    assertEquals("1234-5678", readCoverage.getDependent());
    Narrative narrative = readCoverage.getText();
    assertNotNull(narrative);
    String text = narrative.getDivAsString();
    assertNotNull(text);
    assertTrue(text.contains("Test Fall(01.09.2016-offen)"));
}
Also used : Narrative(org.hl7.fhir.r4.model.Narrative) Reference(org.hl7.fhir.r4.model.Reference) Period(org.hl7.fhir.r4.model.Period) Coverage(org.hl7.fhir.r4.model.Coverage) ICoverage(ch.elexis.core.model.ICoverage) Test(org.junit.Test)

Example 94 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project elexis-server by elexis.

the class CoverageTest method createCoverage.

@Test
public void createCoverage() {
    Coverage coverage = new Coverage();
    // minimal coverage information
    coverage.setBeneficiary(new Reference(new IdDt("Patient", AllTests.getTestDatabaseInitializer().getPatient().getId())));
    coverage.setType(new CodeableConcept().addCoding(new Coding(CodingSystem.ELEXIS_COVERAGE_TYPE.getSystem(), "KVG", "")));
    MethodOutcome outcome = client.create().resource(coverage).execute();
    assertNotNull(outcome);
    assertTrue(outcome.getCreated());
    assertNotNull(outcome.getId());
    Coverage readCoverage = client.read().resource(Coverage.class).withId(outcome.getId()).execute();
    assertNotNull(readCoverage);
    assertEquals(outcome.getId().getIdPart(), readCoverage.getIdElement().getIdPart());
    assertNotNull(readCoverage.getPeriod().getStart());
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) IdDt(ca.uhn.fhir.model.primitive.IdDt) Coverage(org.hl7.fhir.r4.model.Coverage) ICoverage(ch.elexis.core.model.ICoverage) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 95 with Coverage

use of org.hl7.fhir.r4.model.Coverage in project elexis-server by elexis.

the class ClaimTest method createClaim.

@Test
public void createClaim() {
    // claim needs a coverage, a diagnose, a practitioner, an encounter and
    // items
    Coverage coverage = new Coverage();
    // minimal coverage information
    coverage.setBeneficiary(new Reference(new IdDt("Patient", AllTests.getTestDatabaseInitializer().getPatient().getId())));
    coverage.setType(new CodeableConcept().addCoding(new Coding(CodingSystem.ELEXIS_COVERAGE_TYPE.getSystem(), "KVG", "Test")));
    MethodOutcome coverageOutcome = client.create().resource(coverage).execute();
    assertTrue(coverageOutcome.getCreated());
    Bundle results = client.search().forResource(Encounter.class).where(Encounter.IDENTIFIER.exactly().systemAndIdentifier("www.elexis.info/consultationid", TestDatabaseInitializer.getBehandlung().getId())).returnBundle(Bundle.class).execute();
    List<BundleEntryComponent> entries = results.getEntry();
    assertFalse(entries.isEmpty());
    Encounter encounter = (Encounter) entries.get(0).getResource();
    Claim claim = new Claim();
    claim.addInsurance().setCoverage(new Reference("Coverage/" + coverageOutcome.getId()));
    claim.setProvider(new Reference("Practitioner/" + TestDatabaseInitializer.getMandant().getId()));
    claim.addDiagnosis().setDiagnosis(new CodeableConcept().addCoding(new Coding(CodingSystem.ELEXIS_DIAGNOSE_TESSINERCODE.getSystem(), "A1", "")));
    claim.addSupportingInfo().setValue(new StringType("Encounter/" + encounter.getId()));
    ItemComponent item = claim.addItem();
    item.setQuantity(new SimpleQuantity().setValue(1));
    item.setProductOrService(new CodeableConcept().addCoding(new Coding("www.elexis.info/billing/tarmed", "00.0010", "")));
    List<IBilled> before = AllTests.getModelService().getQuery(IBilled.class).execute();
    MethodOutcome outcome = client.create().resource(claim).execute();
    assertNotNull(outcome);
    assertTrue(outcome.getCreated());
    List<IBilled> after = AllTests.getModelService().getQuery(IBilled.class).execute();
    assertTrue(after.size() - before.size() == 1);
    // "00.0010" can only be billed once ...
    boolean failed = false;
    try {
        outcome = client.create().resource(claim).execute();
    } catch (InternalErrorException e) {
        failed = true;
    }
    assertTrue(failed);
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) Bundle(org.hl7.fhir.r4.model.Bundle) SimpleQuantity(org.hl7.fhir.r4.model.SimpleQuantity) IdDt(ca.uhn.fhir.model.primitive.IdDt) Coverage(org.hl7.fhir.r4.model.Coverage) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) IBilled(ch.elexis.core.model.IBilled) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) ItemComponent(org.hl7.fhir.r4.model.Claim.ItemComponent) Encounter(org.hl7.fhir.r4.model.Encounter) Claim(org.hl7.fhir.r4.model.Claim) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Aggregations

Test (org.junit.jupiter.api.Test)34 Coverage (org.hl7.fhir.r4.model.Coverage)31 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)17 Beneficiary (gov.cms.bfd.model.rif.Beneficiary)16 MedicareSegment (gov.cms.bfd.server.war.commons.MedicareSegment)15 Coverage (org.hl7.fhir.dstu3.model.Coverage)15 List (java.util.List)14 Reference (org.hl7.fhir.r4.model.Reference)14 Resource (org.hl7.fhir.r4.model.Resource)14 TransformerConstants (gov.cms.bfd.server.war.commons.TransformerConstants)13 Arrays (java.util.Arrays)13 Instant (java.time.Instant)12 Bundle (org.hl7.fhir.r4.model.Bundle)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Date (java.util.Date)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)11 Constants (ca.uhn.fhir.rest.api.Constants)10 Timer (com.codahale.metrics.Timer)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)10