From 7b3fc034554263b99f645058f68b1812551bc231 Mon Sep 17 00:00:00 2001 From: Adrian Clay Date: Tue, 9 Jan 2024 18:41:46 +0000 Subject: [PATCH] Use ehrComposition / author for authoredOn field instead of ehrExtract / availabilityTime --- CHANGELOG.md | 2 ++ .../translator/mapper/ProcedureRequestMapper.java | 15 ++++++--------- .../mapper/ProcedureRequestMapperTest.java | 6 +++--- ...le.xml => ehr_extract_author_time_example.xml} | 3 +++ 4 files changed, 14 insertions(+), 12 deletions(-) rename gp2gp-translator/src/test/resources/xml/ProcedureRequest/{ehr_extract_availability_time_example.xml => ehr_extract_author_time_example.xml} (86%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e3e49ac6..215e156d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), * REST buffer size has been set to 150Mb ### Fixed +* `ProcedureRequestMapper.authoredOn` is no longer populated with `EhrExtract / availabilityTime` as a fallback, + but does use `EhrComposition / author / time` as a fallback instead now. * Fixed issue where mapping failed due to a Referral Request Priority not being found. * Codings are now provided (code, display and system) in `PractionionerRole.code` and `Organization.type` fields, where only the `text` attribute was provided previously. diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapper.java index b59e7ccf7..70d37d622 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapper.java @@ -60,7 +60,7 @@ public ProcedureRequest mapToProcedureRequest( procedureRequest .setStatus(ProcedureRequestStatus.ACTIVE) .setIntent(ProcedureRequestIntent.PLAN) - .setAuthoredOnElement(getAuthoredOn(planStatement.getAvailabilityTime(), ehrExtract, ehrComposition)) + .setAuthoredOnElement(getAuthoredOn(planStatement.getAvailabilityTime(), ehrComposition)) .setOccurrence(getOccurrenceDate(planStatement.getEffectiveTime())) .setSubject(new Reference(patient)) .setMeta(generateMeta(META_PROFILE)) @@ -104,16 +104,13 @@ private Annotation getNote(String text) { return null; } - private DateTimeType getAuthoredOn(TS availabilityTime, RCMRMT030101UK04EhrExtract ehrExtract, - RCMRMT030101UK04EhrComposition ehrComposition) { + private DateTimeType getAuthoredOn(TS availabilityTime, RCMRMT030101UK04EhrComposition ehrComposition) { if (availabilityTime != null && availabilityTime.hasValue()) { return DateFormatUtil.parseToDateTimeType(availabilityTime.getValue()); - } else { - if (ehrComposition.getAvailabilityTime() != null && ehrComposition.getAvailabilityTime().hasValue()) { - return DateFormatUtil.parseToDateTimeType(ehrComposition.getAvailabilityTime().getValue()); - } else if (ehrExtract.getAvailabilityTime() != null && ehrExtract.getAvailabilityTime().hasValue()) { - return DateFormatUtil.parseToDateTimeType(ehrExtract.getAvailabilityTime().getValue()); - } + } else if (ehrComposition.getAvailabilityTime() != null && ehrComposition.getAvailabilityTime().hasValue()) { + return DateFormatUtil.parseToDateTimeType(ehrComposition.getAvailabilityTime().getValue()); + } else if (ehrComposition.hasAuthor() && ehrComposition.getAuthor().hasTime() && ehrComposition.getAuthor().getTime().hasValue()) { + return DateFormatUtil.parseToDateTimeType(ehrComposition.getAuthor().getTime().getValue()); } return null; diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapperTest.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapperTest.java index fcc2dfb77..036a2902f 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapperTest.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/mapper/ProcedureRequestMapperTest.java @@ -177,8 +177,8 @@ public void mapProcedureRequestWithEhrCompositionAvailabilityTime() { } @Test - public void mapProcedureRequestWithEhrExtractAvailabilityTime() { - var ehrExtract = unmarshallCodeElement("ehr_extract_availability_time_example.xml"); + public void mapProcedureRequestWithAuthorTime() { + var ehrExtract = unmarshallCodeElement("ehr_extract_author_time_example.xml"); var planStatement = getPlanStatement(ehrExtract); setUpCodeableConceptMock(); @@ -187,7 +187,7 @@ public void mapProcedureRequestWithEhrExtractAvailabilityTime() { assertFixedValues(planStatement, procedureRequest); assertThat(procedureRequest.getAuthoredOn()).isEqualTo( - DateFormatUtil.parseToDateTimeType(ehrExtract.getAvailabilityTime().getValue()).getValue()); + DateFormatUtil.parseToDateTimeType(getEhrComposition(ehrExtract).getAuthor().getTime().getValue()).getValue()); assertThat(procedureRequest.getCode().getCodingFirstRep().getDisplay()).isEqualTo( planStatement.getCode().getDisplayName()); assertThat(procedureRequest.getContext().getResource().getIdElement().getValue()).isEqualTo(ENCOUNTER_ID); diff --git a/gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_availability_time_example.xml b/gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_author_time_example.xml similarity index 86% rename from gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_availability_time_example.xml rename to gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_author_time_example.xml index b4334cb5d..78c8f3628 100644 --- a/gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_availability_time_example.xml +++ b/gp2gp-translator/src/test/resources/xml/ProcedureRequest/ehr_extract_author_time_example.xml @@ -5,6 +5,9 @@ + +