Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Commit

Permalink
Merge branch 'story/1001/stg-db-connections' of https://github.com/CD…
Browse files Browse the repository at this point in the history
…Cgov/trusted-intermediary into story/1001/stg-db-connections
  • Loading branch information
saquino0827 committed May 16, 2024
2 parents 21d7cce + d044e35 commit b23e029
Show file tree
Hide file tree
Showing 28 changed files with 395 additions and 330 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ running...
```

This will run the API for you, so no need to run it manually.
**If you are already running the API, stop it before running the load tests or the cleanup steps won't work.**
The load tests will also spin up (and clean up) a local test DB on port 5434 that should not interfere with the local dev DB.

The `locustfile.py` that specifies the load test is located at
[`./operations/locustfile.py`](./operations/locustfile.py).
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.postgres-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.7"

services:
postgresql-test:
image: postgres:16
restart: unless-stopped
environment:
POSTGRES_DB: "intermediary-test"
POSTGRES_PASSWORD: "changeIT!" # pragma: allowlist secret
POSTGRES_USER: "intermediary"
ports:
- 5434:5432
volumes:
- ti_postgres_test_data:/var/lib/postgresql/data

volumes:
ti_postgres_test_data:
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,23 @@ DomainResponse handleResults(DomainRequest request) {
DomainResponse handleMetadata(DomainRequest request) {
try {
String metadataId = request.getPathParams().get("id");
Optional<PartnerMetadata> metadata =
Optional<PartnerMetadata> metadataOptional =
partnerMetadataOrchestrator.getMetadata(metadataId);

if (metadata.isEmpty()) {
if (metadataOptional.isEmpty()) {
return domainResponseHelper.constructErrorResponse(
404, "Metadata not found for ID: " + metadataId);
}

var metadata = metadataOptional.get();

Set<String> messageIdsToLink =
partnerMetadataOrchestrator.findMessagesIdsToLink(metadataId);
partnerMetadataOrchestrator.findMessagesIdsToLink(
metadata.receivedSubmissionId());

FhirMetadata<?> responseObject =
partnerMetadataConverter.extractPublicMetadataToOperationOutcome(
metadata.get(), metadataId, messageIdsToLink);
metadata, metadataId, messageIdsToLink);

return domainResponseHelper.constructOkResponseFromString(
fhir.encodeResourceToJson(responseObject.getUnderlyingOutcome()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.CustomFhirTransformation;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrderConverterHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiHelper;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.util.List;
import java.util.Map;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Patient;

/** Custom transformation to add a contact section to a patient resource. */
public class addContactSectionToPatientResource implements CustomFhirTransformation {
Expand All @@ -18,7 +21,30 @@ public class addContactSectionToPatientResource implements CustomFhirTransformat
@Override
public void transform(FhirResource<?> resource, Map<String, String> args) {
Bundle bundle = (Bundle) resource.getUnderlyingResource();
HapiOrderConverterHelper.addContactSectionToPatientResource(bundle);

HapiHelper.resourcesInBundle(bundle, Patient.class)
.forEach(
p -> {
var myContact = p.addContact();
var motherRelationship = myContact.addRelationship();
motherRelationship.setCoding(
List.of(
new Coding(
"http://terminology.hl7.org/CodeSystem/v3-RoleCode",
"MTH",
"mother")));

var mothersMaidenNameExtension =
p.getExtensionByUrl(
"http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
if (mothersMaidenNameExtension != null) {
myContact.setName(
p.castToHumanName(mothersMaidenNameExtension.getValue()));
}
myContact.setTelecom(p.getTelecom());
myContact.setAddress(p.getAddressFirstRep());
});

metadata.put(bundle.getId(), EtorMetadataStep.CONTACT_SECTION_ADDED_TO_PATIENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.CustomFhirTransformation;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiMessageConverterHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiHelper;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.util.Map;
import org.hl7.fhir.r4.model.Bundle;
Expand All @@ -18,7 +18,13 @@ public class addEtorProcessingTag implements CustomFhirTransformation {
@Override
public void transform(FhirResource<?> resource, Map<String, String> args) {
Bundle bundle = (Bundle) resource.getUnderlyingResource();
HapiMessageConverterHelper.addEtorTagToBundle(bundle);

var system = "http://localcodes.org/ETOR";
var code = "ETOR";
var display = "Processed by ETOR";

HapiHelper.addMetaTag(bundle, system, code, display);

metadata.put(bundle.getId(), EtorMetadataStep.ETOR_PROCESSING_TAG_ADDED_TO_MESSAGE_HEADER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gov.hhs.cdc.trustedintermediary.etor.metadata.EtorMetadataStep;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.FhirResource;
import gov.hhs.cdc.trustedintermediary.etor.ruleengine.transformation.CustomFhirTransformation;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiOrderConverterHelper;
import gov.hhs.cdc.trustedintermediary.external.hapi.HapiHelper;
import gov.hhs.cdc.trustedintermediary.wrappers.MetricMetadata;
import java.util.Map;
import org.hl7.fhir.r4.model.Bundle;
Expand All @@ -18,7 +18,7 @@ public class convertToOmlOrder implements CustomFhirTransformation {
@Override
public void transform(FhirResource<?> resource, Map<String, String> args) {
Bundle bundle = (Bundle) resource.getUnderlyingResource();
HapiOrderConverterHelper.convertToOmlOrder(bundle);
HapiHelper.setMessageTypeCoding(bundle, HapiHelper.OML_CODING);
metadata.put(bundle.getId(), EtorMetadataStep.ORDER_CONVERTED_TO_OML);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gov.hhs.cdc.trustedintermediary.external.hapi;

import gov.hhs.cdc.trustedintermediary.plugin.path.FhirPath;
import gov.hhs.cdc.trustedintermediary.plugin.path.Hl7FhirMappingPath;
import gov.hhs.cdc.trustedintermediary.wrappers.HapiFhir;
import javax.inject.Inject;
import org.hl7.fhir.r4.model.Bundle;
Expand All @@ -24,66 +24,69 @@ private HapiMessageHelper() {}

public String extractPlacerOrderNumber(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.PLACER_ORDER_NUMBER.getPath());
messageBundle, Hl7FhirMappingPath.PLACER_ORDER_NUMBER.getFhirPath());
}

public String extractSendingApplicationNamespace(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_APPLICATION_NAMESPACE.getPath());
messageBundle, Hl7FhirMappingPath.SENDING_APPLICATION_NAMESPACE.getFhirPath());
}

public String extractSendingApplicationUniversalId(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_APPLICATION_UNIVERSAL_ID.getPath());
messageBundle, Hl7FhirMappingPath.SENDING_APPLICATION_UNIVERSAL_ID.getFhirPath());
}

public String extractSendingApplicationUniversalIdType(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_APPLICATION_UNIVERSAL_ID_TYPE.getPath());
messageBundle,
Hl7FhirMappingPath.SENDING_APPLICATION_UNIVERSAL_ID_TYPE.getFhirPath());
}

public String extractSendingFacilityNamespace(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_FACILITY_NAMESPACE.getPath());
messageBundle, Hl7FhirMappingPath.SENDING_FACILITY_NAMESPACE.getFhirPath());
}

public String extractSendingFacilityUniversalId(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_FACILITY_UNIVERSAL_ID.getPath());
messageBundle, Hl7FhirMappingPath.SENDING_FACILITY_UNIVERSAL_ID.getFhirPath());
}

public String extractSendingFacilityUniversalIdType(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.SENDING_FACILITY_UNIVERSAL_ID_TYPE.getPath());
messageBundle, Hl7FhirMappingPath.SENDING_FACILITY_UNIVERSAL_ID_TYPE.getFhirPath());
}

public String extractReceivingApplicationNamespace(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_APPLICATION_NAMESPACE.getPath());
messageBundle, Hl7FhirMappingPath.RECEIVING_APPLICATION_NAMESPACE.getFhirPath());
}

public String extractReceivingApplicationUniversalId(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_APPLICATION_UNIVERSAL_ID.getPath());
messageBundle, Hl7FhirMappingPath.RECEIVING_APPLICATION_UNIVERSAL_ID.getFhirPath());
}

public String extractReceivingApplicationUniversalIdType(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_APPLICATION_UNIVERSAL_ID_TYPE.getPath());
messageBundle,
Hl7FhirMappingPath.RECEIVING_APPLICATION_UNIVERSAL_ID_TYPE.getFhirPath());
}

public String extractReceivingFacilityNamespace(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_FACILITY_NAMESPACE.getPath());
messageBundle, Hl7FhirMappingPath.RECEIVING_FACILITY_NAMESPACE.getFhirPath());
}

public String extractReceivingFacilityUniversalId(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_FACILITY_UNIVERSAL_ID.getPath());
messageBundle, Hl7FhirMappingPath.RECEIVING_FACILITY_UNIVERSAL_ID.getFhirPath());
}

public String extractReceivingFacilityUniversalIdType(Bundle messageBundle) {
return fhirEngine.getStringFromFhirPath(
messageBundle, FhirPath.RECEIVING_FACILITY_UNIVERSAL_ID_TYPE.getPath());
messageBundle,
Hl7FhirMappingPath.RECEIVING_FACILITY_UNIVERSAL_ID_TYPE.getFhirPath());
}
}

This file was deleted.

Loading

0 comments on commit b23e029

Please sign in to comment.