Search in sources :

Example 11 with Time

use of org.hl7.elm.r1.Time in project beneficiary-fhir-data by CMSgov.

the class DMEClaimTransformerV2 method transform.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param claim the CCW {@link DMEClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     DMEClaim}
 */
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(DMEClaimTransformerV2.class.getSimpleName(), "transform")).time();
    if (!(claim instanceof DMEClaim)) {
        throw new BadCodeMonkeyException();
    }
    ExplanationOfBenefit eob = transformClaim((DMEClaim) claim, includeTaxNumbers);
    timer.stop();
    return eob;
}
Also used : DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Timer(com.codahale.metrics.Timer) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Trace(com.newrelic.api.agent.Trace)

Example 12 with Time

use of org.hl7.elm.r1.Time in project beneficiary-fhir-data by CMSgov.

the class CarrierClaimTransformerV2 method transform.

/**
 * @param metricRegistry the {@link MetricRegistry} to use
 * @param claim the CCW {@link CarrierClaim} to transform
 * @return a FHIR {@link ExplanationOfBenefit} resource that represents the specified {@link
 *     CarrierClaim}
 */
@Trace
static ExplanationOfBenefit transform(MetricRegistry metricRegistry, Object claim, Optional<Boolean> includeTaxNumbers) {
    Timer.Context timer = metricRegistry.timer(MetricRegistry.name(CarrierClaimTransformerV2.class.getSimpleName(), "transform")).time();
    if (!(claim instanceof CarrierClaim)) {
        throw new BadCodeMonkeyException();
    }
    ExplanationOfBenefit eob = transformClaim((CarrierClaim) claim, includeTaxNumbers);
    timer.stop();
    return eob;
}
Also used : Timer(com.codahale.metrics.Timer) BadCodeMonkeyException(gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) ExplanationOfBenefit(org.hl7.fhir.r4.model.ExplanationOfBenefit) Trace(com.newrelic.api.agent.Trace)

Example 13 with Time

use of org.hl7.elm.r1.Time in project beneficiary-fhir-data by CMSgov.

the class ExplanationOfBenefitResourceProviderIT method searchForEobsWithPagingWithNegativePagingParameters.

/**
 * Verifies that {@link ExplanationOfBenefitResourceProvider#findByPatient} works as expected for
 * a {@link Patient} that does exist in the DB, with paging, using negative values for page size
 * and start index parameters. This test expects to receive a BadRequestException, as negative
 * values should result in an HTTP 400.
 *
 * @throws FHIRException (indicates test failure)
 */
