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

NAID-3122 - Add confidentialityCode support to AllergyIntoleranceMapper.java #684

Merged
merged 37 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
bc81bbb
[NIAD-3122] Add Predicate to ObservationUtil.java
martin-nhs Jul 1, 2024
3412917
[NIAD-3122] Add initial mapping logic
martin-nhs Jul 1, 2024
4048e51
[NIAD-3122] Add initial mapping logic
martin-nhs Jul 1, 2024
e5e2e2d
[NIAD-3122] Add CodingFactory.java
martin-nhs Jul 1, 2024
e0ccec5
[NIAD-3122] Add comment
martin-nhs Jul 1, 2024
5031d45
[NIAD-3122] Refactor ResourceUtil.java
martin-nhs Jul 1, 2024
baabb6c
[NIAD-3122] Refactor ResourceUtil.java
martin-nhs Jul 1, 2024
474ead4
[NIAD-3122] Refactor ResourceUtil.java
martin-nhs Jul 1, 2024
d8180ad
[NIAD-3122] Refactor ResourceUtil.java
martin-nhs Jul 1, 2024
d627092
[NIAD-3122] Add unit tests
martin-nhs Jul 2, 2024
e2be282
[NIAD-3122] Refactor unit tests
martin-nhs Jul 2, 2024
539e038
[NIAD-3122] Refactor unit tests
martin-nhs Jul 2, 2024
a0e927f
[NIAD-3122] Update CHANGELOG.md
martin-nhs Jul 2, 2024
489e9f8
Merge branch 'main' into NIAD-3122
martin-nhs Jul 2, 2024
3d5eaca
[NIAD-3122] Address Checkstyle violations
martin-nhs Jul 2, 2024
73c5b51
[NIAD-3122] Added unit test and refactored names
martin-nhs Jul 2, 2024
2adf5de
[NIAD-3122] Added util
martin-nhs Jul 2, 2024
74707fa
[NIAD-3122] Refactor unit test
martin-nhs Jul 2, 2024
f987daa
[NIAD-3122] Refactor resource util
martin-nhs Jul 2, 2024
81b1d54
[NIAD-3122] Refactor AllergyIntoleranceMapper.java
martin-nhs Jul 2, 2024
e94ca54
[NIAD-3122] Refactor method name
martin-nhs Jul 2, 2024
9d06ea3
[NIAD-3122] Removed unused predicate
martin-nhs Jul 2, 2024
0834fe8
[NIAD-3122] Refactored ObservationUtil.java
martin-nhs Jul 2, 2024
71216c8
[NIAD-3122] Removed CodingFactory.java
martin-nhs Jul 2, 2024
7b68ab0
[NIAD-3122] Refactor ConfidentialityUtil.java
martin-nhs Jul 2, 2024
b9955d3
[NIAD-3122] Refactor unit tests
martin-nhs Jul 2, 2024
54df5ac
[NIAD-3122] Add enhancement, add unit tests
martin-nhs Jul 2, 2024
9204ff1
[NIAD-3122] Add unit test for ConfidentialityUtilTest.java
martin-nhs Jul 3, 2024
b818277
[NIAD-3122] Add fluent api for interacting with meta
martin-nhs Jul 3, 2024
6481b08
[NIAD-3122] Remove unnecessary refactor
martin-nhs Jul 3, 2024
0258ca0
[NIAD-3122] Refactor ConfidentialityUtilTest.java
martin-nhs Jul 3, 2024
c105f9f
[NIAD-3122] Address Checkstyle violations
martin-nhs Jul 3, 2024
9db6db0
Merge branch 'main' into NIAD-3122
martin-nhs Jul 3, 2024
1f6fe39
[NIAD-3122] Address Spotbugs issue, add enhancements.
martin-nhs Jul 3, 2024
f7c68e8
[NIAD-3122] Remove unused import
martin-nhs Jul 3, 2024
0e9e21a
[NIAD-3122] Address PR comment https://github.com/NHSDigital/nia-pati…
martin-nhs Jul 3, 2024
96c9a28
[NIAD-3122] Address checkstyle violations
martin-nhs Jul 3, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added
* The AllergyIntoleranceMapper has been enhanced to support the redaction fix. If an Allergy Intolerance record includes a confidentialityCode, the meta.security field of the corresponding FHIR resource will now be appropriately populated.

