-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAID-3122 - Add
confidentialityCode
support to `AllergyIntoleranceM…
…apper.java` (#684) * [NIAD-3122] Add Predicate to ObservationUtil.java * [NIAD-3122] Add initial mapping logic * [NIAD-3122] Add initial mapping logic * [NIAD-3122] Add CodingFactory.java * [NIAD-3122] Add comment * [NIAD-3122] Refactor ResourceUtil.java * [NIAD-3122] Refactor ResourceUtil.java * [NIAD-3122] Refactor ResourceUtil.java * [NIAD-3122] Refactor ResourceUtil.java * [NIAD-3122] Add unit tests * [NIAD-3122] Refactor unit tests * [NIAD-3122] Refactor unit tests * [NIAD-3122] Update CHANGELOG.md
- Loading branch information
1 parent
eb19e1d
commit 8c5ce1f
Showing
8 changed files
with
477 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/ConfidentialityUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { } | ||
|
||
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"); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/util/builder/MetaBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.