From f788b9eb0e77959f084d97d71398287e79f3a62d Mon Sep 17 00:00:00 2001 From: Ogollah Date: Tue, 15 Jun 2021 13:09:02 +0300 Subject: [PATCH 01/12] :construction: Start on the MOH510 Report --- opensrp-kip/build.gradle | 2 +- opensrp-kip/src/main/AndroidManifest.xml | 5 + .../kip/activity/Moh510ReportActivity.java | 116 +++++++++++++++ .../kip/view/NavigationMenu.java | 20 +++ .../res/layout/activity_moh510_report.xml | 15 ++ .../main/res/layout/location_spinner_view.xml | 2 +- .../main/res/layout/moh510_content_view.xml | 132 ++++++++++++++++++ .../src/main/res/layout/navigation_drawer.xml | 35 +++++ .../layout/toolbar_mho510_report_content.xml | 28 ++++ opensrp-kip/src/main/res/values/strings.xml | 1 + 10 files changed, 354 insertions(+), 2 deletions(-) create mode 100644 opensrp-kip/src/main/java/org/smartregister/kip/activity/Moh510ReportActivity.java create mode 100644 opensrp-kip/src/main/res/layout/activity_moh510_report.xml create mode 100644 opensrp-kip/src/main/res/layout/moh510_content_view.xml create mode 100644 opensrp-kip/src/main/res/layout/toolbar_mho510_report_content.xml diff --git a/opensrp-kip/build.gradle b/opensrp-kip/build.gradle index cc43f67..88e9759 100755 --- a/opensrp-kip/build.gradle +++ b/opensrp-kip/build.gradle @@ -276,7 +276,7 @@ dependencies { transitive = true } implementation group: 'io.fabric.sdk.android', name: 'fabric', version: '1.4.8' - + implementation 'org.apache.poi:poi:3.17' def robolectricVersion = '4.1' testImplementation("org.robolectric:robolectric:$robolectricVersion") { diff --git a/opensrp-kip/src/main/AndroidManifest.xml b/opensrp-kip/src/main/AndroidManifest.xml index 77dae7c..48caa95 100755 --- a/opensrp-kip/src/main/AndroidManifest.xml +++ b/opensrp-kip/src/main/AndroidManifest.xml @@ -117,6 +117,11 @@ android:screenOrientation="fullSensor" android:theme="@style/ChildTheme.NoActionBar" android:windowSoftInputMode="stateAlwaysHidden|adjustResize" /> + mohIndicators = Arrays.asList(columnsVariable); + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_moh510_report); + + ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, PackageManager.PERMISSION_GRANTED); + } + + public void buttonWriteToExcel(View view){ + + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + LocalDateTime now = LocalDateTime.now(); + + HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); + HSSFSheet sheets = hssfWorkbook.createSheet("moh 510 Report"); + HSSFRow tittle = sheets.createRow(0); + HSSFRow facility = sheets.createRow(1); + HSSFRow year = sheets.createRow(2); + HSSFRow dateRange = sheets.createRow(3); + HSSFRow columnName = sheets.createRow(4); + + HSSFCell tittleCell = tittle.createCell(0); + HSSFCell facilityCell = facility.createCell(0); + HSSFCell yearCell = year.createCell(0); + HSSFCell strStart = dateRange.createCell(0); + HSSFCell startDate = dateRange.createCell(1); + HSSFCell strEnd = dateRange.createCell(2); + HSSFCell enddate = dateRange.createCell(3); + tittleCell.setCellValue("Permanent Immunization Register(MOH 510)"); + facilityCell.setCellValue("Health Facility: Asayi Dispensary"); + yearCell.setCellValue("Year of Enrollment"); + + strStart.setCellValue("Start Date"); + strEnd.setCellValue("End Date"); + enddate.setCellValue(dtf.format(now)); + startDate.setCellValue(dtf.format(now)); + +// Column names + for (int cell = 0; cell startMoh510Report(parentActivity)); + } + + private void startMoh510Report(@Nullable Activity parentActivity){ + if (parentActivity instanceof Moh510ReportActivity) { + drawer.closeDrawer(GravityCompat.START); + return; + } + + if (parentActivity != null) { + Intent intent = new Intent(parentActivity, Moh510ReportActivity.class); + parentActivity.startActivity(intent); + } + } + private void recordStockControl(final Activity parentActivity){ stockControl.setOnClickListener(v -> startStockActivity(parentActivity)); } diff --git a/opensrp-kip/src/main/res/layout/activity_moh510_report.xml b/opensrp-kip/src/main/res/layout/activity_moh510_report.xml new file mode 100644 index 0000000..1f701c7 --- /dev/null +++ b/opensrp-kip/src/main/res/layout/activity_moh510_report.xml @@ -0,0 +1,15 @@ + + + + + + + + \ No newline at end of file diff --git a/opensrp-kip/src/main/res/layout/location_spinner_view.xml b/opensrp-kip/src/main/res/layout/location_spinner_view.xml index babae37..1b66c7b 100755 --- a/opensrp-kip/src/main/res/layout/location_spinner_view.xml +++ b/opensrp-kip/src/main/res/layout/location_spinner_view.xml @@ -12,7 +12,7 @@ android:layout_weight=".28" android:orientation="horizontal"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +