Skip to content

Commit

Permalink
Merge pull request #1032 from Shreeja-dev/main
Browse files Browse the repository at this point in the history
feat:update request uri for /ccda/Bundle and /ccda/Bundle/$validate #1011
  • Loading branch information
ratheesh-kr authored Jan 14, 2025
2 parents de7dbb8 + 6ffda9f commit a4991d0
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private List<Object> processScreening(String groupKey,
request, response,
updatedProvenance,
true, null, interactionId, groupInteractionId,
masterInteractionId, SourceType.CSV.name()));
masterInteractionId, SourceType.CSV.name(),null));
} else {
results.add(createOperationOutcomeForError(masterInteractionId, interactionId,
profile.getPatientMrIdValue(), profile.getEncounterId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,6 +27,7 @@
import org.springframework.web.util.ContentCachingRequestWrapper;
import org.springframework.web.util.ContentCachingResponseWrapper;
import org.techbd.conf.Configuration;
import org.techbd.service.constants.SourceType;
import org.techbd.service.http.Interactions.RequestResponseEncountered;
import org.techbd.service.http.hub.prime.AppConfig;
import org.techbd.udi.UdiPrimeJpaConfig;
Expand Down Expand Up @@ -209,6 +211,8 @@ protected void doFilterInternal(final @NonNull HttpServletRequest origRequest,
&& !requestURI.startsWith("/flatfile/csv") && !requestURI.startsWith("/flatfile/csv/")
) {
final var rihr = new RegisterInteractionHttpRequest();
final var requestUriToBeOverridden = origRequest.getHeader("X-TechBD-Override-Request-URI");
final var source = origRequest.getParameter("source");
try {
LOG.info("REGISTER State None : BEGIN for interaction id : {} tenant id : {}",
rre.interactionId().toString(), rre.tenant());
Expand All @@ -219,13 +223,13 @@ protected void doFilterInternal(final @NonNull HttpServletRequest origRequest,
Map.of("nature", RequestResponseEncountered.class.getName(), "tenant_id",
tenant != null ? tenant.tenantId() != null ? tenant.tenantId() : "N/A" : "N/A")));
rihr.setContentType(MimeTypeUtils.APPLICATION_JSON_VALUE);
rihr.setInteractionKey(requestURI);
rihr.setInteractionKey(StringUtils.isNotEmpty(requestUriToBeOverridden) ? requestUriToBeOverridden : requestURI);
rihr.setPayload(Configuration.objectMapper
.readTree(artifact.getJsonString().orElse("no artifact.getJsonString() in " + provenance)));
rihr.setCreatedAt(createdAt); // don't let DB set this, since it might be stored out of order
rihr.setCreatedBy(InteractionsFilter.class.getName());
rihr.setProvenance(provenance);

rihr.setSourceType(StringUtils.isNotEmpty(source)? source : SourceType.FHIR.name());
// User details
if (saveUserDataToInteractions) {
var curUserName = "API_USER";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public Object validateBundleAndForward(
}
</code> """, required = false) @RequestHeader(value = AppConfig.Servlet.HeaderName.Request.FHIR_VALIDATION_STRATEGY, required = false) String uaValidationStrategyJson,
@Parameter(description = "Optional header to specify the Datalake API URL. If not specified, the default URL mentioned in the application configuration will be used.", required = false) @RequestHeader(value = AppConfig.Servlet.HeaderName.Request.DATALAKE_API_URL, required = false) String customDataLakeApi,
@Parameter(description = "Optional header to specify the request URI to override. This parameter is used for requests forwarded from Mirth Connect, where we override it with the initial request URI from Mirth Connect.", required = false)
@RequestHeader(value = "X-TechBD-Override-Request-URI", required = false) String requestUriToBeOverridden,
@Parameter(description = """
Optional header to specify the Datalake API content type.
Value provided with this header will be used to set the <code>Content-Type</code> header while invoking the Datalake API.
Expand Down Expand Up @@ -213,7 +215,7 @@ public Object validateBundleAndForward(
uaValidationStrategyJson,
customDataLakeApi, dataLakeApiContentType, healthCheck, isSync, includeRequestInOutcome,
includeIncomingPayloadInDB,
request, response, provenance, includeOperationOutcome, mtlsStrategy,null, null,null,source);
request, response, provenance, includeOperationOutcome, mtlsStrategy,null, null,null,source,requestUriToBeOverridden);
} finally {
bundleCounter.add(1);
span.end();
Expand Down Expand Up @@ -266,11 +268,14 @@ public Object validateBundle(
@Parameter(description = "Payload for the API. This <b>must not</b> be <code>null</code>.", required = true) final @RequestBody @Nonnull String payload,
@Parameter(description = "Parameter to specify the Tenant ID. This is a <b>mandatory</b> parameter.", required = true) @RequestHeader(value = Configuration.Servlet.HeaderName.Request.TENANT_ID, required = true) String tenantId,
// "profile" is the same name that HL7 validator uses
@Parameter(description = "Optional header to specify the request URI to override. This parameter is used for requests forwarded from Mirth Connect, where we override it with the initial request URI from Mirth Connect.", required = false)
@RequestHeader(value = "X-TechBD-Override-Request-URI", required = false) String requestUriToBeOverridden,
@Parameter(description = "Parameter to specify the profile. This is an optional parameter. If not specified, the default settings mentioned in the application configuration will be used.", required = false) @RequestParam(value = "profile", required = false) String fhirProfileUrlParam,
@Parameter(description = "Optional header to specify the Structure definition profile URL. If not specified, the default settings mentioned in the application configuration will be used.", required = false) @RequestHeader(value = AppConfig.Servlet.HeaderName.Request.FHIR_STRUCT_DEFN_PROFILE_URI, required = false) String fhirProfileUrlHeader,
@Parameter(description = "Optional header to specify the validation strategy. If not specified, the default settings mentioned in the application configuration will be used.", required = false) @RequestHeader(value = AppConfig.Servlet.HeaderName.Request.FHIR_VALIDATION_STRATEGY, required = false) String uaValidationStrategyJson,
@Parameter(description = "Parameter to decide whether the request is to be included in the outcome.", required = false) @RequestParam(value = "include-request-in-outcome", required = false) boolean includeRequestInOutcome,
@Parameter(description = "Optional parameter to decide whether the session cookie (JSESSIONID) should be deleted.", required = false) @RequestParam(value = "delete-session-cookie", required = false) Boolean deleteSessionCookie,
@Parameter(description = "Optional parameter to specify source of the request.", required = false) @RequestParam(value = "source", required = false, defaultValue = "FHIR") String source,
HttpServletRequest request, HttpServletResponse response) {

if (tenantId == null || tenantId.trim().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Object processHl7Message(String hl7Payload, String tenantId, HttpServletR
return fhirService.processBundle(shinnyFhirJson, tenantId, null, null, null, null, null,
Boolean.toString(false), false,
false,
false, request, response, null, true,null,null, null,null,SourceType.HL7.name());
false, request, response, null, true,null,null, null,null,SourceType.HL7.name(),null);
}
}
} catch (Exception ex) {
Expand Down
8 changes: 8 additions & 0 deletions hub-prime/src/main/resources/application-phiprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ org:
cmd: /usr/bin/post-stdin-payload-to-nyec-datalake-qa-endpoint-via-mtls.sh
# Wait time to receive response from scoring engine
timeout: 180
csv:
validation:
pythonScriptPath: ${TECHBD_CSV_PYTHON_SCRIPT_PATH:../support/specifications/flat-file/validate-nyher-fhir-ig-equivalent.py}
pythonExecutable: ${TECHBD_CSV_PYTHON_EXECUTABLE:python3}
packagePath: ${TECHBD_CSV_PACKAGE_PATH:../support/specifications/flat-file/datapackage-nyher-fhir-ig-equivalent.json}
inboundPath: ${TECHBD_CSV_INBOUND_PATH:/app/techbyDesign/flatFile/inbound}
outputPath: ${TECHBD_CSV_INBOUND_PATH:/app/techbyDesign/flatFile/outbound}
ingessHomePath: ${TECHBD_CSV_INGRESS_PATH:/app/techbyDesign/flatFile/ingress}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void shouldProcessPayloadAndPopulatePatients() throws Exception {
OperationOutcome mockOutcome = new OperationOutcome();
when(fhirService.processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(), any(),
anyString(),
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString()))
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString()))
.thenReturn(mockOutcome);
List<Object> result = csvBundleProcessorService.processPayload(masterInteractionId,
payloadAndValidationOutcomes,new ArrayList<>(),
Expand All @@ -130,7 +130,7 @@ void shouldProcessPayloadAndPopulatePatients() throws Exception {
verify(fhirService, times(2)).processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(),
any(),
anyString(), eq(false), eq(false), eq(false), eq(request), eq(response), any(),
eq(true), any(), anyString(), anyString(),anyString(),anyString());
eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString());
}

@Test
Expand Down Expand Up @@ -185,7 +185,7 @@ void shouldProcessPayloadAndPopulatePatientsWithMultipleEncounters() throws Exce
OperationOutcome mockOutcome = new OperationOutcome();
when(fhirService.processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(), any(),
anyString(),
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString()))
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString()))
.thenReturn(mockOutcome);

