Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed Nov 14, 2023
1 parent a534ca0 commit 8ee5be3
Show file tree
Hide file tree
Showing 11 changed files with 1,504 additions and 1,381 deletions.
2,712 changes: 1,360 additions & 1,352 deletions backend/src/main/java/gov/cdc/usds/simplereport/api/converter/FhirConverter.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ public TestEventExport(TestEvent testEvent, String processingModeCode) {
}

private String genderUnknown = "U";
private static final String DEFAULT_LOCATION_CODE = "53342003"; // http://snomed.info/id/53342003
public static final String DEFAULT_LOCATION_CODE = "53342003"; // http://snomed.info/id/53342003
// "Internal nose structure"
// values pulled from
// https://github.com/CDCgov/prime-data-hub/blob/master/prime-router/metadata/valuesets/common.valuesets

public static final String DEFAULT_LOCATION_NAME =
"Internal nose structure (body structure)"; // http://snomed.info/id/53342003

private final Map<String, String> genderMap =
Map.of(
"male", "M",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gov.cdc.usds.simplereport.api.converter;

import static gov.cdc.usds.simplereport.api.converter.FhirConstants.NOTE_TYPE_EXTENSION_URL;
import static gov.cdc.usds.simplereport.api.model.TestEventExport.DEFAULT_LOCATION_CODE;
import static gov.cdc.usds.simplereport.api.model.TestEventExport.DEFAULT_LOCATION_NAME;
import static gov.cdc.usds.simplereport.api.model.TestEventExport.UNKNOWN_ADDRESS_INDICATOR;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.from;
Expand Down Expand Up @@ -588,8 +590,8 @@ void convertToSpecimen_Strings_valid() {
ConvertToSpecimenProps.builder()
.specimenCode("258500001")
.specimenName("Nasopharyngeal swab")
.collectionCode("53342003")
.collectionName("Internal nose structure (body structure)")
.collectionCode("53342003 but not the default one")
.collectionName("Internal nose structure (body structure) but not the default one")
.id("id-123")
.identifier("uuid-123")
.collectionDate(collectionDate)
Expand All @@ -607,9 +609,9 @@ void convertToSpecimen_Strings_valid() {
assertThat(actual.getCollection().getBodySite().getCodingFirstRep().getSystem())
.isEqualTo(snomedCode);
assertThat(actual.getCollection().getBodySite().getCodingFirstRep().getCode())
.isEqualTo("53342003");
.isEqualTo("53342003 but not the default one");
assertThat(actual.getCollection().getBodySite().getText())
.isEqualTo("Internal nose structure (body structure)");
.isEqualTo("Internal nose structure (body structure) but not the default one");
assertThat(((DateTimeType) actual.getCollection().getCollected()).getValue())
.isEqualTo("2023-06-22T16:38:00Z");
}
Expand All @@ -621,8 +623,9 @@ void convertToSpecimen_Strings_null() {
assertThat(actual.getId()).isNull();
assertThat(actual.getType().getText()).isNull();
assertThat(actual.getType().getCoding()).isEmpty();
assertThat(actual.getCollection().getBodySite().getText()).isNull();
assertThat(actual.getCollection().getBodySite().getCoding()).isEmpty();
assertThat(actual.getCollection().getBodySite().getText()).isEqualTo(DEFAULT_LOCATION_NAME);
assertThat(actual.getCollection().getBodySite().getCodingFirstRep().getCode())
.isEqualTo(DEFAULT_LOCATION_CODE);
assertThat(actual.getCollection().getCollected()).isNull();
assertThat(actual.getReceivedTime()).isNull();
}
Expand Down Expand Up @@ -668,7 +671,7 @@ void convertToSpecimen_SpecimenType_valid() {
@Test
void convertToSpecimen_SpecimenType_matchesJson() throws IOException {
var internalId = "3c9c7370-e2e3-49ad-bb7a-f6005f41cf29";
SpecimenType specimenType = new SpecimenType("nasal", "40001", "nose", "10101");
SpecimenType specimenType = new SpecimenType("nasal", "40001");
ReflectionTestUtils.setField(specimenType, "internalId", UUID.fromString(internalId));

var actual =
Expand Down
9 changes: 9 additions & 0 deletions backend/src/test/resources/fhir/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,15 @@
},
"receivedTime": "2023-07-14T15:45:34+00:00",
"collection": {
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
},
"collectedDateTime": "2023-07-14T15:45:34+00:00"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@
},
"receivedTime": "2023-07-10T08:51:00-04:00",
"collection": {
"collectedDateTime": "2023-07-10T08:51:00-04:00"
"collectedDateTime": "2023-07-10T08:51:00-04:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -1165,7 +1174,16 @@
},
"receivedTime": "2021-12-21T17:00:00-05:00",
"collection": {
"collectedDateTime": "2021-12-21T17:00:00-05:00"
"collectedDateTime": "2021-12-21T17:00:00-05:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -1712,7 +1730,16 @@
},
"receivedTime": "2021-12-21T15:00:00-05:00",
"collection": {
"collectedDateTime": "2021-12-21T15:00:00-05:00"
"collectedDateTime": "2021-12-21T15:00:00-05:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -2303,7 +2330,16 @@
},
"receivedTime": "2022-01-05T12:00:00-05:00",
"collection": {
"collectedDateTime": "2022-01-05T12:00:00-05:00"
"collectedDateTime": "2022-01-05T12:00:00-05:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -2850,7 +2886,16 @@
},
"receivedTime": "2022-01-05T12:00:00-05:00",
"collection": {
"collectedDateTime": "2022-01-05T12:00:00-05:00"
"collectedDateTime": "2022-01-05T12:00:00-05:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down
8 changes: 4 additions & 4 deletions backend/src/test/resources/fhir/specimen.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"coding": [
{
"system": "http://snomed.info/sct",
"code": "10101"
"code": "53342003"
}
],
"text": "nose"
"text": "Internal nose structure (body structure)"
},
"collectedDateTime":"2023-06-22T11:35:00-04:00"
"collectedDateTime": "2023-06-22T11:35:00-04:00"
},
"receivedTime":"2023-06-23T12:00:00-04:00",
"receivedTime": "2023-06-23T12:00:00-04:00",
"identifier": [
{
"value": "$SPECIMEN_IDENTIFIER"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@
},
"receivedTime": "2021-12-22T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-21T14:00:00-06:00"
"collectedDateTime": "2021-12-21T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -1169,7 +1178,16 @@
},
"receivedTime": "2021-12-22T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-21T14:00:00-06:00"
"collectedDateTime": "2021-12-21T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@
},
"receivedTime": "2021-12-20T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-20T14:00:00-06:00"
"collectedDateTime": "2021-12-20T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@
},
"receivedTime": "2021-12-22T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-21T14:00:00-06:00"
"collectedDateTime": "2021-12-21T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down Expand Up @@ -1169,7 +1178,16 @@
},
"receivedTime": "2021-12-22T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-21T14:00:00-06:00"
"collectedDateTime": "2021-12-21T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,16 @@
},
"receivedTime": "2021-12-22T14:00:00-06:00",
"collection": {
"collectedDateTime": "2021-12-21T14:00:00-06:00"
"collectedDateTime": "2021-12-21T14:00:00-06:00",
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "53342003"
}
],
"text": "Internal nose structure (body structure)"
}
}
}
},
Expand Down
Loading

0 comments on commit 8ee5be3

Please sign in to comment.