Skip to content

Commit

Permalink
MI | Update Home inventory detail view #433
Browse files Browse the repository at this point in the history
Signed-off-by: mib.iqbal <[email protected]>
  • Loading branch information
mib-iqbal committed Apr 11, 2017
1 parent 092a06b commit d3e34f8
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);



Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" />
</TableRow>
<TableRow>
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/CustomFontTextViewStyle.ListView.Medium"
android:text="Stimulasi Bahasa : "
android:id="@+id/lbl_Stimulasi"
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/CustomFontTextViewStyle.ListView.Medium"
android:text="N/A"
android:id="@+id/Stimulasi_3"
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/CustomFontTextViewStyle.ListView.Medium"
android:text="Cara berbicara : "
android:id="@+id/lbl_Stimulasi"
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/CustomFontTextViewStyle.ListView.Medium"
android:text="N/A"
android:id="@+id/berbicara_3"
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
</TableRow>

<TableRow>
Expand All @@ -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"
Expand All @@ -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" />
Expand All @@ -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"
Expand All @@ -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" />
Expand All @@ -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"
Expand All @@ -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" />
Expand All @@ -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"
Expand All @@ -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" />
Expand All @@ -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"
Expand All @@ -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" />
Expand All @@ -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"
Expand All @@ -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" />
Expand Down
10 changes: 0 additions & 10 deletions opensrp-sdidtk/src/main/res/layout/ki_detail_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
style="@style/CustomFontTextViewStyle.ListView.Medium"
android:text="Umur"
android:id="@+id/Umur"
android:textSize="14sp"
android:layout_margin="5dp"
android:textColor="@color/text_black" />
<org.ei.opensrp.view.customControls.CustomFontTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down

0 comments on commit d3e34f8

Please sign in to comment.