diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java index af01b1b02..06dafaeeb 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/AgentDirectoryMapper.java @@ -63,7 +63,7 @@ public List mapAgentDirectory(RCMRMT030101UK04AgentDir return agentResources; } - return null; + return List.of(); } private void mapAgent(RCCTMT120101UK01Agent agent, List agentResourceList) { diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/DocumentReferenceMapper.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/DocumentReferenceMapper.java index f69c40f96..e1276595c 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/DocumentReferenceMapper.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/mapper/DocumentReferenceMapper.java @@ -238,6 +238,6 @@ private Integer getAttachmentSize(List patientAttachmentLo // stubbed method for abstract class public List mapResources(RCMRMT030101UK04EhrExtract ehrExtract, Patient patient, List encounterList, String practiseCode) { - return null; + return List.of(); } } diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageService.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageService.java index baa09e000..81e19f2fb 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageService.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/storage/AzureStorageService.java @@ -82,23 +82,21 @@ private BlockBlobClient createBlobBlockClient(String filename) { } private void addFileStringToMainContainer(String filename, byte[] fileAsString) throws StorageException, IOException { - try { + try (InputStream dataStream = new ByteArrayInputStream(fileAsString)) { BlockBlobClient blobClient = createBlobBlockClient(filename); - InputStream dataStream = new ByteArrayInputStream(fileAsString); blobClient.upload(dataStream, fileAsString.length); - dataStream.close(); } catch (IOException e) { throw new StorageException("Failed to upload blob to Azure Blob storage", e); } } private ByteArrayOutputStream downloadFileToStream(String filename) throws StorageException { - try { - BlockBlobClient blobClient = createBlobBlockClient(filename); - int dataSize = (int) blobClient.getProperties().getBlobSize(); - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize); + + BlockBlobClient blobClient = createBlobBlockClient(filename); + int dataSize = (int) blobClient.getProperties().getBlobSize(); + + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(dataSize)) { blobClient.downloadStream(outputStream); - outputStream.close(); return outputStream; } catch (IOException e) { throw new StorageException("Failed to download blob from Azure Blob storage", e); diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ObservationUtil.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ObservationUtil.java index 500e9f007..513f4cf65 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ObservationUtil.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ObservationUtil.java @@ -138,10 +138,8 @@ public static Object getEffective(IVLTS effectiveTime, TS availabilityTime) { effectivePeriod.setEndElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getHigh().getValue())); } - if (availabilityTimeHasValue(availabilityTime) && effectivePeriod.getStart() == null) { - if (effectivePeriod.getEnd() != null) { - effectivePeriod.setStartElement(DateFormatUtil.parseToDateTimeType(availabilityTime.getValue())); - } + if (availabilityTimeHasValue(availabilityTime) && effectivePeriod.getStart() == null && effectivePeriod.getEnd() != null) { + effectivePeriod.setStartElement(DateFormatUtil.parseToDateTimeType(availabilityTime.getValue())); } if (effectivePeriod.hasStart() || effectivePeriod.hasEnd()) { diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ResourceReferenceUtil.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ResourceReferenceUtil.java index 0afabe033..40ceb26c0 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ResourceReferenceUtil.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ResourceReferenceUtil.java @@ -4,8 +4,6 @@ import static uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil.isBloodPressure; import static uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil.isDiagnosticReport; import static uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil.isDocumentReference; -import static uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil.isTemplate; - import java.util.List; import org.hl7.fhir.dstu3.model.IdType; @@ -57,14 +55,6 @@ public void extractChildReferencesFromCompoundStatement(RCMRMT030101UK04Compound addDiagnosticReportEntry(compoundStatement, entryReferences); } else { - // NIAD_2190 the section below appears to be for Questionnaire Response links and the observation - // created that goes with it. Since Questionnaires have been removed, the contents of the addTemplateEntry function has - // been commented out while it is tested more in depth. It can be removed following the effect investigation - // - Scott Alexander 21072022 - if (isTemplate(compoundStatement)) { - addTemplateEntry(compoundStatement, entryReferences); - } - compoundStatement.getComponent().forEach(component -> { addObservationStatementEntry( component.getObservationStatement(), entryReferences, compoundStatement); @@ -108,14 +98,6 @@ private static boolean isNotIgnoredResource(RCMRMT030101UK04CompoundStatement co || !references.contains(OBSERVATION_REFERENCE.formatted(compoundStatement.getId().get(0).getRoot())); } - private static void addTemplateEntry(RCMRMT030101UK04CompoundStatement compoundStatement, - List entryReferences) { -// entryReferences.add(createResourceReference(ResourceType.QuestionnaireResponse.name(), -// QUESTIONNAIRE_ID.formatted(compoundStatement.getId().get(0).getRoot()))); -// entryReferences.add(createResourceReference(ResourceType.Observation.name(), -// compoundStatement.getId().get(0).getRoot())); - } - private void addObservationStatementEntry(RCMRMT030101UK04ObservationStatement observationStatement, List entryReferences, RCMRMT030101UK04CompoundStatement compoundStatement) { if (observationStatement != null && isNotIgnoredResource(compoundStatement, entryReferences)) {