use of org.hl7.fhir.r4.model.Coverage in project cqf-ruler by DBCG.
the class DataOperationProviderIT method testR4LibraryFhirQueryPattern.
@Test
public void testR4LibraryFhirQueryPattern() throws IOException {
String bundleAsText = stringFromResource("ExmLogicTransactionBundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("target").setValue(new StringType("dummy"));
Library returnLibrary = getClient().operation().onInstance(new IdType("Library", "EXMLogic")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
assertNotNull(returnLibrary);
for (DataRequirement dr : returnLibrary.getDataRequirement()) {
switch(dr.getType()) {
case "Patient":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Patient?_id={{context.patientId}}".equals(query));
}
break;
case "Encounter":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
if (dr.hasCodeFilter()) {
assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
} else {
assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
}
}
break;
case "Coverage":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
}
break;
}
}
}
use of org.hl7.fhir.r4.model.Coverage in project cqf-ruler by DBCG.
the class DataOperationProviderIT method testR4MeasureFhirQueryPattern.
@Test
public void testR4MeasureFhirQueryPattern() throws IOException {
String bundleAsText = stringFromResource("ExmLogicMeasureTransactionBundle.json");
Bundle bundle = (Bundle) getFhirContext().newJsonParser().parseResource(bundleAsText);
getClient().transaction().withBundle(bundle).execute();
Parameters params = new Parameters();
params.addParameter().setName("startPeriod").setValue(new StringType("2019-01-01"));
params.addParameter().setName("endPeriod").setValue(new StringType("2020-01-01"));
Library returnLibrary = getClient().operation().onInstance(new IdType("Measure", "measure-exm")).named("$data-requirements").withParameters(params).returnResourceType(Library.class).execute();
assertNotNull(returnLibrary);
for (DataRequirement dr : returnLibrary.getDataRequirement()) {
switch(dr.getType()) {
case "Patient":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Patient?_id={{context.patientId}}".equals(query));
}
break;
case "Encounter":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
if (dr.hasCodeFilter()) {
assertTrue("Encounter?status=finished&subject=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292".equals(query));
} else {
assertTrue("Encounter?subject=Patient/{{context.patientId}}".equals(query));
}
}
break;
case "Coverage":
{
String query = dr.getExtensionByUrl("http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-fhirQueryPattern").getValueAsPrimitive().getValueAsString();
assertTrue("Coverage?policy-holder=Patient/{{context.patientId}}&type:in=http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591".equals(query));
}
break;
}
}
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class ServerCapabilityStatementIT method getCapabilities.
/**
* Verifies that the server responds as expected to the <code>GET [base]/_metadata</code>
* endpoint.
*/
@Test
public void getCapabilities() {
IGenericClient fhirClient = ServerTestUtils.get().createFhirClient();
CapabilityStatement capabilities = fhirClient.capabilities().ofType(CapabilityStatement.class).execute();
assertNotNull(capabilities);
// Verify that our custom server metadata is correct.
assertEquals(V1Server.CAPABILITIES_PUBLISHER, capabilities.getPublisher());
assertEquals(V1Server.CAPABILITIES_SERVER_NAME, capabilities.getSoftware().getName());
assertEquals("gov.cms.bfd:bfd-server-war", capabilities.getImplementation().getDescription());
assertNotEquals(null, capabilities.getSoftware().getVersion());
assertNotEquals("", capabilities.getSoftware().getVersion());
// The default for this field is HAPI's version but we don't use that.
assertNotEquals(VersionUtil.getVersion(), capabilities.getSoftware().getVersion());
assertEquals(1, capabilities.getRest().size());
CapabilityStatementRestComponent restCapabilities = capabilities.getRestFirstRep();
assertEquals(RestfulCapabilityMode.SERVER, restCapabilities.getMode());
// Verify that Patient resource support looks like expected.
CapabilityStatementRestResourceComponent patientCapabilities = restCapabilities.getResource().stream().filter(r -> r.getType().equals(Patient.class.getSimpleName())).findAny().get();
assertTrue(patientCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.READ).findAny().isPresent());
assertTrue(patientCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.SEARCHTYPE).findAny().isPresent());
assertFalse(patientCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.CREATE).findAny().isPresent());
// Verify that Coverage resource support looks like expected.
CapabilityStatementRestResourceComponent coverageCapabilities = restCapabilities.getResource().stream().filter(r -> r.getType().equals(Coverage.class.getSimpleName())).findAny().get();
assertTrue(coverageCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.READ).findAny().isPresent());
assertTrue(coverageCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.SEARCHTYPE).findAny().isPresent());
// Verify that EOB resource support looks like expected.
CapabilityStatementRestResourceComponent eobCapabilities = restCapabilities.getResource().stream().filter(r -> r.getType().equals(ExplanationOfBenefit.class.getSimpleName())).findAny().get();
assertTrue(eobCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.READ).findAny().isPresent());
assertTrue(eobCapabilities.getInteraction().stream().filter(i -> i.getCode() == TypeRestfulInteraction.SEARCHTYPE).findAny().isPresent());
// Spot check that an arbitrary unsupported resource isn't listed.
assertFalse(restCapabilities.getResource().stream().filter(r -> r.getType().equals(DiagnosticReport.class.getSimpleName())).findAny().isPresent());
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method createBundle.
/**
* Create a bundle from the entire search result
*
* @param paging contains the {@link OffsetLinkBuilder} information
* @param resources a list of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, of which a portion or all will be added to the bundle based on the paging values
* @param transactionTime date for the bundle
* @return Returns a {@link Bundle} of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or
* {@link Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle createBundle(OffsetLinkBuilder paging, List<IBaseResource> resources, Instant transactionTime) {
Bundle bundle = new Bundle();
if (paging.isPagingRequested()) {
/*
* FIXME: Due to a bug in HAPI-FHIR described here
* https://github.com/jamesagnew/hapi-fhir/issues/1074 paging for count=0 is not working
* correctly.
*/
int endIndex = Math.min(paging.getStartIndex() + paging.getPageSize(), resources.size());
List<IBaseResource> resourcesSubList = resources.subList(paging.getStartIndex(), endIndex);
bundle = TransformerUtils.addResourcesToBundle(bundle, resourcesSubList);
paging.setTotal(resources.size()).addLinks(bundle);
} else {
bundle = TransformerUtils.addResourcesToBundle(bundle, resources);
}
/*
* Dev Note: the Bundle's lastUpdated timestamp is the known last update time for the whole
* database. Because the filterManager's tracking of this timestamp is lazily updated for
* performance reason, the resources of the bundle may be after the filter manager's version of
* the timestamp.
*/
Instant maxBundleDate = resources.stream().map(r -> r.getMeta().getLastUpdated().toInstant()).filter(Objects::nonNull).max(Instant::compareTo).orElse(transactionTime);
bundle.getMeta().setLastUpdated(transactionTime.isAfter(maxBundleDate) ? Date.from(transactionTime) : Date.from(maxBundleDate));
bundle.setTotal(resources.size());
return bundle;
}
use of org.hl7.fhir.r4.model.Coverage in project beneficiary-fhir-data by CMSgov.
the class TransformerUtils method createBundle.
/**
* Create a bundle from the entire search result
*
* @param resources a list of {@link ExplanationOfBenefit}s, {@link Coverage}s, or {@link
* Patient}s, all of which will be added to the bundle
* @param paging contains the {@link LinkBuilder} information to add to the bundle
* @param transactionTime date for the bundle
* @return Returns a {@link Bundle} of either {@link ExplanationOfBenefit}s, {@link Coverage}s, or
* {@link Patient}s, which may contain multiple matching resources, or may also be empty.
*/
public static Bundle createBundle(List<IBaseResource> resources, LinkBuilder paging, Instant transactionTime) {
Bundle bundle = new Bundle();
TransformerUtils.addResourcesToBundle(bundle, resources);
paging.addLinks(bundle);
bundle.setTotalElement(paging.isPagingRequested() ? new UnsignedIntType() : new UnsignedIntType(resources.size()));
/*
* Dev Note: the Bundle's lastUpdated timestamp is the known last update time for the whole
* database. Because the filterManager's tracking of this timestamp is lazily updated for
* performance reason, the resources of the bundle may be after the filter manager's version of
* the timestamp.
*/
Instant maxBundleDate = resources.stream().map(r -> r.getMeta().getLastUpdated().toInstant()).filter(Objects::nonNull).max(Instant::compareTo).orElse(transactionTime);
bundle.getMeta().setLastUpdated(transactionTime.isAfter(maxBundleDate) ? Date.from(transactionTime) : Date.from(maxBundleDate));
return bundle;
}
Aggregations