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

EA-184 - Move reporting module to an aware_of dependency #229

Merged
merged 12 commits into from
May 29, 2024
Merged

Conversation

mseaton
Copy link
Member

@mseaton mseaton commented May 29, 2024

No description provided.

@mseaton mseaton requested a review from mogoodrich May 29, 2024 01:15
<artifactId>emrapi-api-reporting</artifactId>
<packaging>jar</packaging>
<name>EMR API Reporting API</name>

Copy link
Member Author

Choose a reason for hiding this comment

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

Here, I create a new maven sub-module, which will result in a jar that can be conditionally loaded. All of the reporting-related dependencies are able to be moved in here.

@Handler(supports = AwaitingAdmissionVisitQuery.class)
@OpenmrsProfile(modules = { "reporting:*" })
public class AwaitingAdmissionVisitQueryEvaluator implements VisitQueryEvaluator {

Copy link
Member Author

Choose a reason for hiding this comment

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

The logic for retrieving visits awaiting admission was moved into the AdtService so that it can be used without relying on the reporting module. Then, the reporting module evaluator below was updated to call the implementation in the AdtService. None of the unit tests were changed, and all continue to pass.

@@ -12,56 +12,13 @@
<name>EMR API Module API</name>
<description>API project for EMRAPI</description>

<dependencies>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is residual cleanup from prior refactor, where these dependencies can live in the top level pom and used by all submodules.

* @param visitIds - if non-null, only returns matches for visits with the given ids
* @return List<Visit></Visit> of the matching visits
*/
List<Visit> getVisitsAwaitingAdmission(Location location, Collection<Integer> patientIds, Collection<Integer> visitIds);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new AdtService method that now contains the logic that was previously implemented in the reporting module


import java.util.List;
import java.util.Map;

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to get rid of the EmrVisitDAO, which only really existed to execute hql queries, and replaced it with this new EmrApiDAO that provides more general purpose HQL execution methods. The logic that was in the EmrVisitDAO methods has been moved to the service layer.

@@ -82,13 +75,13 @@ public enum SortOrder {
@Autowired
protected DispositionService dispositionService;

@Autowired
protected VisitQueryService visitQueryService;

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to remove usage of reporting module constructs here, and use the new Adt service method instead, so this no longer relies on the reporting module code.

@@ -6,5 +6,5 @@ where
p.voided = 'false'
and p.patientId in(select distinct personId from Obs o
where
Copy link
Member Author

Choose a reason for hiding this comment

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

There were some errors / inconsistencies in some of these hql queries, where on one side of a condition it was looking for an id, and the other side an object. I changed them to consistently refer to objects rather than deconstruct to ids.

@@ -0,0 +1,36 @@
select
Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually the main thing that was needed to move off of the reporting module dependency. I moved what was previously being done in a reporting module evaluator using the HqlQueryBuilder, and built a similar query here using HQL directly and the new EmrApiDAO methods that evaluate it.

catch (Exception e) {
throw new RuntimeException(e);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is to eliminate the use of a reporting module utility method

@@ -13,18 +13,20 @@
<description>OMOD project for EMRAPI</description>

<dependencies>

<dependency>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is partially clean up of a prior commit that removed the condition-list submodule, and partially part of this new commit that adds the reporting api submodule jar to the omod.

@mseaton mseaton requested review from dkayiwa and ibacher May 29, 2024 01:37
import static java.util.Collections.EMPTY_LIST;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.sort;
import static java.util.Collections.*;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @dkayiwa I'll fix. Annoying that intellij defaults to wildcards for static imports with > 3 usages.

@@ -31,4 +33,13 @@ public ObsBuilder buildDiagnosis(Patient patient, String dateYmd, Diagnosis.Orde
}
return builder;
}

private Date parseYmd(String ymd) {
Copy link
Member

Choose a reason for hiding this comment

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

Are we intentionally duplicating this?

Copy link
Member

Choose a reason for hiding this comment

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

It might be easier to swap to using common-langs DateUtils#parseDate(), e.g., DateUtils.parseDate(dateYmd, "yyyy-MM-dd") should work. 😁

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, will do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually that's a different version of DateUtils that we have available and it doesn't really seem to buy anything, so I'm going to leave it as is.

@ibacher
Copy link
Member

ibacher commented May 29, 2024

This basically LGTM, but I'd fix the * import before merging.

@mseaton mseaton merged commit 0789713 into master May 29, 2024
1 check passed
@mseaton mseaton deleted the EA-184-2 branch May 29, 2024 21:20
@mogoodrich
Copy link
Member

Belated LGTM @mseaton .... one thought looking at this, we are actually not super far from removing the need for reporting for Awaiting Admission altogether if we wanted to, right? (not suggesting we do so now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants