This repository has been archived by the owner on Jan 21, 2021. It is now read-only.
forked from SEL-Columbia/dristhi
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify: Add javadoc for report package.
- Loading branch information
Showing
6 changed files
with
451 additions
and
322 deletions.
There are no files selected for viewing
86 changes: 57 additions & 29 deletions
86
opensrp-mcare-register/src/main/java/org/opensrp/register/mcare/report/mis1/MIS1Report.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 |
---|---|---|
@@ -1,39 +1,67 @@ | ||
package org.opensrp.register.mcare.report.mis1; | ||
|
||
|
||
import org.opensrp.register.mcare.domain.Members; | ||
import org.opensrp.register.mcare.report.mis1.familyPlanning.FamilyPlanningReport; | ||
import org.opensrp.register.mcare.report.mis1.maternityCare.MaternityCareReport; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Top level class for calculating MIS1Report. | ||
* Client init an object of this class using the targeted member list. | ||
* <br> | ||
* <b>For developers</b> | ||
* <br> | ||
* Targeted member list is looped through once in this top level class. All the internal. | ||
* <i>{@link org.opensrp.register.mcare.report.mis1.Report}</i> object operate on single <i>{@link org.opensrp.register.mcare.domain.Members}</i> object. | ||
* <br> | ||
* TODO: <br> | ||
* 1. Go through the code to understand underlying desing patterns. <br> | ||
* 2. Don't use raw strings. Update <i>{@link org.opensrp.register.mcare.domain.Members}</i> class with key value. e.g: {@link org.opensrp.register.mcare.domain.Members.VaccineDose}. <br> | ||
* 3. Some report calculators are done partially e.g:{@link org.opensrp.register.mcare.report.mis1.maternityCare.ANCReportCalculator}. Others calculation can be done in same way. <br> | ||
* <br> | ||
* For a general understanding, this class represents the complete page of SRS with all the table. Every Report object {@link FamilyPlanningReport} is an table of SRS. | ||
* Every Report calculator object can be thought of an row of the table {@link org.opensrp.register.mcare.report.mis1.familyPlanning.birthControlMethdoUsagesCalculation.CondomMethodUsagesCalculator}, {@link org.opensrp.register.mcare.report.mis1.maternityCare.TTDoseReportCalculator}. | ||
* <br> | ||
* | ||
* @see <a href="http://doc.mpower-social.com:8080/share/page/document-details?nodeRef=workspace://SpacesStore/bb7b37bd-0d5a-4813-9903-33dce944b165">MIS1 Report SRS.</a> | ||
* <br> | ||
* @see <a href="https://go.gliffy.com/go/publish/12216901">Class diagram</a> | ||
*/ | ||
public class MIS1Report { | ||
private String unionName; | ||
private List<Members> membersList; | ||
private FamilyPlanningReport familyPlanningReport; | ||
private MaternityCareReport maternityCareReport; | ||
|
||
|
||
public MIS1Report(String unionName, List<Members> membersList, long startDateTime, long endDateTime) { | ||
this.unionName = unionName; | ||
this.membersList = membersList; | ||
this.familyPlanningReport = new FamilyPlanningReport(startDateTime, endDateTime); | ||
this.maternityCareReport = new MaternityCareReport(startDateTime, endDateTime); | ||
this.calculateReport(); | ||
} | ||
|
||
public FamilyPlanningReport getFamilyPlanningReport() { | ||
return familyPlanningReport; | ||
} | ||
|
||
public MaternityCareReport getMaternityCareReport() { | ||
return maternityCareReport; | ||
} | ||
|
||
private void calculateReport() { | ||
for (Members member : membersList) { | ||
familyPlanningReport.calculate(member); | ||
maternityCareReport.calculate(member); | ||
} | ||
} | ||
|
||
private String unionName; | ||
|
||
private List<Members> membersList; | ||
|
||
private FamilyPlanningReport familyPlanningReport; | ||
|
||
private MaternityCareReport maternityCareReport; | ||
|
||
public MIS1Report(String unionName, List<Members> membersList, long startDateTime, long endDateTime) { | ||
this.unionName = unionName; | ||
this.membersList = membersList; | ||
this.familyPlanningReport = new FamilyPlanningReport(startDateTime, endDateTime); | ||
this.maternityCareReport = new MaternityCareReport(startDateTime, endDateTime); | ||
this.calculateReport(); | ||
} | ||
|
||
public FamilyPlanningReport getFamilyPlanningReport() { | ||
return familyPlanningReport; | ||
} | ||
|
||
public MaternityCareReport getMaternityCareReport() { | ||
return maternityCareReport; | ||
} | ||
|
||
/** | ||
* This function calls all member reports <i>calculate</i> method using single member. | ||
* <b>Should be called inside constructor.</b> | ||
*/ | ||
private void calculateReport() { | ||
for (Members member : membersList) { | ||
familyPlanningReport.calculate(member); | ||
maternityCareReport.calculate(member); | ||
} | ||
} | ||
} |
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
57 changes: 37 additions & 20 deletions
57
...mcare-register/src/main/java/org/opensrp/register/mcare/report/mis1/ReportCalculator.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 |
---|---|---|
@@ -1,28 +1,45 @@ | ||
package org.opensrp.register.mcare.report.mis1; | ||
|
||
|
||
import org.opensrp.register.mcare.domain.Members; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Base abstract class for report calculation. Every report calculator should extends this class. | ||
*/ | ||
public abstract class ReportCalculator { | ||
protected long startDateTime; | ||
protected long endDateTime; | ||
|
||
public ReportCalculator(long startDateTime, long endDateTime) { | ||
this.startDateTime = startDateTime; | ||
this.endDateTime = endDateTime; | ||
} | ||
|
||
public abstract void calculate(Members member); | ||
|
||
protected boolean withInStartAndEndTime(Map<String, String> visitData) { | ||
if(visitData.containsKey(Members.CLIENT_VERSION_KEY)) { | ||
long clientVersion = Long.parseLong(visitData.get(Members.CLIENT_VERSION_KEY)); | ||
if(clientVersion >= startDateTime && clientVersion <= endDateTime) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
protected long startDateTime; | ||
|
||
protected long endDateTime; | ||
|
||
public ReportCalculator(long startDateTime, long endDateTime) { | ||
this.startDateTime = startDateTime; | ||
this.endDateTime = endDateTime; | ||
} | ||
|
||
/** | ||
* Concrete class should implement this method to calculate their desired method to based on current | ||
* Member. | ||
* e.g: whether current member is pregnant or not. | ||
* | ||
* @param member | ||
*/ | ||
public abstract void calculate(Members member); | ||
|
||
/** | ||
* Check if given map visit data(PSRF, ANC, PNC) within start and end time. | ||
* | ||
* @param visitData | ||
* @return | ||
*/ | ||
protected boolean withInStartAndEndTime(Map<String, String> visitData) { | ||
if (visitData.containsKey(Members.CLIENT_VERSION_KEY)) { | ||
long clientVersion = Long.parseLong(visitData.get(Members.CLIENT_VERSION_KEY)); | ||
if (clientVersion >= startDateTime && clientVersion <= endDateTime) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.