@Test public void loadCatchesExceptionWhenPatientDoesNotHavePatientClass() throws ComponentLookupException { doReturn(null).when(this.doc).getXObject(Patient.CLASS_REFERENCE); PatientData<String> result = this.component.load(this.patient); Assert.assertNull(result); }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
ClinicalStatusController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; } }
ClinicalStatusController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  }
ClinicalStatusController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @SuppressWarnings("unchecked") @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<String> readJSON(JSONObject json); }
ClinicalStatusController implements PatientDataController<String> { @Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }  @Override String getName(); @Override PatientData<String> load(Patient patient); @Override void writeJSON(Patient patient, JSONObject json, Collection<String> selectedFieldNames); @Override void writeJSON(Patient patient, JSONObject json); @SuppressWarnings("unchecked") @Override void save(Patient patient); @Override void save(@Nonnull final Patient patient, @Nonnull final PatientWritePolicy policy); @Override PatientData<String> readJSON(JSONObject json);  }