forked from chpladmin/chpl-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add endpoint /report-data/code-sets and /code-sets/listings for…
… the Criteria Attr rept OCD-2037
- Loading branch information
Showing
5 changed files
with
141 additions
and
2 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
14 changes: 14 additions & 0 deletions
14
...ervice/src/main/java/gov/healthit/chpl/report/criteriaattribute/CodeSetListingReport.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,14 @@ | ||
package gov.healthit.chpl.report.criteriaattribute; | ||
|
||
import gov.healthit.chpl.certificationCriteria.CertificationCriterion; | ||
import gov.healthit.chpl.codeset.CodeSet; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class CodeSetListingReport { | ||
private String chplProductNumber; | ||
private CertificationCriterion criterion; | ||
private CodeSet codeSet; | ||
} |
14 changes: 14 additions & 0 deletions
14
.../chpl-service/src/main/java/gov/healthit/chpl/report/criteriaattribute/CodeSetReport.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,14 @@ | ||
package gov.healthit.chpl.report.criteriaattribute; | ||
|
||
import gov.healthit.chpl.certificationCriteria.CertificationCriterion; | ||
import gov.healthit.chpl.codeset.CodeSet; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class CodeSetReport { | ||
private CertificationCriterion criterion; | ||
private CodeSet codeSet; | ||
private Long count; | ||
} |
76 changes: 76 additions & 0 deletions
76
...pl-service/src/main/java/gov/healthit/chpl/report/criteriaattribute/CodeSetReportDao.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,76 @@ | ||
package gov.healthit.chpl.report.criteriaattribute; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.stereotype.Repository; | ||
|
||
import gov.healthit.chpl.certificationCriteria.CertificationCriterionEntity; | ||
import gov.healthit.chpl.codeset.CodeSetEntity; | ||
import gov.healthit.chpl.dao.impl.BaseDAOImpl; | ||
import jakarta.persistence.Query; | ||
|
||
@Repository | ||
public class CodeSetReportDao extends BaseDAOImpl { | ||
public List<CodeSetReport> getCodeSetReports() { | ||
String hql = "SELECT cc, cs, count(*) as codeSetCount " | ||
+ "FROM CertificationCriterionEntity cc, " | ||
+ "CertificationResultEntity cr, " | ||
+ "CertifiedProductDetailsEntity cpd, " | ||
+ "CertificationResultCodeSetEntity crcs, " | ||
+ "CodeSetEntity cs " | ||
+ "WHERE cc.id = cr.certificationCriterionId " | ||
+ "AND cr.certifiedProductId = cpd.id " | ||
+ "AND cr.id = crcs.certificationResultId " | ||
+ "AND crcs.codeSet.id = cs.id " | ||
+ "AND cpd.certificationStatusId IN (1,6,7) " | ||
+ "AND (cc.endDay is null OR cc.endDay > CURRENT_DATE()) " | ||
+ "AND cc.deleted = false " | ||
+ "AND cr.deleted = false " | ||
+ "AND crcs.deleted = false " | ||
+ "AND cpd.deleted = false " | ||
+ "AND cs.deleted = false " | ||
+ "GROUP BY cc.id, cs.id "; | ||
|
||
Query query = entityManager.createQuery(hql); | ||
List<Object[]> results = query.getResultList(); | ||
|
||
return results.stream() | ||
.map(result -> CodeSetReport.builder() | ||
.criterion(((CertificationCriterionEntity) result[0]).toDomain()) | ||
.codeSet(((CodeSetEntity) result[1]).toDomain()) | ||
.count((Long) result[2]) | ||
.build()) | ||
.toList(); | ||
} | ||
|
||
public List<CodeSetListingReport> getCodeSetListingReports() { | ||
String hql = "SELECT cc, cs, cpd.chplProductNumber " | ||
+ "FROM CertificationCriterionEntity cc, " | ||
+ "CertificationResultEntity cr, " | ||
+ "CertifiedProductDetailsEntity cpd, " | ||
+ "CertificationResultCodeSetEntity crcs, " | ||
+ "CodeSetEntity cs " | ||
+ "WHERE cc.id = cr.certificationCriterionId " | ||
+ "AND cr.certifiedProductId = cpd.id " | ||
+ "AND cr.id = crcs.certificationResultId " | ||
+ "AND crcs.codeSet.id = cs.id " | ||
+ "AND cpd.certificationStatusId IN (1,6,7) " | ||
+ "AND cc.deleted = false " | ||
+ "AND cr.deleted = false " | ||
+ "AND crcs.deleted = false " | ||
+ "AND cpd.deleted = false " | ||
+ "AND cs.deleted = false "; | ||
|
||
Query query = entityManager.createQuery(hql); | ||
List<Object[]> results = query.getResultList(); | ||
|
||
return results.stream() | ||
.map(result -> CodeSetListingReport.builder() | ||
.criterion(((CertificationCriterionEntity) result[0]).toDomain()) | ||
.codeSet(((CodeSetEntity) result[1]).toDomain()) | ||
.chplProductNumber((String) result[2]) | ||
.build()) | ||
.toList(); | ||
} | ||
|
||
} |
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