List<Object> result = csvBundleProcessorService.processPayload(masterInteractionId,
Expand All @@ -199,7 +199,7 @@ void shouldProcessPayloadAndPopulatePatientsWithMultipleEncounters() throws Exce
verify(fhirService, times(2)).processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(),
any(),
anyString(), eq(false), eq(false), eq(false), eq(request), eq(response), any(),
eq(true), any(), anyString(), anyString(),anyString(),anyString());
eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString());
}

@Test
Expand Down Expand Up @@ -245,7 +245,7 @@ void shouldProcessPayloadAndHandleFutureFailures() throws Exception {
OperationOutcome successfulOutcome = new OperationOutcome();
when(fhirService.processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(), any(),
anyString(),
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString()))
eq(false), eq(false), eq(false), eq(request), eq(response), any(), eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString()))
.thenReturn(successfulOutcome)
.thenThrow(new RuntimeException("Mock failure"));
List<Object> result = csvBundleProcessorService.processPayload(masterInteractionId,
Expand All @@ -260,7 +260,7 @@ void shouldProcessPayloadAndHandleFutureFailures() throws Exception {
verify(fhirService, times(2)).processBundle(eq(mockBundle), anyString(), any(), any(), any(), any(),
any(),
anyString(), eq(false), eq(false), eq(false), eq(request), eq(response), any(),
eq(true), any(), anyString(), anyString(),anyString(),anyString());
eq(true), any(), anyString(), anyString(),anyString(),anyString(),anyString());
}

private String getMockBundleJson() {
Expand Down

0 comments on commit a4991d0

Please sign in to comment.