@Test
public void searchForEobsWithPagingWithNegativePagingParameters() throws FHIRException {
    List<Object> loadedRecords = ServerTestUtils.get().loadData(Arrays.asList(StaticRifResourceGroup.SAMPLE_A.getResources()));
    IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
    Beneficiary beneficiary = loadedRecords.stream().filter(r -> r instanceof Beneficiary).map(r -> (Beneficiary) r).findFirst().get();
    /*
     * FIXME: At this time we cannot check for negative page size parameters due to
     * the same bug described in
     * https://github.com/jamesagnew/hapi-fhir/issues/1074.
     */
    Bundle searchResults = fhirClient.search().forResource(ExplanationOfBenefit.class).where(ExplanationOfBenefit.PATIENT.hasId(TransformerUtils.buildPatientId(beneficiary))).returnBundle(Bundle.class).execute();
    assertNotNull(searchResults);
    /*
     * Access a created link of this bundle, providing the startIndex but not the
     * pageSize (count).
     */
    assertThrows(InvalidRequestException.class, () -> {
        fhirClient.loadPage().byUrl(searchResults.getLink(Bundle.LINK_SELF).getUrl() + "&startIndex=-1").andReturnBundle(Bundle.class).execute();
    });
}
Also used : Arrays(java.util.Arrays) Bundle(org.hl7.fhir.dstu3.model.Bundle) Date(java.util.Date) Constants(ca.uhn.fhir.rest.api.Constants) InpatientClaim(gov.cms.bfd.model.rif.InpatientClaim) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) PartDEvent(gov.cms.bfd.model.rif.PartDEvent) SNFClaim(gov.cms.bfd.model.rif.SNFClaim) DateRangeParam(ca.uhn.fhir.rest.param.DateRangeParam) BeforeAll(org.junit.jupiter.api.BeforeAll) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) BeneficiaryHistory(gov.cms.bfd.model.rif.BeneficiaryHistory) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Triple(org.apache.commons.lang3.tuple.Triple) OutpatientClaim(gov.cms.bfd.model.rif.OutpatientClaim) IdDt(ca.uhn.fhir.model.primitive.IdDt) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) List(java.util.List) TransformerConstants(gov.cms.bfd.server.war.commons.TransformerConstants) EntityManagerFactory(javax.persistence.EntityManagerFactory) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CarrierClaim(gov.cms.bfd.model.rif.CarrierClaim) Optional(java.util.Optional) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) RequestHeaders(gov.cms.bfd.server.war.commons.RequestHeaders) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ArrayList(java.util.ArrayList) HHAClaim(gov.cms.bfd.model.rif.HHAClaim) PipelineTestUtils(gov.cms.bfd.pipeline.sharedutils.PipelineTestUtils) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) ImmutableList(com.google.common.collect.ImmutableList) ReferenceParam(ca.uhn.fhir.rest.param.ReferenceParam) DMEClaim(gov.cms.bfd.model.rif.DMEClaim) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) StaticRifResourceGroup(gov.cms.bfd.model.rif.samples.StaticRifResourceGroup) ServerTestUtils(gov.cms.bfd.server.war.ServerTestUtils) StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) CommonHeaders(gov.cms.bfd.server.war.commons.CommonHeaders) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) HospiceClaim(gov.cms.bfd.model.rif.HospiceClaim) EntityManager(javax.persistence.EntityManager) MedicareBeneficiaryIdHistory(gov.cms.bfd.model.rif.MedicareBeneficiaryIdHistory) AfterEach(org.junit.jupiter.api.AfterEach) ChronoUnit(java.time.temporal.ChronoUnit) Patient(org.hl7.fhir.dstu3.model.Patient) FHIRException(org.hl7.fhir.exceptions.FHIRException) IGenericClient(ca.uhn.fhir.rest.client.api.IGenericClient) Bundle(org.hl7.fhir.dstu3.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) ExplanationOfBenefit(org.hl7.fhir.dstu3.model.ExplanationOfBenefit) Beneficiary(gov.cms.bfd.model.rif.Beneficiary) Test(org.junit.jupiter.api.Test)

Example 14 with Time

use of org.hl7.elm.r1.Time in project beneficiary-fhir-data by CMSgov.

the class SNFClaimTransformerV2Test method shouldHaveClmIpAdmsnTypeCdSupInfo.

@Test
public void shouldHaveClmIpAdmsnTypeCdSupInfo() {
    SupportingInformationComponent sic = TransformerTestUtilsV2.findSupportingInfoByCode("https://bluebutton.cms.gov/resources/variables/clm_ip_admsn_type_cd", eob.getSupportingInfo());
    SupportingInformationComponent compare = TransformerTestUtilsV2.createSupportingInfo(// We don't care what the sequence number is here
    sic.getSequence(), // Category
    Arrays.asList(new Coding("http://terminology.hl7.org/CodeSystem/claiminformationcategory", "info", "Information"), new Coding("https://bluebutton.cms.gov/resources/codesystem/information", "https://bluebutton.cms.gov/resources/variables/clm_ip_admsn_type_cd", "Claim Inpatient Admission Type Code")), // Code
    new Coding("https://bluebutton.cms.gov/resources/variables/clm_ip_admsn_type_cd", "3", "Elective - The patient's condition permitted adequate time to schedule the availability of suitable accommodations."));
    assertTrue(compare.equalsDeep(sic));
}
Also used : SupportingInformationComponent(org.hl7.fhir.r4.model.ExplanationOfBenefit.SupportingInformationComponent) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 15 with Time

use of org.hl7.elm.r1.Time in project kindling by HL7.

