Search in sources :

Example 1 with COMPLETED

use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProvider method findByPatient.

/**
 * Adds support for the FHIR "search" operation for {@link ExplanationOfBenefit}s, allowing users
 * to search by {@link ExplanationOfBenefit#getPatient()}.
 *
 * <p>The {@link Search} annotation indicates that this method supports the search operation.
 * There may be many different methods annotated with this {@link Search} annotation, to support
 * many different search criteria.
 *
 * @param patient a {@link ReferenceParam} for the {@link ExplanationOfBenefit#getPatient()} to
 *     try and find matches for {@link ExplanationOfBenefit}s
 * @param type a list of {@link ClaimType} to include in the result. Defaults to all types.
 * @param startIndex an {@link OptionalParam} for the startIndex (or offset) used to determine
 *     pagination
 * @param excludeSamhsa an {@link OptionalParam} that, if <code>"true"</code>, will use {@link
 *     Stu3EobSamhsaMatcher} to filter out all SAMHSA-related claims from the results
 * @param lastUpdated an {@link OptionalParam} that specifies a date range for the lastUpdated
 *     field.
 * @param serviceDate an {@link OptionalParam} that specifies a date range for {@link
 *     ExplanationOfBenefit}s that completed
 * @param requestDetails a {@link RequestDetails} containing the details of the request URL, used
 *     to parse out pagination values
 * @return Returns a {@link Bundle} of {@link ExplanationOfBenefit}s, which may contain multiple
 *     matching resources, or may also be empty.
 */
