Skip to content

Commit

Permalink
NIAD-1615: PlanStatement displays 'Earliest Recall Date' text when …
Browse files Browse the repository at this point in the history
…`ProcedureRequest.occurrencePeriod` has only a `start` date. (#911)

* NIAD-1615: `ProcedureRequest` displays 'Earliest Recall Date' text when `occurrencePeriod` has only a start date.

Created explict tests to cover the scenarios of when the occurrence period in the input json `ProcedureRequest` resource, contains both and start and an end date, and when it only contains a start date.
Removed test files and related entries in parameterized tests as now covered by the explicit tests.
Updated functionality to only produce the "Earliest Recall Date" text in the XML `ProcedureRequest` when the input json `ProcedureRequest.occurrencePeriod` has both a start and an end date

* NIAD-1615: `ProcedureRequest` displays 'Earliest Recall Date' text when `occurrencePeriod` has only a start date.

Created explict tests to cover the scenarios of when the occurrence period in the input json `ProcedureRequest` resource, contains both and start and an end date, and when it only contains a start date.
Removed test files and related entries in parameterized tests as now covered by the explicit tests.
Updated functionality to only produce the "Earliest Recall Date" text in the XML `ProcedureRequest` when the input json `ProcedureRequest.occurrencePeriod` has both a start and an end date

* NIAD-1615: `ProcedureRequest` displays 'Earliest Recall Date' text when `occurrencePeriod` has only a start date.

Removed the check for `occurrencePeriod.start` when checking if an end time is present as for the type `Period` the `start` property is mandatory
  • Loading branch information
MartinWheelerMT authored Oct 4, 2024
1 parent c73c7d3 commit cd6c775
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 63 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added a scheduled delay checker to update EhrExtract to "Integration Failure" state if sentAt exceeds 8 days and no acknowledgment is received.
* When mapping a `DocumentReference` which contains a `NOPAT` `meta.security` or `NOPAT` `securityLabel` tag the resultant XML for that resource
will contain a `NOPAT` `confidentialityCode` element.

### Fixed

* When mapping `ProcedureRequests` with an `occurrencePeriod` which contains only a start date, then the `text` element
in the resultant XML will no longer contain the superfluous 'Earliest Recall Date: <startDate>' value.

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ private Optional<String> getSupportingInformation(ProcedureRequest procedureRequ
}

private Optional<String> getEarliestRecallDate(ProcedureRequest procedureRequest) {
if (procedureRequest.hasOccurrencePeriod()
&& procedureRequest.getOccurrencePeriod().hasStart()) {
if (procedureRequest.hasOccurrencePeriod() && procedureRequest.getOccurrencePeriod().hasEnd()) {
return Optional.of(formatStartDate(procedureRequest));
}

return Optional.empty();
}


private Optional<String> getRequester(ProcedureRequest procedureRequest) {
Reference agent = procedureRequest.getRequester().getAgent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public class DiaryPlanStatementMapperTest {
private static final String EXPECTED_PLAN_STATEMENT_WITH_PRACTITIONER = TEST_DIRECTORY + "expected-plan-statement-4.xml";
private static final String INPUT_PROCEDURE_REQUEST_WITH_MULTIPLE_REASON_CODES = TEST_DIRECTORY + "procedure-request-resource-5.json";
private static final String EXPECTED_PLAN_STATEMENT_WITH_MULTIPLE_REASON_CODES = TEST_DIRECTORY + "expected-plan-statement-5.xml";
private static final String INPUT_PROCEDURE_REQUEST_WITH_PERIOD_END = TEST_DIRECTORY + "procedure-request-resource-6.json";
private static final String EXPECTED_PLAN_STATEMENT_WITH_PERIOD_END = TEST_DIRECTORY + "expected-plan-statement-6.xml";
private static final String INPUT_PROCEDURE_REQUEST_WITHOUT_PERIOD_END = TEST_DIRECTORY + "procedure-request-resource-7.json";
private static final String EXPECTED_PLAN_STATEMENT_WITHOUT_PERIOD_END = TEST_DIRECTORY + "expected-plan-statement-7.xml";
private static final String EXPECTED_PLAN_STATEMENT_WITH_IS_NESTED = TEST_DIRECTORY + "expected-plan-statement-8.xml";
private static final String INPUT_PROCEDURE_REQUEST_WITHOUT_REQUIRED_AUTHORED_ON = TEST_DIRECTORY + "procedure-request-resource-8.json";
private static final String INPUT_PROCEDURE_REQUEST_SINGLE_REASON_CODE = TEST_DIRECTORY + "procedure-request-resource-9.json";
Expand Down Expand Up @@ -121,6 +117,82 @@ public void When_MappingProcedureRequestWithoutRequiredAuthoredOn_Expect_MapperE
-> diaryPlanStatementMapper.mapDiaryProcedureRequestToPlanStatement(inputProcedureRequest, true));
}

@Test
public void When_MappingWithOccurrenceWithStartAndEnd_Expect_TextContainsEarliestRecallDateOfStartAndEffectiveTimeOfEnd() {
var inputJson = """
{
"resourceType": "ProcedureRequest",
"id": "1B1C6F50-D8BE-4480-83D6-EF25AC5F1836",
"status": "active",
"intent": "plan",
"authoredOn": "2010-01-13T15:29:50.1+00:00",
"occurrencePeriod": {
"start": "2010-01-13",
"end": "2010-01-15"
},
"code": {
"text": "test"
}
}""";

final var expectedXml = """
<component typeCode="COMP" >
<PlanStatement classCode="OBS" moodCode="INT">
<id root="394559384658936" />
<code nullFlavor="UNK"><originalText>Mocked code</originalText></code>
<text>
Earliest Recall Date: 2010-01-13
</text>
<statusCode code="COMPLETE" />
<effectiveTime>
<center value="20100115"/>
</effectiveTime>
<availabilityTime value="20100113152950"/>
</PlanStatement>
</component>""";

final var procedureRequest = new FhirParseService().parseResource(inputJson, ProcedureRequest.class);
var actualXml = diaryPlanStatementMapper.mapDiaryProcedureRequestToPlanStatement(procedureRequest, false);

assertThat(actualXml).isEqualTo(expectedXml);
}

@Test
public void When_MappingWithOccurrenceWithOnlyStart_Expect_TextDoesNotContainEarliestRecallDateAndEffectiveTimeOfStart() {
var inputJson = """
{
"resourceType": "ProcedureRequest",
"id": "1B1C6F50-D8BE-4480-83D6-EF25AC5F1836",
"status": "active",
"intent": "plan",
"authoredOn": "2010-01-13T15:29:50.1+00:00",
"occurrencePeriod": {
"start": "2010-01-13"
},
"code": {
"text": "test"
}
}""";

final var expectedXml = """
<component typeCode="COMP" >
<PlanStatement classCode="OBS" moodCode="INT">
<id root="394559384658936" />
<code nullFlavor="UNK"><originalText>Mocked code</originalText></code>
<statusCode code="COMPLETE" />
<effectiveTime>
<center value="20100113"/>
</effectiveTime>
<availabilityTime value="20100113152950"/>
</PlanStatement>
</component>""";

final var procedureRequest = new FhirParseService().parseResource(inputJson, ProcedureRequest.class);
var actualXml = diaryPlanStatementMapper.mapDiaryProcedureRequestToPlanStatement(procedureRequest, false);

assertThat(actualXml).isEqualTo(expectedXml);
}

@ParameterizedTest
@MethodSource("testData")
public void When_MappingProcedureRequest_Expect_ResourceMapped(String inputJsonPath, String expectedXmlPath) throws IOException {
Expand All @@ -140,8 +212,6 @@ private static Stream<Arguments> testData() {
Arguments.of(INPUT_PROCEDURE_REQUEST_WITH_DEVICE, EXPECTED_PLAN_STATEMENT_WITH_DEVICE),
Arguments.of(INPUT_PROCEDURE_REQUEST_WITH_PRACTITIONER, EXPECTED_PLAN_STATEMENT_WITH_PRACTITIONER),
Arguments.of(INPUT_PROCEDURE_REQUEST_WITH_MULTIPLE_REASON_CODES, EXPECTED_PLAN_STATEMENT_WITH_MULTIPLE_REASON_CODES),
Arguments.of(INPUT_PROCEDURE_REQUEST_WITH_PERIOD_END, EXPECTED_PLAN_STATEMENT_WITH_PERIOD_END),
Arguments.of(INPUT_PROCEDURE_REQUEST_WITHOUT_PERIOD_END, EXPECTED_PLAN_STATEMENT_WITHOUT_PERIOD_END),
Arguments.of(INPUT_PROCEDURE_REQUEST_SINGLE_REASON_CODE, EXPECTED_PROCEDURE_REQUEST_SINGLE_REASON_CODE),
Arguments.of(INPUT_JSON_WITH_SINGLE_SUPPORTING_INFO, OUTPUT_JSON_WITH_SINGLE_SUPPORTING_INFO),
Arguments.of(INPUT_JSON_WITH_MULTIPLE_SUPPORTING_INFO, OUTPUT_JSON_WITH_MULTIPLE_SUPPORTING_INFO)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit cd6c775

Please sign in to comment.