Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor of ReferralRequestMapperTest #938

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.assertj.core.groups.Tuple;
import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.Encounter;
Expand Down Expand Up @@ -568,46 +569,34 @@ void When_MappingReferralRequestReferencedByReferralRequestToExternalDocumentLin
);
final var referralRequest = referralRequests.getFirst();

assertAll(
() -> assertThat(referralRequest.getSupportingInfo())
.hasSize(2),
() -> assertThat(referralRequest.getSupportingInfo().getFirst().getReferenceElement().getResourceType())
.isEqualTo(ResourceType.DocumentReference.name()),
() -> assertThat(referralRequest.getSupportingInfo().getFirst().getReferenceElement().getIdPart())
.isEqualTo("narrative-statement-1"),
() -> assertThat(referralRequest.getSupportingInfo().getLast().getReferenceElement().getResourceType())
.isEqualTo(ResourceType.DocumentReference.name()),
() -> assertThat(referralRequest.getSupportingInfo().getLast().getReferenceElement().getIdPart())
.isEqualTo("narrative-statement-2")
);
assertThat(referralRequest.getSupportingInfo())
.extracting("referenceElement.resourceType", "referenceElement.idPart")
.containsExactly(
Tuple.tuple(ResourceType.DocumentReference.name(), "narrative-statement-1"),
Tuple.tuple(ResourceType.DocumentReference.name(), "narrative-statement-2")
MartinWheelerMT marked this conversation as resolved.
Show resolved Hide resolved
);
}

@Test
void When_ReferralRequestReferencedByMultipleLinkSets_Expect_AllRelatedDocumentReferencesAddedAsSupportingInfo() {
final var expectedSize = 3;
final RCMRMT030101UKEhrExtract ehrExtract = unmarshallEhrExtractElement(
"ehr_extract_with_multiple_request_statement_to_external_document_linksets.xml"
);


final var referralRequests = referralRequestMapper.mapResources(
ehrExtract,
(Patient) new Patient().setId(PATIENT_ID),
List.of(),
PRACTISE_CODE
);
final var referralRequest = referralRequests.getFirst();
assertAll(
() -> assertThat(referralRequest.getSupportingInfo()).hasSize(expectedSize),
() -> assertThat(referralRequest.getSupportingInfo())
.extracting(reference -> reference.getReferenceElement().getIdPart())
.containsExactly(
"narrative-statement-1",
"narrative-statement-2",
"narrative-statement-3"
)
);

assertThat(referralRequests.getFirst().getSupportingInfo())
.extracting("referenceElement.resourceType", "referenceElement.idPart")
.containsExactly(
Tuple.tuple(ResourceType.DocumentReference.name(), "narrative-statement-1"),
Tuple.tuple(ResourceType.DocumentReference.name(), "narrative-statement-2"),
Tuple.tuple(ResourceType.DocumentReference.name(), "narrative-statement-3")
);
}

private RCMRMT030101UKRequestStatement getNestedRequestStatement(RCMRMT030101UKEhrComposition ehrComposition) {
Expand Down