## [3.0.0] - 2024-07-02

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.Encounter;
import org.hl7.fhir.dstu3.model.Extension;
import org.hl7.fhir.dstu3.model.Meta;
import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.v3.CD;
Expand All @@ -40,6 +41,7 @@
import lombok.RequiredArgsConstructor;
import uk.nhs.adaptors.pss.translator.util.DegradedCodeableConcepts;
import uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil;
import uk.nhs.adaptors.pss.translator.util.builder.MetaBuilder;

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
Expand Down Expand Up @@ -88,14 +90,21 @@ private AllergyIntolerance mapAllergyIntolerance(RCMRMT030101UKEhrComposition eh
.getId()
.getRoot();

final Meta meta = new MetaBuilder()
.withInitialMeta(() -> generateMeta(META_PROFILE))
.withSecurityIfConfidentialityCodesPresent(
ehrComposition.getConfidentialityCode(),
observationStatement.getConfidentialityCode()
).build();

allergyIntolerance
.addCategory(getCategory(compoundStatement))
.setAssertedDateElement(getAssertedDateElement(compoundStatement.getAvailabilityTime(), ehrComposition))
.setPatient(new Reference(patient))
.setClinicalStatus(ACTIVE)
.setVerificationStatus(UNCONFIRMED)
.addIdentifier(buildIdentifier(id, practiseCode))
.setMeta(generateMeta(META_PROFILE))
.setMeta(meta)
.setId(id);

buildOnset(compoundStatement, allergyIntolerance);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package uk.nhs.adaptors.pss.translator.util;

import org.hl7.fhir.dstu3.model.Coding;
import org.hl7.fhir.dstu3.model.Meta;
import org.hl7.v3.CV;

import java.util.Collection;
import java.util.Collections;
import java.util.Optional;

public final class ConfidentialityUtil {

private ConfidentialityUtil() { }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to break a line after line 11 otherwise it is very difficult to read such a class.
Also, it would be good to have a line break between the constructor and the static variable.


private static final Coding CONFIDENTIALITY_CODING = new Coding()
.setSystem("http://hl7.org/fhir/v3/ActCode")
.setCode("NOPAT")
.setDisplay("no disclosure to patient, family or caregivers without attending provider's authorization");

public static Meta addSecurityToMetaIfConfidentialityCodesPresent(Collection<Optional<CV>> confidentialityCodes, Meta meta) {
final boolean isCodePresent = confidentialityCodes.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.anyMatch(ConfidentialityUtil::isNopat);

if (isCodePresent) {
return ConfidentialityUtil.addConfidentialityToMeta(meta);
}

return meta;
}

private static Meta addConfidentialityToMeta(final Meta meta) {
return meta.setSecurity(
Collections.singletonList(
CONFIDENTIALITY_CODING
)
);
}

private static boolean isNopat(CV coding) {
return coding.getCode().equals("NOPAT");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package uk.nhs.adaptors.pss.translator.util.builder;

import org.hl7.fhir.dstu3.model.Meta;
import org.hl7.v3.CV;
import uk.nhs.adaptors.pss.translator.util.ConfidentialityUtil;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Supplier;

public final class MetaBuilder {
private Meta meta;

public MetaBuilder withInitialMeta(final Supplier<Meta> metaSupplier) {
this.meta = Objects.requireNonNull(metaSupplier.get());
return this;
}

@SafeVarargs
public final MetaBuilder withSecurityIfConfidentialityCodesPresent(Optional<CV>... confidentialityCodes) {
this.meta = ConfidentialityUtil.addSecurityToMetaIfConfidentialityCodesPresent(
Arrays.asList(confidentialityCodes),
this.meta
);

return this;
}

public Meta build() {
return this.meta.copy();
}
}
Loading