the class OldSpreadsheetParser method readSearchParams.

private void readSearchParams(ResourceDefn root2, Sheet sheet, boolean forProfile) throws Exception {
    if (sheet != null) {
        for (int row = 0; row < sheet.rows.size(); row++) {
            if (!sheet.hasColumn(row, "Name"))
                throw new Exception("Search Param has no name " + getLocation(row));
            String n = sheet.getColumn(row, "Name");
            if (!n.startsWith("!")) {
                if (!sheet.hasColumn(row, "Type"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " has no type " + getLocation(row));
                if (n.endsWith("-before") || n.endsWith("-after"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " includes relative time " + getLocation(row));
                if (root2.getSearchParams().containsKey(n))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + ": duplicate name " + getLocation(row));
                String d = sheet.getColumn(row, "Description");
                SearchType t = readSearchType(sheet.getColumn(row, "Type"), row);
                SearchParameter.XPathUsageType pu = readSearchXPathUsage(sheet.getColumn(row, "Path Usage"), row);
                if (Utilities.noString(sheet.getColumn(row, "Path")) && !root2.getName().equals("Resource") && !root2.getName().equals("DomainResource"))
                    throw new Exception("Search Param " + root2.getName() + "/" + n + " has no path at " + getLocation(row));
                SearchParameterDefn sp = null;
                if (t == SearchType.composite) {
                    List<CompositeDefinition> pn = new ArrayList<CompositeDefinition>();
                    if (Utilities.noString(d))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " has no description " + getLocation(row));
                    String[] pl = sheet.getColumn(row, "Path").split("\\&");
                    String[] pe = sheet.getColumn(row, "Expression").split("\\;");
                    if (pe.length != pl.length + 1)
                        throw new Exception("Composite Search Param " + root2.getName() + "/" + n + " needs expressions " + getLocation(row));
                    int i = 0;
                    for (String pi : pl) {
                        String p = pi.trim();
                        i++;
                        String e = pe[i].trim();
                        if (!root2.getSearchParams().containsKey(p)) {
                            boolean found = false;
                            if (p.endsWith("[x]"))
                                for (String pan : root2.getSearchParams().keySet()) {
                                    if (pan.startsWith(p.substring(0, p.length() - 3)))
                                        found = true;
                                }
                            if (!found)
                                throw new Exception("Composite Search Param " + root2.getName() + "/" + n + "  refers to an unknown component " + p + " at " + getLocation(row));
                        }
                        pn.add(new CompositeDefinition(p, e));
                    }
                    StandardsStatus ss = root2.getStatus();
                    if (!Utilities.noString(sheet.getColumn(row, "Standards-Status")))
                        ss = StandardsStatus.fromCode(sheet.getColumn(row, "Standards-Status"));
                    sp = new SearchParameterDefn(n, d, t, pu, ss);
                    sp.setExpression(pe[0].trim());
                    sp.getComposites().addAll(pn);
                } else {
                    List<String> pn = new ArrayList<String>();
                    String xp = sheet.getColumn(row, "XPath");
                    String[] pl = sheet.getColumn(row, "Path").split("\\|");
                    boolean hierarchy = false;
                    for (String pi : pl) {
                        String p = pi.trim();
                        ElementDefn e = null;
                        if (!Utilities.noString(p) && !p.startsWith("!") && !p.startsWith("Extension{") && definitions != null) {
                            e = root2.getRoot().getElementForPath(trimIndexes(p), definitions, "search param", true, true);
                        }
                        if (e != null && e.hasHierarchy() && e.getHierarchy())
                            hierarchy = true;
                        if (Utilities.noString(d) && e != null)
                            d = e.getShortDefn();
                        if (p.startsWith("Extension(")) {
                            String url = extractExtensionUrl(p);
                            StructureDefinition ex = context.fetchResource(StructureDefinition.class, url);
                            if (ex == null)
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " refers to unknown extension '" + url + "' " + getLocation(row));
                            if (Utilities.noString(d))
                                d = ex.getDescription();
                            pn.add(p);
                        }
                        if (d == null)
                            throw new Exception("Search Param " + root2.getName() + "/" + n + " has no description " + getLocation(row));
                        if (e != null)
                            pn.add(p);
                        if (t == SearchType.reference) {
                            if (e == null && !forProfile && !sheet.hasColumn(row, "Target Types"))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " of type reference has wrong path '" + p + "' at " + getLocation(row));
                            if (!forProfile && e != null && (!e.hasType("Reference")) && (!e.hasType("canonical")) && (!e.hasType("Resource")))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is reference, but the element type is " + e.typeCode());
                        } else {
                            if (e != null && e.hasOnlyType("Reference"))
                                throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            if (t == SearchType.uri) {
                                if (e != null && !(e.typeCode().equals("uri") || e.typeCode().equals("url") || e.typeCode().equals("oid") || e.typeCode().startsWith("canonical(")))
                                    throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            } else {
                                if (e != null && e.typeCode().equals("uri"))
                                    throw new Exception("Search Param " + root2.getName() + "/" + n + " wrong type. The search type is " + t.toString() + ", but the element type is " + e.typeCode());
                            }
                        }
                    }
                    if (!forProfile && t == SearchType.reference && pn.size() == 0 && !sheet.hasColumn(row, "Target Types"))
                        throw new Exception("Search Param " + root2.getName() + "/" + n + " of type reference has no path(s) " + getLocation(row));
                    StandardsStatus ss = root2.getStatus();
                    if (!Utilities.noString(sheet.getColumn(row, "Standards-Status")))
                        ss = StandardsStatus.fromCode(sheet.getColumn(row, "Standards-Status"));
                    sp = new SearchParameterDefn(n, d, t, pu, ss);
                    sp.getPaths().addAll(pn);
                    if (!Utilities.noString(xp))
                        sp.setXPath(xp);
                    if (!Utilities.noString(sheet.getColumn(row, "Expression")))
                        sp.setExpression(sheet.getColumn(row, "Expression"));
                    if (!Utilities.noString(sheet.getColumn(row, "Target Types"))) {
                        sp.setManualTypes(sheet.getColumn(row, "Target Types").split("\\,"));
                    }
                    sp.setHierarchy(hierarchy);
                    CommonSearchParameter csp = definitions.getCommonSearchParameters().get(root2.getName() + "::" + n);
                    if (csp != null)
                        for (String s : csp.getResources()) {
                            if (!root2.getName().equals(s))
                                sp.getOtherResources().add(s);
                        }
                }
                root2.getSearchParams().put(n, sp);
            }
        }
    }
}
Also used : SearchParameterDefn(org.hl7.fhir.definitions.model.SearchParameterDefn) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) FHIRException(org.hl7.fhir.exceptions.FHIRException) CompositeDefinition(org.hl7.fhir.definitions.model.SearchParameterDefn.CompositeDefinition) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchType(org.hl7.fhir.definitions.model.SearchParameterDefn.SearchType) CommonSearchParameter(org.hl7.fhir.definitions.model.CommonSearchParameter) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus)

Aggregations

Time (com.android.calendarcommon2.Time)178 ArrayList (java.util.ArrayList)64 List (java.util.List)40 Timer (com.codahale.metrics.Timer)27 Trace (com.newrelic.api.agent.Trace)23 Date (java.util.Date)23 Test (org.junit.jupiter.api.Test)23 IOException (java.io.IOException)21 FHIRException (org.hl7.fhir.exceptions.FHIRException)21 Paint (android.graphics.Paint)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)19 Resource (org.hl7.fhir.r4.model.Resource)19 BadCodeMonkeyException (gov.cms.bfd.sharedutils.exceptions.BadCodeMonkeyException)18 Condition (org.hl7.fhir.r4.model.Condition)16 Optional (java.util.Optional)15 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)15 Bundle (org.hl7.fhir.r4.model.Bundle)15 Coding (org.hl7.fhir.r4.model.Coding)15 Reference (org.hl7.fhir.r4.model.Reference)15 HashMap (java.util.HashMap)14