@Search
@Trace
public Bundle findByPatient(@RequiredParam(name = ExplanationOfBenefit.SP_PATIENT) @Description(shortDefinition = "The patient identifier to search for") ReferenceParam patient, @OptionalParam(name = "type") @Description(shortDefinition = "A list of claim types to include") TokenAndListParam type, @OptionalParam(name = "startIndex") @Description(shortDefinition = "The offset used for result pagination") String startIndex, @OptionalParam(name = "excludeSAMHSA") @Description(shortDefinition = "If true, exclude all SAMHSA-related resources") String excludeSamhsa, @OptionalParam(name = "_lastUpdated") @Description(shortDefinition = "Include resources last updated in the given range") DateRangeParam lastUpdated, @OptionalParam(name = "service-date") @Description(shortDefinition = "Include resources that completed in the given range") DateRangeParam serviceDate, RequestDetails requestDetails) {
    /*
     * startIndex is an optional parameter here because it must be declared in the
     * event it is passed in. However, it is not being used here because it is also
     * contained within requestDetails and parsed out along with other parameters
     * later.
     */
    String beneficiaryId = patient.getIdPart();
    Set<ClaimType> claimTypes = parseTypeParam(type);
    Boolean includeTaxNumbers = returnIncludeTaxNumbers(requestDetails);
    OffsetLinkBuilder paging = new OffsetLinkBuilder(requestDetails, "/ExplanationOfBenefit?");
    Operation operation = new Operation(Operation.Endpoint.V1_EOB);
    operation.setOption("by", "patient");
    operation.setOption("types", (claimTypes.size() == ClaimType.values().length) ? "*" : claimTypes.stream().sorted(Comparator.comparing(ClaimType::name)).collect(Collectors.toList()).toString());
    operation.setOption("IncludeTaxNumbers", "" + includeTaxNumbers);
    operation.setOption("pageSize", paging.isPagingRequested() ? "" + paging.getPageSize() : "*");
    operation.setOption("_lastUpdated", Boolean.toString(lastUpdated != null && !lastUpdated.isEmpty()));
    operation.setOption("service-date", Boolean.toString(serviceDate != null && !serviceDate.isEmpty()));
    operation.publishOperationName();
    List<IBaseResource> eobs = new ArrayList<IBaseResource>();
    // Optimize when the lastUpdated parameter is specified and result set is empty
    if (loadedFilterManager.isResultSetEmpty(beneficiaryId, lastUpdated)) {
        return TransformerUtils.createBundle(paging, eobs, loadedFilterManager.getTransactionTime());
    }
    /*
     * The way our JPA/SQL schema is setup, we have to run a separate search for
     * each claim type, then combine the results. It's not super efficient, but it's
     * also not so inefficient that it's worth fixing.
     */
    if (claimTypes.contains(ClaimType.CARRIER))
        eobs.addAll(transformToEobs(ClaimType.CARRIER, findClaimTypeByPatient(ClaimType.CARRIER, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.DME))
        eobs.addAll(transformToEobs(ClaimType.DME, findClaimTypeByPatient(ClaimType.DME, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.HHA))
        eobs.addAll(transformToEobs(ClaimType.HHA, findClaimTypeByPatient(ClaimType.HHA, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.HOSPICE))
        eobs.addAll(transformToEobs(ClaimType.HOSPICE, findClaimTypeByPatient(ClaimType.HOSPICE, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.INPATIENT))
        eobs.addAll(transformToEobs(ClaimType.INPATIENT, findClaimTypeByPatient(ClaimType.INPATIENT, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.OUTPATIENT))
        eobs.addAll(transformToEobs(ClaimType.OUTPATIENT, findClaimTypeByPatient(ClaimType.OUTPATIENT, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.PDE))
        eobs.addAll(transformToEobs(ClaimType.PDE, findClaimTypeByPatient(ClaimType.PDE, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (claimTypes.contains(ClaimType.SNF))
        eobs.addAll(transformToEobs(ClaimType.SNF, findClaimTypeByPatient(ClaimType.SNF, beneficiaryId, lastUpdated, serviceDate), Optional.of(includeTaxNumbers)));
    if (Boolean.parseBoolean(excludeSamhsa))
        filterSamhsa(eobs);
    eobs.sort(ExplanationOfBenefitResourceProvider::compareByClaimIdThenClaimType);
    // Add bene_id to MDC logs
    TransformerUtils.logBeneIdToMdc(Arrays.asList(beneficiaryId));
    return TransformerUtils.createBundle(paging, eobs, loadedFilterManager.getTransactionTime());
}
Also used : OffsetLinkBuilder(gov.cms.bfd.server.war.commons.OffsetLinkBuilder) ArrayList(java.util.ArrayList) Operation(gov.cms.bfd.server.war.Operation) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Trace(com.newrelic.api.agent.Trace) Search(ca.uhn.fhir.rest.annotation.Search)

Example 2 with COMPLETED

use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ImmunizationFHIRConversionTest method testImmunizationReasonImmune.

@Test
void testImmunizationReasonImmune() throws IOException {
    // Status reason is IMMUNE when OBX.3 is 59784-9, and RXA.18 and RXA.20 not provided
    String hl7VUXmessageRep = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130531||48^HIB PRP-T^CVX\r" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // Status defaults to completed
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    assertThat(immunization.hasStatusReason()).isTrue();
    assertThat(immunization.getStatusReason().getCoding()).hasSize(2);
    // From OBX.3==59784-9
    assertThat(immunization.getStatusReason().getCoding().get(0).getCode()).isEqualTo("IMMUNE");
    assertThat(immunization.getStatusReason().getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v3-ActReason");
    assertThat(immunization.getStatusReason().getCoding().get(0).getDisplay()).isEqualTo("immunity");
    assertThat(immunization.getStatusReason().getCoding().get(1).getCode()).isEqualTo("59784-9");
    assertThat(immunization.getStatusReason().getCoding().get(1).getSystem()).isEqualTo("http://loinc.org");
    assertThat(immunization.getStatusReason().getCoding().get(1).getDisplay()).isEqualTo("Disease with presumed immunity");
    assertThat(immunization.getStatusReason().getText()).isEqualTo("Disease with presumed immunity");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 3 with COMPLETED

use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ImmunizationFHIRConversionTest method testImmunizationDefaultCompletedMEDPRECStatusReason.

@Test
void testImmunizationDefaultCompletedMEDPRECStatusReason() throws IOException {
    // Status defaults to completed RXA.20, RXA.18 and ORC.5 are empty
    // Status reason is MEDPREC when OBX.3 is 30945-0 RXA.18 and RXA.20 not provided
    String hl7VUXmessageRep = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.5.1|||NE|AL||||||RI543763\r" + "PID|1||12345^^^^MR||TestPatient^Jane^^^^^L||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130531||48^HIB PRP-T^CVX|999|||1|\r" + "OBX|1|CE|30945-0^contraindication^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064||||||F||||||\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // Status defaults to completed
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    assertThat(immunization.hasStatusReason()).isTrue();
    assertThat(immunization.getStatusReason().getCoding()).hasSize(2);
    assertThat(immunization.getStatusReason().getCoding().get(0).getCode()).isEqualTo("MEDPREC");
    assertThat(immunization.getStatusReason().getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v3-ActReason");
    assertThat(immunization.getStatusReason().getCoding().get(0).getDisplay()).isEqualTo("medical precaution");
    assertThat(immunization.getStatusReason().getCoding().get(1).getCode()).isEqualTo("30945-0");
    assertThat(immunization.getStatusReason().getCoding().get(1).getSystem()).isEqualTo("http://loinc.org");
    assertThat(immunization.getStatusReason().getCoding().get(1).getDisplay()).isEqualTo("contraindication");
    assertThat(immunization.getStatusReason().getText()).isEqualTo("contraindication");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 4 with COMPLETED

use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ImmunizationFHIRConversionTest method testImmunizationOBX3is309567.

@Test
void testImmunizationOBX3is309567() throws IOException {
    // When OBX.3 is 30956-7 and RXA.5 is not provided we get a vaccine code from OBX.5
    String hl7VUXmessageRep = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130531\r" + "OBX|1|CWE|30956-7^vaccine type^LN|1|107^DTAP^CVX\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // Status defaults to completed
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    assertThat(immunization.hasStatusReason()).isFalse();
    assertThat(immunization.hasReaction()).isFalse();
    assertThat(immunization.hasProgramEligibility()).isFalse();
    assertThat(immunization.hasFundingSource()).isFalse();
    // When OBX.3 is 30956-7 we get a vaccine code
    assertThat(immunization.hasVaccineCode()).isTrue();
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getCode()).isEqualTo("107");
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getDisplay()).isEqualTo("DTAP");
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getSystem()).isEqualTo("http://hl7.org/fhir/sid/cvx");
    assertThat(immunization.getVaccineCode().getText()).isEqualTo("DTAP");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 5 with COMPLETED

use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project openmrs-module-fhir2 by openmrs.

the class FhirImmunizationServiceImplTest method updateImmunization_shouldUpdateImmunizationAccordingly.

@Test
public void updateImmunization_shouldUpdateImmunizationAccordingly() {
    // setup
    FhirContext ctx = FhirContext.forR4();
    IParser parser = ctx.newJsonParser();
    Immunization updatedImmunization = parser.parseResource(Immunization.class, "{\n" + "  \"resourceType\": \"Immunization\",\n" + "  \"id\": \"9353776b-dead-4588-8723-d687197d8438\",\n" + "  \"status\": \"completed\",\n" + "  \"vaccineCode\": {\n" + "    \"coding\": [\n" + "      {\n" + "        \"code\": \"d144d24f-6913-4b63-9660-a9108c2bebef\",\n" + "        \"display\": \"STAVUDINE LAMIVUDINE AND NEVIRAPINE\"\n" + "      }\n" + "    ]\n" + "  },\n" + "  \"patient\": {\n" + "    \"reference\": \"Patient/a7e04421-525f-442f-8138-05b619d16def\",\n" + "    \"type\": \"Patient\"\n" + "  },\n" + "  \"encounter\": {\n" + "    \"reference\": \"Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc\",\n" + "    \"type\": \"Encounter\"\n" + "  },\n" + "  \"occurrenceDateTime\": \"2020-07-08T20:30:00+02:00\",\n" + "  \"manufacturer\": {\n" + "    \"display\": \"Pharma Inc.\"\n" + "  },\n" + "  \"lotNumber\": \"YU765YT-1\",\n" + "  \"expirationDate\": \"2020-10-08\",\n" + "  \"performer\": [\n" + "    {\n" + "      \"actor\": {\n" + "        \"reference\": \"Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66\",\n" + "        \"type\": \"Practitioner\"\n" + "      }\n" + "    }\n" + "  ],\n" + "  \"protocolApplied\": [\n" + "    {\n" + "      \"doseNumberPositiveInt\": 4\n" + "    }\n" + "  ]\n" + "}");
    // replay
    Immunization savedImmunization = service.update("9353776b-dead-4588-8723-d687197d8438", updatedImmunization);
    Obs obs = obsService.getObsByUuid(savedImmunization.getId());
    // verify
    helper.validateImmunizationObsGroup(obs);
    assertObsCommons(obs, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
    obs.getGroupMembers().forEach(o -> {
        assertObsCommons(o, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
    });
    Map<String, Obs> members = helper.getObsMembersMap(obs);
    assertThat(members.get(CIEL_984).getValueCoded().getUuid(), is("d144d24f-6913-4b63-9660-a9108c2bebef"));
    assertThat(members.get(CIEL_1410).getValueDatetime(), equalTo(new DateTimeType("2020-07-08T20:30:00+02:00").getValue()));
    assertThat(members.get(CIEL_1418).getValueNumeric(), equalTo(4.0));
    assertThat(members.get(CIEL_1419).getValueText(), is("Pharma Inc."));
    assertThat(members.get(CIEL_1420).getValueText(), is("YU765YT-1"));
    assertThat(members.get(CIEL_165907).getValueDate(), equalTo(new DateType("2020-10-08").getValue()));
}
Also used : Obs(org.openmrs.Obs) FhirContext(ca.uhn.fhir.context.FhirContext) Immunization(org.hl7.fhir.r4.model.Immunization) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DateType(org.hl7.fhir.r4.model.DateType) IParser(ca.uhn.fhir.parser.IParser) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Aggregations

Immunization (org.hl7.fhir.r4.model.Immunization)13 Date (java.util.Date)9 ArrayList (java.util.ArrayList)8 InputStream (java.io.InputStream)7 Reference (org.hl7.fhir.dstu3.model.Reference)7 Test (org.junit.jupiter.api.Test)7 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)6 Collectors (java.util.stream.Collectors)5 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)5 Reference (org.hl7.fhir.r4.model.Reference)5 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)5 FhirContext (ca.uhn.fhir.context.FhirContext)4 Search (ca.uhn.fhir.rest.annotation.Search)4 Trace (com.newrelic.api.agent.Trace)4 File (java.io.File)4 List (java.util.List)4 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)4 Coding (org.hl7.fhir.dstu3.model.Coding)4 Bundle (org.hl7.fhir.r4.model.Bundle)4 CodeType (org.hl7.fhir.r4.model.CodeType)4