Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/MAT-7166-e…
Browse files Browse the repository at this point in the history
…xport-tc-madiefile
  • Loading branch information
nmorasb committed Jun 7, 2024
2 parents e258c05 + a3e5004 commit 716ff0b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.hl7.fhir.r4.model.Reference;
import org.hl7.fhir.r4.model.Resource;
import org.hl7.fhir.r4.model.StringType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestClientException;
Expand Down Expand Up @@ -66,6 +67,9 @@ public class TestCaseBundleService {

private final FhirContext fhirContext;

@Value("${madie.url}")
private String madieUrl;

public Map<String, Bundle> getTestCaseExportBundle(Measure measure, List<TestCase> testCases) {
if (measure == null || testCases == null || testCases.isEmpty()) {
throw new InternalServerException("Unable to find Measure and/or test case");
Expand Down Expand Up @@ -131,8 +135,8 @@ public void updateEntry(TestCase testCase, BundleType bundleType) {
.map(
entry -> {
if (bundleType == BundleType.TRANSACTION) {

FhirResourceHelpers.setResourceEntry(entry.getResource(), entry);
FhirResourceHelpers.setRequestForResourceEntry(
entry.getResource(), entry, Bundle.HTTPVerb.PUT);
return entry;
} else if (bundleType == BundleType.COLLECTION) {
entry.setRequest(null);
Expand Down Expand Up @@ -283,7 +287,11 @@ private List<Reference> buildEvaluatedResource(Bundle testCaseBundle) {
List<Reference> references = new ArrayList<>();
testCaseBundle
.getEntry()
.forEach(entry -> references.add(new Reference(entry.getResource().getId())));
// remove the madie url to provide relative urls
.forEach(
entry ->
references.add(
new Reference(StringUtils.remove(entry.getResource().getId(), madieUrl))));
return references;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ public static Bundle.BundleEntryComponent getBundleEntryComponent(
.setResource(resource);
// for the transaction bundles, add request object to the entry
if ("Transaction".equalsIgnoreCase(bundleType)) {
setResourceEntry(resource, entryComponent);
// We want to enforce PUT request temporarily
// https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1877
if (resource.getResourceType().toString().equals("MeasureReport")) {
setRequestForResourceEntry(resource, entryComponent, Bundle.HTTPVerb.PUT);
} else {
setRequestForResourceEntry(resource, entryComponent, Bundle.HTTPVerb.POST);
}
}
return entryComponent;
}

public static void setResourceEntry(
Resource resource, Bundle.BundleEntryComponent entryComponent) {
public static void setRequestForResourceEntry(
Resource resource, Bundle.BundleEntryComponent entryComponent, Bundle.HTTPVerb httpMethod) {
Bundle.BundleEntryRequestComponent requestComponent =
new Bundle.BundleEntryRequestComponent()
.setMethod(Bundle.HTTPVerb.POST)
.setMethod(httpMethod)
.setUrl(resource.getResourceType() + "/" + resource.getIdPart());
entryComponent.setRequest(requestComponent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void updateEntryTest() {

bundle = parser.parseResource(Bundle.class, testCase.getJson());
assertEquals(
bundle.getEntry().get(0).getRequest().getMethod().toString(), HTTPVerb.POST.toString());
bundle.getEntry().get(0).getRequest().getMethod().toString(), HTTPVerb.PUT.toString());
}

@Test
Expand Down Expand Up @@ -203,7 +203,7 @@ void getTestCaseExportBundleMulti() {
assertEquals(5, bundle.getEntry().size());
assertEquals(bundle.getType(), Bundle.BundleType.TRANSACTION);
bundleEntry = bundle.getEntry().get(4);
assertEquals(bundleEntry.getRequest().getMethod(), Bundle.HTTPVerb.POST);
assertEquals(bundleEntry.getRequest().getMethod(), Bundle.HTTPVerb.PUT);
assertEquals(
bundleEntry.getRequest().getUrl(),
"MeasureReport/" + bundleEntry.getResource().getIdPart());
Expand Down

0 comments on commit 716ff0b

Please sign in to comment.