From d3e34f8d82fd55641d9d2a281223bd4043e6ae25 Mon Sep 17 00:00:00 2001 From: "mib.iqbal" Date: Tue, 11 Apr 2017 09:31:39 +0800 Subject: [PATCH] MI | Update Home inventory detail view #433 Signed-off-by: mib.iqbal --- .../HomeInventoryDetailActivity.java | 102 +++++++++++++----- .../layout/home_invent_detail_data_layout.xml | 68 ++++++------ .../src/main/res/layout/ki_detail_profile.xml | 10 -- 3 files changed, 111 insertions(+), 69 deletions(-) diff --git a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/homeinventory/HomeInventoryDetailActivity.java b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/homeinventory/HomeInventoryDetailActivity.java index 687dd1dbe..13a37a44a 100644 --- a/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/homeinventory/HomeInventoryDetailActivity.java +++ b/opensrp-sdidtk/src/main/java/org/ei/opensrp/ddtk/homeinventory/HomeInventoryDetailActivity.java @@ -14,6 +14,8 @@ import android.widget.TextView; import org.ei.opensrp.Context; +import org.ei.opensrp.commonregistry.AllCommonsRepository; +import org.ei.opensrp.commonregistry.CommonPersonObject; import org.ei.opensrp.commonregistry.CommonPersonObjectClient; import org.ei.opensrp.ddtk.R; import org.ei.opensrp.repository.DetailsRepository; @@ -71,14 +73,14 @@ protected void onCreate(Bundle savedInstanceState) { TextView Keterlibatan = (TextView) findViewById(R.id.Keterlibatan); TextView Varisai = (TextView) findViewById(R.id.Varisai); - TextView belajar_3 = (TextView) findViewById(R.id.belajar_3); - TextView Stimulasi_3 = (TextView) findViewById(R.id.Stimulasi_3); - TextView fisik_3 = (TextView) findViewById(R.id.fisik_3); - TextView Responsivitas_3 = (TextView) findViewById(R.id.Responsivitas_3); - TextView Akademis_3 = (TextView) findViewById(R.id.Akademis_3); - TextView Keteladanan_3 = (TextView) findViewById(R.id.Keteladanan_3); - TextView Variasi_3 = (TextView) findViewById(R.id.Variasi_3); - TextView Penerimaan_3 = (TextView) findViewById(R.id.Penerimaan_3); + TextView Lingkungan_3 = (TextView) findViewById(R.id.Lingkungan_3); + TextView berbicara_3 = (TextView) findViewById(R.id.berbicara_3); + TextView Interaksi_3 = (TextView) findViewById(R.id.Interaksi_3); + TextView Sikap_3 = (TextView) findViewById(R.id.Sikap_3); + TextView umum_3 = (TextView) findViewById(R.id.umum_3); + TextView Mainan_3 = (TextView) findViewById(R.id.Mainan_3); + TextView pembelajaran_3 = (TextView) findViewById(R.id.pembelajaran_3); + TextView Kebiasaan_3 = (TextView) findViewById(R.id.Kebiasaan_3); @@ -127,39 +129,89 @@ public void onClick(View v) { String ages = childclient.getColumnmaps().get("tanggalLahirAnak").substring(0, childclient.getColumnmaps().get("tanggalLahirAnak").indexOf("T")); - anakUmur.setText(getString(R.string.detailUmur) +": "+ ages+" Bulan" ); + anakUmur.setText(getString(R.string.detailUmur) +": "+ Integer.toString(monthRangeToToday(ages))+" Bulan" ); + + + AllCommonsRepository childRepository = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_anak"); + CommonPersonObject childobject = childRepository.findByCaseID(childclient.entityId()); + AllCommonsRepository kirep = org.ei.opensrp.Context.getInstance().allCommonsRepositoryobjects("ec_kartu_ibu"); + final CommonPersonObject kiparent = kirep.findByCaseID(childobject.getColumnmaps().get("relational_id")); + + if(kiparent != null) { + detailsRepository.updateDetails(kiparent); + String namaayah = kiparent.getDetails().get("namaSuami") != null ? kiparent.getDetails().get("namaSuami") : ""; + String namaibu = kiparent.getColumnmaps().get("namalengkap") != null ? kiparent.getColumnmaps().get("namalengkap") : ""; + + anakNamaIbu.setText(namaibu + "," + namaayah); + // viewHolder.village_name.setText(kiparent.getDetails().get("address1")!=null?kiparent.getDetails().get("address1") :"-"); + } + anakBerat.setText(getString(R.string.detailBerat) +": "+ (childclient.getDetails().get("berat") != null ? childclient.getDetails().get("berat").replaceAll("_", " ") : "-")); anakTinggi.setText(getString(R.string.detailTinggi) +": "+ (childclient.getDetails().get("tinggi") != null ? childclient.getDetails().get("tinggi").replaceAll("_", " ") : "-")); anakLingKepala.setText(getString(R.string.detailLingkarKepala) +": "+ (childclient.getDetails().get("lingkar_kepala") != null ? childclient.getDetails().get("lingkar_kepala").replaceAll("_", " ") : "-")); - Responsivitas.setText("5"); - Penerimaan.setText("5"); - Keteraturan.setText("5"); - Sumber_belajar.setText("7"); - Keterlibatan.setText("0"); - Varisai.setText("0"); - belajar_3.setText("0"); - Stimulasi_3.setText("0"); - fisik_3.setText("0"); - Responsivitas_3.setText("0"); - Akademis_3.setText("0"); - Keteladanan_3.setText("0"); - Variasi_3.setText("0"); - Penerimaan_3.setText("0"); - //KMS calculation + checkHome02(1,11,Responsivitas); + checkHome02(12,19,Penerimaan); + checkHome02(20,25,Keteraturan); + checkHome02(26,34,Sumber_belajar); + checkHome02(35,40,Keterlibatan); + checkHome02(41,45,Varisai); + + checkHome36(1,5,Lingkungan_3); + checkHome36(6,9,berbicara_3); + checkHome36(10,15,Interaksi_3); + checkHome36(16,21,Sikap_3); + checkHome36(22,30,umum_3); + checkHome36(31,37,Mainan_3); + checkHome36(38,45,pembelajaran_3); + checkHome36(48,55,Kebiasaan_3); + + - //Graph + } + + public void checkHome02 (int fisrt, int last , TextView total1 ) { + int _endlinecount = 0; + for (int i = fisrt ; i <=last ; i++){ + String home_endline = "home"+i+"_it"; + if(childclient.getDetails().get(home_endline) !=null) { + if (childclient.getDetails().get(home_endline).equalsIgnoreCase("Yes")) { + _endlinecount = _endlinecount + 1; + } else { + } + } + } + total1.setText(""+_endlinecount); + } + public void checkHome36 (int fisrt, int last , TextView total ) { + int _endlinecount = 0; + for (int i = fisrt ; i <=last ; i++){ + String home_endline = "home"+i+"_ec"; + if(childclient.getDetails().get(home_endline) !=null) { + if (childclient.getDetails().get(home_endline).equalsIgnoreCase("Yes")) { + _endlinecount = _endlinecount + 1; + } else { + } + } + } + total.setText(""+_endlinecount); } + private int monthRangeToToday(String lastVisitDate){ + String currentDate[] = new SimpleDateFormat("yyyy-MM").format(new java.util.Date()).substring(0,7).split("-"); + return ((Integer.parseInt(currentDate[0]) - Integer.parseInt(lastVisitDate.substring(0,4)))*12 + + (Integer.parseInt(currentDate[1]) - Integer.parseInt(lastVisitDate.substring(5,7)))); + } + // NOT USING PICTURE AT THE MOMENT String mCurrentPhotoPath; diff --git a/opensrp-sdidtk/src/main/res/layout/home_invent_detail_data_layout.xml b/opensrp-sdidtk/src/main/res/layout/home_invent_detail_data_layout.xml index 2190e3076..acf2f11bf 100644 --- a/opensrp-sdidtk/src/main/res/layout/home_invent_detail_data_layout.xml +++ b/opensrp-sdidtk/src/main/res/layout/home_invent_detail_data_layout.xml @@ -230,7 +230,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Sumber belajar : " + android:text=" Lingkungan rumah :" android:id="@+id/lbl_belajar" android:textSize="14sp" android:layout_margin="5dp" @@ -241,32 +241,32 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/belajar_3" + android:id="@+id/Lingkungan_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> - - + + @@ -275,7 +275,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Lingkungan fisik : " + android:text="Interaksi dengan anak : " android:id="@+id/lbl_fisik" android:textSize="14sp" android:layout_margin="5dp" @@ -286,7 +286,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/fisik_3" + android:id="@+id/Interaksi_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> @@ -298,7 +298,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Responsivitas : " + android:text="Sikap selama kunjungan : " android:id="@+id/lbl_Responsivitas" android:textSize="14sp" android:layout_margin="5dp" @@ -309,7 +309,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/Responsivitas_3" + android:id="@+id/Sikap_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> @@ -321,7 +321,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Stimulasi Akademis : " + android:text="Sikap secara umum : " android:id="@+id/lbl_Akademis" android:textSize="14sp" android:layout_margin="5dp" @@ -332,7 +332,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/Akademis_3" + android:id="@+id/umum_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> @@ -344,7 +344,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Keteladanan : " + android:text="Mainan anak : " android:id="@+id/lbl_Keteladanan" android:textSize="14sp" android:layout_margin="5dp" @@ -355,7 +355,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/Keteladanan_3" + android:id="@+id/Mainan_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> @@ -367,7 +367,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Variasi : " + android:text="Materi pembelajaran anak : " android:id="@+id/lbl_Variasi" android:textSize="14sp" android:layout_margin="5dp" @@ -378,7 +378,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/Variasi_3" + android:id="@+id/pembelajaran_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> @@ -390,7 +390,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" - android:text="Penerimaan : " + android:text=" Kebiasaan dan Barang Keluarga : " android:id="@+id/lbl_Penerimaan" android:textSize="14sp" android:layout_margin="5dp" @@ -401,7 +401,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:textAppearance="?android:attr/textAppearanceLarge" style="@style/CustomFontTextViewStyle.ListView.Medium" android:text="N/A" - android:id="@+id/Penerimaan_3" + android:id="@+id/Kebiasaan_3" android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> diff --git a/opensrp-sdidtk/src/main/res/layout/ki_detail_profile.xml b/opensrp-sdidtk/src/main/res/layout/ki_detail_profile.xml index f65889e0e..fb266ff69 100644 --- a/opensrp-sdidtk/src/main/res/layout/ki_detail_profile.xml +++ b/opensrp-sdidtk/src/main/res/layout/ki_detail_profile.xml @@ -68,16 +68,6 @@ android:textSize="14sp" android:layout_margin="5dp" android:textColor="@color/text_black" /> -