Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
work on encounter sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Proshanto committed May 22, 2017
1 parent dc70e5d commit 9a047e3
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public Event convertToEvent(JSONObject encounter) throws JSONException{
JSONArray ol = encounter.getJSONArray("obs");
for (int i = 0; i < ol.length(); i++) {
JSONObject o = ol.getJSONObject(i);
System.out.println(o.get("display"));
//System.out.println(o.get("display"));
/*List<Object> values = new ArrayList<Object>();
if(o.optJSONObject("display") != null){
values.add(o.getJSONObject("value").getString("uuid"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,27 +170,35 @@ public Event getEvent(JSONObject event){
String[] patientArray = patientIfo.split("-");
logger.info("patient:"+patientArray[0]);

JSONArray observations = event.getJSONArray("obs");
for (int i = 0; i < observations.length(); i++) {
JSONObject o = observations.getJSONObject(i);
String vaccines = (String) o.get("display");
String[] vaccineArray = vaccines.split(",");
logger.info("vaccineArray:"+vaccineArray[0] +" : "+ vaccineArray[1] + " : " +vaccineArray[2] );
if(eventType.equalsIgnoreCase("VAC")){
JSONArray observations = event.getJSONArray("obs");
for (int i = 0; i < observations.length(); i++) {
JSONObject o = observations.getJSONObject(i);
String vaccines = (String) o.get("display");
String vaccineString = this.StringFilter(vaccines);
System.err.println("vaccineString:"+vaccineString);
String[] vaccineArray = vaccineString.split(",");
System.out.println("Array:"+vaccineArray.toString());
logger.info("vaccineArray:"+vaccineArray[0] +" : "+ vaccineArray[1] + " : " +vaccineArray[2] +":"+vaccineArray[3]);
}
}
//String[] array = ((String) obs1.getValues().get(0)).split(":");


} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(ArrayIndexOutOfBoundsException ee){
logger.info(""+ee.getMessage());
}



FormsType<WomanTTForm> womanTTForm = FormFatcory.getFormsTypeInstance("WTT");
//womanTTForm.makeForm(filePath);
return null;
}

public FormSubmission createFormSubmission(){
public FormSubmission createFormSumission(){
JsonNode enc = null;
ObjectMapper mapper = new ObjectMapper();
try {
Expand Down Expand Up @@ -249,7 +257,26 @@ public FormSubmission createFormSubmission(){
return formSubmission;
}


public String StringFilter(String str){

String strRemoveImmu = "";
strRemoveImmu = str.replace("Immunization Incident Template:", "");
String strRemoveTT = "";
strRemoveTT = strRemoveImmu.replace("(Tetanus toxoid)", "");//TT
String strRemoveOPV = "";
strRemoveOPV = strRemoveTT.replace("(Poliomyelitis oral, trivalent, live attenuated)", "");//OPV
String strRemovePenta = "";
strRemovePenta = strRemoveOPV.replace("(Diphtheria-hemophilus influenzae B-pertussis-poliomyelitis-tetanus-hepatitis B)", "");//penta
String strRemovePCV = "";
strRemovePCV = strRemovePenta.replace("(Pneumococcus, purified polysaccharides antigen conjugated)", "");//pcv1
String strRemoveBCG = "";
strRemoveBCG = strRemovePCV.replace("(Tuberculosis, live attenuated)", "");//bcg
String strRemoveIPV = "";
strRemoveIPV = strRemoveBCG.replace("(IPV Vaccine)", "");//ipv
System.out.println(strRemoveIPV);
return str;

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mock;
import org.opensrp.encounter.sync.MakeFormSubmission;
import org.opensrp.register.encounter.sync.*;
import org.opensrp.form.domain.FormSubmission;
import org.opensrp.form.repository.AllFormSubmissions;
import org.opensrp.service.EventService;
Expand Down Expand Up @@ -61,4 +61,11 @@ public void shuoldCreateEncounter(){

}

@Test
public void ShouldRemoveSubstringFromString(){
MakeFormSubmission makeFormSubmission = new MakeFormSubmission();
makeFormSubmission.StringFilter("Immunization Incident Template: BCG (Tuberculosis, live attenuated), 2017-01-25, true, 0.0");

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void shuoldCreateWonamTT1(){
String uuid = UUID.randomUUID().toString();
System.out.println("uuid:"+uuid);
MakeFormSubmission makeFormSubmission = new MakeFormSubmission(formSubmissions);
formSubmission =makeFormSubmission.createFormSubmission();
formSubmission =makeFormSubmission.createFormSumission();
formSubmissions.remove(formSubmission);
assertNotNull(formSubmission);

Expand Down

0 comments on commit 9a047e3

Please sign in to comment.