@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_visit_dashboard); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); } Intent intent = getIntent(); mVisit = new VisitDAO() .getVisitsByID(intent.getLongExtra(ApplicationConstants.BundleKeys.VISIT_ID, 0)); mPatient = new PatientDAO().findPatientByID(String.valueOf(mVisit.getPatientID())); mPatientName = intent.getStringExtra(ApplicationConstants.BundleKeys.PATIENT_NAME); mVisitEncounters = mVisit.getEncounters(); mEmptyListView = (TextView) findViewById(R.id.visitDashboardEmpty); FontsUtil.setFont(mEmptyListView, FontsUtil.OpenFonts.OPEN_SANS_BOLD); mExpandableListView = (ExpandableListView) findViewById(R.id.visitDashboardExpList); mExpandableListView.setEmptyView(mEmptyListView); }
@Override public void updateEncounterList() { mVisitEncounters.clear(); mExpandableListAdapter.notifyDataSetChanged(); mVisit.setEncounters(new EncounterDAO().findEncountersByVisitID(mVisit.getId())); mVisitEncounters.addAll(mVisit.getEncounters()); mExpandableListAdapter.notifyDataSetChanged(); }
@Override public boolean onCreateOptionsMenu(Menu menu) { if (DateUtils.ZERO.equals(mVisit.getStopDate())) { getMenuInflater().inflate(R.menu.active_visit_menu, menu); } getSupportActionBar().setSubtitle(mPatientName); return true; }
public static Visit map(JSONObject jsonObject) throws JSONException { Visit visit = new Visit(); visit.setUuid(getStringFromObject(jsonObject, "uuid")); JSONObject locationObject = getJSONObject(jsonObject, "location"); visit.setVisitPlace(getStringFromObject(locationObject, DISPLAY_KEY)); JSONObject visitTypeObject = jsonObject.getJSONObject("visitType"); visit.setVisitType(getStringFromObject(visitTypeObject, DISPLAY_KEY)); visit.setStartDate(DateUtils.convertTime(getStringFromObject(jsonObject, "startDatetime"))); visit.setStopDate(DateUtils.convertTime(getStringFromObject(jsonObject, "stopDatetime"))); List<Encounter> encounterList = new ArrayList<Encounter>(); if (!jsonObject.isNull("encounters")) { JSONArray encountersJSONArray = jsonObject.getJSONArray("encounters"); for (int i = 0; i < encountersJSONArray.length(); i++) { Encounter encounter = new Encounter(); JSONObject encounterJSONObject = encountersJSONArray.getJSONObject(i); List<Observation> observationList = new ArrayList<Observation>(); encounter.setDisplay(getStringFromObject(encounterJSONObject, DISPLAY_KEY)); encounter.setUuid(getStringFromObject(encounterJSONObject, "uuid")); encounter.setEncounterType( Encounter.EncounterType.getType( getStringFromObject( getJSONObject(encounterJSONObject, "encounterType"), DISPLAY_KEY))); encounter.setEncounterDatetime( DateUtils.convertTime(getStringFromObject(encounterJSONObject, "encounterDatetime"))); JSONArray obsJSONArray = encounterJSONObject.getJSONArray("obs"); for (int j = 0; j < obsJSONArray.length(); j++) { Observation observation = new Observation(); JSONObject observationJSONObject = obsJSONArray.getJSONObject(j); observation.setUuid(getStringFromObject(observationJSONObject, "uuid")); if (Encounter.EncounterType.VITALS.equals(encounter.getEncounterType())) { String[] labelAndValue = getStringFromObject(observationJSONObject, DISPLAY_KEY).split(":"); observation.setDisplay(labelAndValue[0]); observation.setDisplayValue(labelAndValue[1]); } else if (Encounter.EncounterType.VISIT_NOTE.equals(encounter.getEncounterType())) { observation = ObservationMapper.diagnosisMap(observationJSONObject); } else { observation.setDisplay(getStringFromObject(observationJSONObject, DISPLAY_KEY)); } observationList.add(observation); } encounter.setObservations(observationList); encounterList.add(encounter); } } visit.setEncounters(encounterList); return visit; }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (resultCode) { case RESULT_OK: String path = data.getData().toString(); String instanceID = path.substring(path.lastIndexOf('/') + 1); FormManagerBundle bundle = FormsHelper.createBundle( new FormsDAO(getContentResolver()) .getSurveysSubmissionDataFromFormInstanceId(instanceID) .getFormInstanceFilePath(), mPatient.getUuid(), mPatient.getId(), mVisit.getUuid()); mFormsManager.uploadXFormWithMultiPartRequest( FormsHelper.createUploadXFormWithMultiPartRequestListener(bundle, this)); break; case RESULT_CANCELED: finish(); default: break; } }
public void endVisit() { mVisitsManager.endVisitByUUID( VisitsHelper.createEndVisitsByUUIDListener( mVisit.getUuid(), mPatient.getId(), mVisit.getId(), this)); }