Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data requirements test fixture update #522

Merged
merged 1 commit into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import org.opencds.cqf.ruler.utility.Ids;
import org.opencds.cqf.ruler.utility.Libraries;
import org.opencds.cqf.ruler.utility.Searches;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import ca.uhn.fhir.rest.annotation.IdParam;
Expand All @@ -44,6 +46,8 @@
import org.springframework.util.StringUtils;

public class DataOperationsProvider extends DaoRegistryOperationProvider {
private Logger myLog = LoggerFactory.getLogger(DataOperationsProvider.class);

@Autowired
private JpaLibraryContentProviderFactory jpaLibraryContentProviderFactory;

Expand Down Expand Up @@ -97,7 +101,13 @@ public Library getLibraryFromMeasure(Measure measure, RequestDetails theRequestD
}
}

Library library = read(new IdType(libraryIdOrCanonical), theRequestDetails);
Library library = null;

try {
read(new IdType(libraryIdOrCanonical), theRequestDetails);
} catch (Exception e) {
myLog.info("Library read failed as measure.getLibrary() is not an ID, fall back to search as canonical");
}

if (library == null) {
library = search(Library.class, Searches.byCanonical(libraryIdOrCanonical), theRequestDetails).firstOrNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import org.opencds.cqf.ruler.utility.Canonicals;
import org.opencds.cqf.ruler.utility.Libraries;
import org.opencds.cqf.ruler.utility.Searches;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import ca.uhn.fhir.rest.annotation.IdParam;
Expand All @@ -47,6 +49,8 @@

public class DataOperationsProvider extends DaoRegistryOperationProvider {

private Logger myLog = LoggerFactory.getLogger(DataOperationsProvider.class);

@Autowired
private JpaLibraryContentProviderFactory jpaLibraryContentProviderFactory;

Expand Down Expand Up @@ -111,8 +115,13 @@ public Library getLibraryFromMeasure(Measure measure, RequestDetails theRequestD
}
}

Library library = read(new IdType(libraryIdOrCanonical), theRequestDetails);
Library library = null;

try {
library = read(new IdType(libraryIdOrCanonical), theRequestDetails);
} catch (Exception e) {
myLog.info("Library read failed as measure.getLibrary() is not an ID, fall back to search as canonical");
}
if (library == null) {
library = search(Library.class, Searches.byCanonical(libraryIdOrCanonical), theRequestDetails).firstOrNull();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ public class DataOperationProviderIT extends RestIntegrationTest {

@Test
public void testDstu3DataRequirementsOperation() throws IOException {
String bundleAsText = stringFromResource( "DataReqLibraryTransactionBundle.json");
String bundleAsText = stringFromResource( "DataReqLibraryTransactionBundleDstu3.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", "LibraryEvaluationTest"))
Library returnLibrary = getClient().operation()
.onInstance(new IdType("Library", "LibraryEvaluationTest"))
.named("$data-requirements")
.withParameters(params)
.returnResourceType(Library.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ public class DataOperationProviderIT extends RestIntegrationTest {

@Test
public void testR4LibraryDataRequirementsOperation() throws IOException {
String bundleAsText = stringFromResource( "DataReqLibraryTransactionBundle.json");
String bundleAsText = stringFromResource( "DataReqLibraryTransactionBundleR4.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", "LibraryEvaluationTest"))
Library returnLibrary = getClient().operation()
.onInstance(new IdType("Library", "LibraryEvaluationTest"))
.named("$data-requirements")
.withParameters(params)
.returnResourceType(Library.class)
Expand Down
284 changes: 284 additions & 0 deletions plugin/cr/src/test/resources/DataReqLibraryTransactionBundleDstu3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
{
"resourceType": "Bundle",
"type": "transaction",
"id": "LibraryTransactionBundleDstu3",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "example-opioidcds",
"meta": {
"versionId": "1",
"lastUpdated": "2017-11-25T17:26:27.040-07:00"
},
"identifier": [
{
"use": "official",
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/identifier-type",
"code": "SB",
"display": "Social Beneficiary Identifier"
}
],
"text": "US Social Security Number"
},
"system": "http://hl7.org/fhir/sid/us-ssn",
"value": "000002341"
}
],
"active": true,
"name": [
{
"family": "Goodwall",
"given": [
"Jerry",
"Phillip"
]
}
],
"telecom": [
{
"system": "phone",
"value": "248-555-7834",
"use": "home"
},
{
"system": "phone",
"value": "248-555-7845",
"use": "mobile"
}
],
"gender": "male",
"birthDate": "1936-05-29",
"address": [
{
"use": "home",
"type": "postal",
"line": [
"751 E Apple Drive"
],
"city": "Novi",
"district": "Oakland County",
"state": "MI",
"postalCode": "48376"
}
]
},
"request": {
"method": "PUT",
"url": "Patient/example-opioidcds/_history/1"
}
},
{
"resource": {
"resourceType": "Observation",
"id": "example-opioidcds",
"status": "final",
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "3779-6"
}
]
},
"subject": {
"reference": "Patient/example-opioidcds"
},
"effectiveDateTime": "2017-12-12",
"interpretation": {
"coding": [
{
"system": "https://www.hl7.org/fhir/v2/0078",
"code": "POS"
}
]
}
},
"request": {
"method": "PUT",
"url": "Observation/example-opioidcds"
}
},
{
"resource": {
"resourceType": "Library",
"id": "LibraryEvaluationTestDependency",
"extension": [
{
"url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem",
"valueReference": {
"reference": "Device/cqf-tooling"
}
},
{
"url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem",
"valueReference": {
"reference": "cqf-tooling"
}
}
],
"url": "http://localhost:8080/fhir/Library/LibraryEvaluationTestDependency",
"version": "1.0.000",
"name": "LibraryEvaluationTestDependency",
"relatedArtifact": [
{
"type": "depends-on",
"display": "FHIR model information",
"resource": "http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"
}
],
"parameter": [
{
"name": "Patient",
"use": "out",
"min": 0,
"max": "1",
"type": "Patient"
},
{
"name": "Encounters",
"use": "out",
"min": 0,
"max": "*",
"type": "Encounter"
}
],
"dataRequirement": [
{
"type": "Patient",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Patient"
]
},
{
"type": "Encounter",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Encounter"
]
}
],
"content": [
{
"contentType": "text/cql",
"data": "bGlicmFyeSBMaWJyYXJ5RXZhbHVhdGlvblRlc3REZXBlbmRlbmN5IHZlcnNpb24gJzEuMC4wMDAnCgp1c2luZyBGSElSIHZlcnNpb24gJzMuMC4wJwoKY29udGV4dCBQYXRpZW50CgpkZWZpbmUgIkVuY291bnRlcnMiOgogIFtFbmNvdW50ZXJdCg=="
}
]
},
"request": {
"method": "PUT",
"url": "Library/LibraryEvaluationTestDependency"
}
},
{
"resource": {
"resourceType": "Library",
"id": "LibraryEvaluationTest",
"extension": [
{
"url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem",
"valueReference": {
"reference": "Device/cqf-tooling"
}
},
{
"url": "http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem",
"valueReference": {
"reference": "cqf-tooling"
}
}
],
"url": "http://localhost:8080/fhir/Library/LibraryEvaluationTest",
"version": "1.0.000",
"name": "LibraryEvaluationTest",
"relatedArtifact": [
{
"type": "depends-on",
"display": "FHIR model information",
"resource": "http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1"
},
{
"type": "depends-on",
"resource": "http://fhir.org/guides/cqf/common/Library/LibraryEvaluationTestDependency|1.0.000"
}
],
"parameter": [
{
"name": "Patient",
"use": "out",
"min": 0,
"max": "1",
"type": "Patient"
},
{
"name": "Has Bone Narrowing Conditions",
"use": "out",
"min": 0,
"max": "1",
"type": "boolean"
},
{
"name": "Has Osteonecrosis Knee Conditions",
"use": "out",
"min": 0,
"max": "1",
"type": "boolean"
},
{
"name": "Has Angular Deformity Knee Conditions",
"use": "out",
"min": 0,
"max": "1",
"type": "boolean"
},
{
"name": "Has Presence of significant radiographic findings, which may include knee joint destruction, angular deformity, or severe narrowing",
"use": "out",
"min": 0,
"max": "1",
"type": "boolean"
},
{
"name": "Has Failure of Previous Proximal Tibial or Distal Femoral Osteotomy",
"use": "out",
"min": 0,
"max": "1",
"type": "boolean"
}
],
"dataRequirement": [
{
"type": "Patient",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Patient"
]
},
{
"type": "Condition",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Condition"
]
},
{
"type": "Procedure",
"profile": [
"http://hl7.org/fhir/StructureDefinition/Procedure"
]
}
],
"content": [
{
"contentType": "text/cql",
"data": "bGlicmFyeSBMaWJyYXJ5RXZhbHVhdGlvblRlc3QgdmVyc2lvbiAnMS4wLjAwMCcKCnVzaW5nIEZISVIgdmVyc2lvbiAnMy4wLjAnCgppbmNsdWRlIExpYnJhcnlFdmFsdWF0aW9uVGVzdERlcGVuZGVuY3kgdmVyc2lvbiAnMS4wLjAwMCcgY2FsbGVkIExFVDIKCmNvbnRleHQgUGF0aWVudAoKLy8gVGhpcyBleHByZXNzaW9uIGRvZXMgbm90IGRpcmVjdGx5IHJldHJpZXZlIGRhdGEgYW5kIHNvIGl0IGlzIG5vdCBuZWNlc3NhcnkgZm9yCi8vIERhdGFSZXF1aXJlbWVudCBpZGVudGlmaWNhdGlvbi4gSXQga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bUHJvY2VkdXJlXSkKCmRlZmluZSAiRW5jb3VudGVycyBmcm9tIERlcGVuZGVuY3kgTGlicmFyeSI6CiAgTEVUMi4iRW5jb3VudGVycyIKCmRlZmluZSAiSGFzIEVuY291bnRlcnMiOgogICAgZXhpc3RzICgiRW5jb3VudGVycyBmcm9tIERlcGVuZGVuY3kgTGlicmFyeSIpCg=="
}
]
},
"request": {
"method": "PUT",
"url": "Library/LibraryEvaluationTest"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"resourceType": "Bundle",
"type": "transaction",
"id": "LibraryTrsnsactionBundle",
"id": "LibraryTrsnsactionBundleR4",
"entry": [
{
"resource": {
Expand Down
Loading