/** * Convenience method to create and return a file for the stored ComplexData.data Object * * @param obs * @return File object */ public static File getComplexDataFile(Obs obs) { String[] names = obs.getValueComplex().split("\\|"); String filename = names.length < 2 ? names[0] : names[names.length - 1]; File dir = OpenmrsUtil.getDirectoryInApplicationDataDirectory( Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); return new File(dir, filename); }
public Obs getObs(Obs obs, String view) { File file = getComplexDataFile(obs); log.debug("value complex: " + obs.getValueComplex()); log.debug("file path: " + file.getAbsolutePath()); ComplexData complexData = null; String[] names = obs.getValueComplex().split("\\|"); String originalFilename = names[0]; originalFilename = originalFilename.replaceAll(",", "").replaceAll(" ", "").replaceAll("file$", "");
public Obs getObs(Obs obs, String view) { File file = getComplexDataFile(obs); log.debug("value complex: " + obs.getValueComplex()); log.debug("file path: " + file.getAbsolutePath()); ComplexData complexData = null; String[] names = obs.getValueComplex().split("\\|"); String originalFilename = names[0]; originalFilename = originalFilename.replaceAll(",", "").replaceAll(" ", "").replaceAll("file$", "");
/** * @see org.openmrs.obs.ComplexObsHandler#getObs(Obs, String) */ public Obs getObs(Obs obs, String view) { File file = BinaryDataHandler.getComplexDataFile(obs); log.debug("value complex: " + obs.getValueComplex()); log.debug("file path: " + file.getAbsolutePath()); ComplexData complexData = null; try { complexData = new ComplexData(file.getName(), OpenmrsUtil.getFileAsBytes(file)); } catch (IOException e) { log.error("Trying to read file: " + file.getAbsolutePath(), e); } String mimeType = OpenmrsUtil.getFileMimeType(file); complexData.setMimeType(mimeType); obs.setComplexData(complexData); return obs; }
String[] names = obs.getValueComplex().split("\\|"); String originalFilename = names[0]; originalFilename = originalFilename.replace(",", "").replace(" ", "");
try { file = getComplexDataFile(obs); String[] names = obs.getValueComplex().split("\\|"); String originalFilename = names[0]; originalFilename = originalFilename.replace(",", "").replace(" ", "");
} else if ("ST".equals(abbrev)) { return getValueText(); } else if ("ED".equals(abbrev) && getValueComplex() != null) { String[] valuesComplex = getValueComplex().split("\\|"); for (String value : valuesComplex) { if (StringUtils.isNotEmpty(value)) { if (getValueComplex() != null) { String[] valuesComplex = getValueComplex().split("\\|"); for (String value : valuesComplex) { if (StringUtils.isNotEmpty(value)) {
String valueComplex = obsToSave.getValueComplex(); String filename = valueComplex.substring(valueComplex.indexOf("|") + 1).trim(); newComplexFile = new File(complexObsDir, filename);
Assert.assertNotNull(complexObs.getValueComplex()); Assert.assertNotNull(complexObs.getComplexData()); Assert.assertEquals(complexObs, os.getObsByUuid(complexObs.getUuid()));
if (obs.getValueComplex() != null) { errors.rejectValue("valueComplex", "error.not.null"); && obs.getValueComplex() == null && obs.getValueDatetime() == null && obs.getValueDrug() == null && obs.getValueModifier() == null && obs.getValueNumeric() == null && obs.getValueText() == null && obs.getComplexData() == null) {
newObs.setInterpretation(obsToCopy.getInterpretation()); newObs.setValueComplex(obsToCopy.getValueComplex()); newObs.setComplexData(obsToCopy.getComplexData()); newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());
String lookFor = existingObs == null ? null : existingObs.getValueComplex(); Obs initialValue = null; if (lookFor != null) {
value = new ComplexData(existingObs.getValueComplex(), null);
if (obs.getValueComplex() != null) { return obs.getValueComplex();
@Test @Verifies(value="shouldSetTheValueComplexOfObsIfConceptIsComplex",method="createObs(Concept concept, Object value, Date datetime, String accessionNumber)") public void createObs_shouldSetTheValueComplexOfObsIfConceptIsComplex(){ ComplexData complexData=new ComplexData("test", null); Concept c=new Concept(); ConceptDatatype cd=new ConceptDatatype(); cd.setUuid(HtmlFormEntryConstants.COMPLEX_UUID); c.setDatatype(cd); Obs o=HtmlFormEntryUtil.createObs(c, complexData, null, null); Assert.assertEquals(o.getValueComplex(),complexData.getTitle()); }
if (o.getValueCoded() != null || o.getValueComplex() != null || o.getValueDatetime() != null || o.getValueDrug() != null || o.getValueNumeric() != null || o.getValueText() != null) { Assert