Skip to content

Commit

Permalink
BFD-3665 adding Samhsa test coverage
Browse files Browse the repository at this point in the history
BFD-3665 adding Samhsa test coverage
some refactor
  • Loading branch information
MahiFentaye committed Jan 23, 2025
1 parent 20e6c99 commit 8c1a10a
Show file tree
Hide file tree
Showing 9 changed files with 2,521 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public List<Coding> getClaimSecurityLevel(String claimId, Class<?> tagClass) {
if (securityTags.isEmpty()) {
Coding coding = new Coding();
coding
.setSystem("http://terminology.hl7.org/CodeSystem/v3-Confidentiality")
.setSystem(TransformerConstants.SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL)
.setCode("N")
.setDisplay("Normal");
securityTagCoding.add(coding);
Expand All @@ -83,20 +83,14 @@ public List<Coding> getClaimSecurityLevel(String claimId, Class<?> tagClass) {
coding
.setSystem(TransformerConstants.SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL)
.setCode(TagCode.R.toString())
.setDisplay("Restricted");
.setDisplay(TagCode.R.getDisplayName());
break;
case _42CFRPart2:
coding
.setSystem(TransformerConstants.SAMHSA_ACT_CODE_SYSTEM_URL)
.setCode(TagCode._42CFRPart2.toString())
.setDisplay("42 CFR Part 2");
.setDisplay(TagCode._42CFRPart2.getDisplayName());
break;

default:
coding
.setSystem(TransformerConstants.SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL)
.setCode("N") // Default to 'Normal' if unrecognized
.setDisplay("Normal");
}
}
securityTagCoding.add(coding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,15 @@ public enum CurrencyIdentifier {
"https://www.hhs.gov/sites/default/files/logo-white-lg.png";

/**
* URL for C4DIC Logo <a href="https://www.hhs.gov/sites/default/files/logo-white-lg.png">C4DIC
* Logo </a>.
* HL7 CodeSystem v3-Confidentiality <a
* href="http://terminology.hl7.org/CodeSystem/v3-Confidentiality"">CodeSystem: </a>.
*/
public static final String SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL =
"http://terminology.hl7.org/CodeSystem/v3-Confidentiality";

/**
* URL for C4DIC Logo <a href="https://www.hhs.gov/sites/default/files/logo-white-lg.png">C4DIC
* Logo </a>.
* HL7 CodeSystem v3-Confidentiality<a
* href="http://terminology.hl7.org/CodeSystem/v3-ActCode">CodeSystem: </a>.
*/
public static final String SAMHSA_ACT_CODE_SYSTEM_URL =
"http://terminology.hl7.org/CodeSystem/v3-ActCode";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gov.cms.bfd.model.rif.samples.StaticRifResourceGroup;
import io.restassured.http.Header;
import io.restassured.http.Headers;
import io.restassured.specification.RequestSpecification;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Path;
Expand Down Expand Up @@ -78,16 +79,34 @@ protected static String getJsonResponseFor(String requestString) {
requestString, new Headers(new Header("Content-Type", "application/json+fhir")));
}

/**
* Gets the json response for the specified endpoint request string and default content type json
* header.
*
* @param requestString the request string
* @param requestSpec the request Spec
* @return the json response for
*/
protected static String getJsonResponseFor(
String requestString, RequestSpecification requestSpec) {
return getJsonResponseFor(
requestString,
new Headers(new Header("Content-Type", "application/json+fhir")),
requestSpec);
}

/**
* Gets the json response for the specified endpoint request string and specified headers.
*
* @param requestString the request string
* @param headers the headers for the request
* @param requestSpec the request Specification
* @return the json response for
*/
protected static String getJsonResponseFor(String requestString, Headers headers) {
protected static String getJsonResponseFor(
String requestString, Headers headers, RequestSpecification requestSpec) {
return given()
.spec(requestAuth)
.spec(requestSpec)
.headers(headers)
.expect()
.log()
Expand All @@ -101,6 +120,17 @@ protected static String getJsonResponseFor(String requestString, Headers headers
.asString();
}

/**
* Gets the json response for the specified endpoint request string and specified headers.
*
* @param requestString the request string
* @param headers the headers for the request
* @return the json response for
*/
protected static String getJsonResponseFor(String requestString, Headers headers) {
return getJsonResponseFor(requestString, headers, requestAuth);
}

/**
* Gets the expected json response directory. These are generated as a point in time comparison
* when we know the responses are in a good state so that the json response tests can regression
Expand Down Expand Up @@ -207,6 +237,16 @@ protected static Beneficiary getSampleABene() {
return ServerTestUtils.get().getFirstBeneficiary(loadedRecords);
}

/**
* Gets the first sample A beneficiary.
*
* @return the first sample A beneficiary
*/
protected static Beneficiary getSampleABeneSamhsa() {
List<Object> loadedRecords = ServerTestUtils.get().loadSampleASamhsaData();
return ServerTestUtils.get().getFirstBeneficiary(loadedRecords);
}

/**
* Gets the first sample A beneficiary.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public static Stream<Arguments> data() {
arguments(
"eobReadInpatient",
(Supplier<String>) EndpointJsonResponseComparatorV2E2E::eobReadInpatient),
arguments(
"eobReadByPatientWithSamhsa",
(Supplier<String>) EndpointJsonResponseComparatorV2E2E::eobReadByPatientWithSamhsa),
arguments(
"eobReadOutpatient",
(Supplier<String>) EndpointJsonResponseComparatorV2E2E::eobReadOutpatient),
Expand Down Expand Up @@ -769,6 +772,27 @@ public static String eobReadInpatient() {
return getJsonResponseFor(baseServerUrl + "/v2/fhir/ExplanationOfBenefit/" + eobId);
}

/**
* Executes a search against the EOB endpoint using an inpatient claim id (based on the sample a
* data) and returns the sorted results.
*
* @return the sorted results
*/
public static String eobReadByPatientWithSamhsa() {
Beneficiary bene = getSampleABeneSamhsa();

String url =
baseServerUrl
+ "/v2/fhir/ExplanationOfBenefit/?patient="
+ bene.getBeneficiaryId()
+ "&_count="
+ 2
+ "&_page="
+ (6);

return getJsonResponseFor(url + bene.getBeneficiaryId(), getRequestAuth(SAMHSA_KEYSTORE));
}

/**
* Executes a search against the EOB endpoint using an outpatient claim id (based on the sample a
* data) and returns the sorted results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public static Stream<Arguments> data() {
arguments(
"eobByPatientIdAll",
(Supplier<String>) EndpointJsonResponseComparatorE2E::eobByPatientIdAll),
arguments(
"eobByPatientIdAllWithSamhsa",
(Supplier<String>) EndpointJsonResponseComparatorE2E::eobByPatientIdAllWithSamhsa),
arguments(
"eobByPatientIdPaged",
(Supplier<String>) EndpointJsonResponseComparatorE2E::eobByPatientIdPaged),
Expand Down Expand Up @@ -575,6 +578,26 @@ public static String eobByPatientIdAll() {
return sortDiagnosisTypes(response, "/entry/3/resource/diagnosis/7/type");
}

/**
* Executes a search against the EOB endpoint using the sample A bene id and returns the sorted
* results.
*
* @return the sorted results
*/
public static String eobByPatientIdAllWithSamhsa() {
Beneficiary beneficiary = getSampleABeneSamhsa();

String url =
baseServerUrl
+ "/v1/fhir/ExplanationOfBenefit/?patient="
+ beneficiary.getBeneficiaryId()
+ "&_count="
+ 2
+ "&_page="
+ (6);
return getJsonResponseFor(url, getRequestAuth(SAMHSA_KEYSTORE));
}

/**
* Executes a search against the EOB endpoint using the sample A bene id and returns the sorted
* results with paging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void testGetClaimSecurityLevelOutpatient() {
type.addCoding().setCode("OUT");

Set<String> mockTags = new HashSet<>();
mockTags.add("NormalTag");
when(entityManager.createQuery(anyString())).thenReturn(query);
when(query.getResultList()).thenReturn(new java.util.ArrayList<>(mockTags));

Expand Down
Loading

0 comments on commit 8c1a10a

Please sign in to comment.