Skip to content

Commit 4da233e

Browse files
Adding basic test case
This is not complete as it: a) does no ID checking for the dummy specimen b) we do not yet verify that a result has a link to specimen, we just check that there is a specimen and result in a diagnostic report
1 parent 48c16b7 commit 4da233e

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

service/src/test/java/uk/nhs/adaptors/gp2gp/ehr/mapper/diagnosticreport/DiagnosticReportMapperTest.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public void setUp() throws IOException {
115115
when(idMapper.getOrNew(any(ResourceType.class), any(IdType.class))).thenAnswer(mockIdForResourceAndId());
116116
when(agentDirectory.getAgentId(any(Reference.class))).thenAnswer(mockIdForReference());
117117
when(randomIdGeneratorService.createNewId()).thenReturn(TEST_ID);
118+
when(specimenMapper.mapSpecimenToCompoundStatement(any(Specimen.class), anyList(), any(DiagnosticReport.class)))
119+
.thenAnswer(mockSpecimenMapping());
118120
when(codeableConceptCdMapper.mapCodeableConceptToCd(any(CodeableConcept.class)))
119121
.thenReturn(CodeableConceptMapperMockUtil.NULL_FLAVOR_CODE);
120122

@@ -290,28 +292,20 @@ void When_DiagnosticReport_With_NoReferencedSpecimenAndFilingCommentWithNoCommen
290292
}
291293

292294
/**
293-
* TODO
294-
*
295-
* It makes no sense whatsoever to place any logic within the SpecimenMapper - what we care
296-
* about here is a DiagnosticReport with a Test Result (Observation). If the Observation has
297-
* a related specimen - then this should be picked up by the SpecimenMapper.
298-
*
299-
* If there is an Observation (Test Result) WITHOUT a Specimen, then this I think should be handled
300-
* within the ObservationMapper.
295+
* A Diagnosis Report may have an Observation (Test Result) and Specimen. If the result and specimen are not
296+
* linked then we need to create a dummy specimen linked to the result.
301297
*/
302-
303298
@Test
304-
void When_DiagnosticReport_With_SpecimenAndTestResultWithNoSpecimen_Expect_TestResultDataToBePresentWithinObservationStatement() {
305-
final String diagnosticReportFileName = "diagnostic-report-with-one-specimen-and-test-result-with-no-specimen.json";
299+
void When_DiagnosticReport_Has_SpecimenAndUnlinkedTestResult_ExpectADummySpecimenLinkedToTestResult() {
300+
final String diagnosticReportFileName = "diagnostic-report-with-one-specimen-and-one-unrelated-observation.json";
306301
final DiagnosticReport diagnosticReport = getDiagnosticReportResourceFromJson(diagnosticReportFileName);
307302
final Bundle bundle = getBundleResourceFromJson(INPUT_JSON_BUNDLE);
308303
final InputBundle inputBundle = new InputBundle(bundle);
309304

310305
when(messageContext.getInputBundleHolder()).thenReturn(inputBundle);
311306

312307
final String actualXml = mapper.mapDiagnosticReportToCompoundStatement(diagnosticReport);
313-
314-
assertThat(actualXml).contains("ObservationStatement");
308+
assertThat(actualXml).contains("Mapped Specimen with id: DUMMY-SPECIMEN-");
315309
}
316310

317311
private Bundle getBundleResourceFromJson(String filename) {

service/src/test/resources/ehr/mapper/diagnosticreport/diagnostic-report-with-one-specimen-and-one-unrelated-observation.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ Status: unknown</text>
2121
</NarrativeStatement>
2222
</component>
2323
<!-- Mapped Specimen with id: Specimen/96B93E28-293D-46E7-B4C2-D477EEBF7098-SPEC-0 -->
24-
<!-- Mapped Observation with id: Observation/AD373CA7-3940-4249-85A2-D3A22E9F17C7 -->
24+
<!-- Mapped Specimen with id: DUMMY-SPECIMEN-5E496953-065B-41F2-9577-BE8F2FBD0757 -->
2525
</CompoundStatement>
2626
</component>

0 commit comments

Comments
 (0)