-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/samhsa2.0' into BFD-3664
- Loading branch information
Showing
98 changed files
with
3,780 additions
and
240 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
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
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
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
3 changes: 1 addition & 2 deletions
3
...hared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/adapters/SamhsaSnfAdapter.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
26 changes: 0 additions & 26 deletions
26
...d-pipeline-shared-utils/src/main/java/gov/cms/bfd/pipeline/sharedutils/model/TagCode.java
This file was deleted.
Oops, something went wrong.
126 changes: 126 additions & 0 deletions
126
...erver/bfd-server-war/src/main/java/gov/cms/bfd/server/war/commons/SecurityTagManager.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,126 @@ | ||
package gov.cms.bfd.server.war.commons; | ||
|
||
import gov.cms.bfd.sharedutils.TagCode; | ||
import jakarta.persistence.EntityManager; | ||
import jakarta.persistence.PersistenceContext; | ||
import jakarta.persistence.Query; | ||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** Find security level. */ | ||
@Service | ||
public final class SecurityTagManager { | ||
|
||
/** The Entity manager. */ | ||
private EntityManager entityManager; | ||
|
||
/** | ||
* Sets the {@link #entityManager}. | ||
* | ||
* @param entityManager a JPA {@link EntityManager} connected to the application's database | ||
*/ | ||
@PersistenceContext | ||
public void setEntityManager(EntityManager entityManager) { | ||
this.entityManager = entityManager; | ||
} | ||
|
||
/** | ||
* Query tags for a specific claim from a specific table. | ||
* | ||
* @param claimId the name of the variable | ||
* @param tagClass the name of the tag class | ||
* @return queryTagsForClaim | ||
*/ | ||
public Set<String> queryTagsForClaim(String claimId, Class<?> tagClass) { | ||
|
||
String sql = "SELECT t.code FROM " + tagClass.getSimpleName() + " t WHERE t.claim = :claim"; | ||
|
||
Query query = entityManager.createQuery(sql); | ||
query.setParameter("claim", claimId); | ||
|
||
@SuppressWarnings("unchecked") | ||
List<String> resultList = query.getResultList(); | ||
|
||
return new HashSet<>(resultList); | ||
} | ||
|
||
/** | ||
* Determines the security level based on the collected tags. | ||
* | ||
* @param claimId value of claimId | ||
* @param tagClass value of tagClass | ||
* @return SecurityLevel | ||
*/ | ||
public List<Coding> getClaimSecurityLevel(String claimId, Class<?> tagClass) { | ||
|
||
// Query tags associated with the claim | ||
List<String> securityTags = queryTagsForClaim(claimId, tagClass).stream().toList(); | ||
|
||
List<Coding> securityTagCoding = new ArrayList<>(); | ||
|
||
// If no security tags are found, directly add the default "Normal" tag | ||
if (securityTags.isEmpty()) { | ||
Coding coding = new Coding(); | ||
coding | ||
.setSystem(TransformerConstants.SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL) | ||
.setCode("N") | ||
.setDisplay("Normal"); | ||
securityTagCoding.add(coding); | ||
} else { | ||
// Check for each tag and set corresponding code and display | ||
for (String securityTag : securityTags) { | ||
Coding coding = new Coding(); | ||
// Convert the securityTag string to the TagCode enum | ||
TagCode tagCode = TagCode.fromString(securityTag); | ||
// Check each security tag and apply corresponding values | ||
if (tagCode != null) { | ||
switch (tagCode) { | ||
case R: | ||
coding | ||
.setSystem(TransformerConstants.SAMHSA_CONFIDENTIALITY_CODE_SYSTEM_URL) | ||
.setCode(TagCode.R.toString()) | ||
.setDisplay(TagCode.R.getDisplayName()); | ||
break; | ||
case _42CFRPart2: | ||
coding | ||
.setSystem(TransformerConstants.SAMHSA_ACT_CODE_SYSTEM_URL) | ||
.setCode(TagCode._42CFRPart2.toString()) | ||
.setDisplay(TagCode._42CFRPart2.getDisplayName()); | ||
break; | ||
} | ||
} | ||
securityTagCoding.add(coding); | ||
} | ||
} | ||
|
||
return securityTagCoding; | ||
} | ||
|
||
/** | ||
* Determines the security level based on the collected tags. | ||
* | ||
* @param claimId value of claimId | ||
* @param tagClass value of tagClass | ||
* @return SecurityLevel | ||
*/ | ||
public List<org.hl7.fhir.dstu3.model.Coding> getClaimSecurityLevelDstu3( | ||
String claimId, Class<?> tagClass) { | ||
|
||
List<org.hl7.fhir.dstu3.model.Coding> securityTagCoding = new ArrayList<>(); | ||
List<Coding> coding = getClaimSecurityLevel(claimId, tagClass); | ||
for (Coding code : coding) { | ||
org.hl7.fhir.dstu3.model.Coding securityTag = new org.hl7.fhir.dstu3.model.Coding(); | ||
securityTag | ||
.setSystem("http://terminology.hl7.org/CodeSystem/v3-Confidentiality") | ||
.setCode(code.getCode()) | ||
.setDisplay(code.getDisplay()); | ||
|
||
securityTagCoding.add(securityTag); | ||
} | ||
return securityTagCoding; | ||
} | ||
} |
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
Oops, something went wrong.