本文整理了Java中org.openmrs.Obs.getComplexData()
方法的一些代码示例,展示了Obs.getComplexData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.getComplexData()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:getComplexData
[英]Get the ComplexData. This is retrieved by the ComplexObsHandler from the file system or another location, not from the database.
This will be null unless you call:
Obs obsWithComplexData =
Context.getObsService().getComplexObs(obsId, OpenmrsConstants.RAW_VIEW);
[中]获取复杂数据。这是由ComplexObsHandler从文件系统或其他位置检索的,而不是从数据库检索的。
除非您调用:
Obs obsWithComplexData =
Context.getObsService().getComplexObs(obsId, OpenmrsConstants.RAW_VIEW);
代码示例来源:origin: openmrs/openmrs-core
ComplexData complexData = obs.getComplexData();
if (complexData == null) {
log.error("Cannot save complex data where obsId=" + obs.getObsId() + " because its ComplexData is null.");
fout = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), StandardCharsets.UTF_8));
Reader tempRd;
Object data = obs.getComplexData().getData();
if (data instanceof char[]) {
fout.write((char[]) data);
代码示例来源:origin: openmrs/openmrs-core
/**
* @see org.openmrs.obs.ComplexObsHandler#saveObs(org.openmrs.Obs)
*/
@Override
public Obs saveObs(Obs obs) throws APIException {
try {
// Write the File to the File System
String fileName = obs.getComplexData().getTitle();
File outfile = getOutputFileToWrite(obs);
OutputStream out = new FileOutputStream(outfile, false);
FileInputStream mediaStream = (FileInputStream) obs.getComplexData().getData();
OpenmrsUtil.copyFile(mediaStream, out);
// Store the filename in the Obs
obs.setComplexData(null);
obs.setValueComplex(fileName + "|" + outfile.getName());
// close the stream
out.close();
}
catch (IOException ioe) {
throw new APIException("Obs.error.trying.write.complex", null, ioe);
}
return obs;
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ComplexObsHandler#saveObs(Obs)
*/
@Override
public Obs saveObs(Obs obs) throws APIException {
try {
// Write the File to the File System
String fileName = obs.getComplexData().getTitle();
InputStream in = (InputStream) obs.getComplexData().getData();
File outfile = getOutputFileToWrite(obs);
OutputStream out = new FileOutputStream(outfile, false);
OpenmrsUtil.copyFile(in, out);
// Store the filename in the Obs
obs.setComplexData(null);
obs.setValueComplex(fileName + "|" + outfile.getName());
// close the stream
out.close();
}
catch (Exception e) {
throw new APIException("Obs.error.writing.binary.data.complex", null, e);
}
return obs;
}
代码示例来源:origin: openmrs/openmrs-core
public Obs saveObs(Obs obs) throws APIException {
ComplexData complexData = obs.getComplexData();
if (complexData == null) {
log.error("Cannot save complex data where obsId=" + obs.getObsId() + " because its ComplexData is null.");
fout = new FileOutputStream(outfile);
Object data = obs.getComplexData().getData();
if (data instanceof byte[]) {
fout.write((byte[]) data);
代码示例来源:origin: openmrs/openmrs-core
/**
* Returns a {@link File} for the given obs complex data to be written to. The output file
* location is determined off of the {@link OpenmrsConstants#GLOBAL_PROPERTY_COMPLEX_OBS_DIR}
* and the file name is determined off the current obs.getComplexData().getTitle().
*
* @param obs the Obs with a non-null complex data on it
* @return File that the complex data should be written to
*/
public File getOutputFileToWrite(Obs obs) throws IOException {
String title = obs.getComplexData().getTitle();
String titleWithoutExtension = FilenameUtils.removeExtension(title);
String extension = "." + StringUtils.defaultIfEmpty(FilenameUtils.getExtension(title), "dat");
String uuid = obs.getUuid();
String filename;
if (StringUtils.isNotBlank(titleWithoutExtension)) {
filename = titleWithoutExtension + "_" + uuid + extension;
} else {
filename = uuid + extension;
}
File dir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(
Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR));
File outputfile = new File(dir, filename);
return outputfile;
}
代码示例来源:origin: openmrs/openmrs-core
Object data = obs.getComplexData().getData();
if (data instanceof BufferedImage) {
img = (BufferedImage) obs.getComplexData().getData();
} else if (data instanceof InputStream) {
try {
outfile = getOutputFileToWrite(obs);
String extension = getExtension(obs.getComplexData().getTitle());
代码示例来源:origin: openmrs/openmrs-core
private void handleExistingObsWithComplexConcept(Obs obs) {
ComplexData complexData = obs.getComplexData();
Concept concept = obs.getConcept();
if (null != concept && concept.isComplex()
&& null != complexData && null != complexData.getData()) {
// save or update complexData object on this obs
// this is done before the database save so that the obs.valueComplex
// can be filled in by the handler.
ComplexObsHandler handler = getHandler(obs);
if (null != handler) {
handler.saveObs(obs);
} else {
throw new APIException("unknown.handler", new Object[] {concept});
}
}
}
代码示例来源:origin: openmrs/openmrs-core
Obs complexObs2 = handler.getObs(obs2, "RAW_VIEW");
assertEquals(complexObs1.getComplexData().getMimeType(), mimetype);
assertEquals(complexObs2.getComplexData().getMimeType(), mimetype);
代码示例来源:origin: openmrs/openmrs-core
Obs complexObs2 = handler.getObs(obs2, "RAW_VIEW");
assertEquals(complexObs1.getComplexData().getMimeType(), mimetype);
assertEquals(complexObs2.getComplexData().getMimeType(), mimetype);
代码示例来源:origin: openmrs/openmrs-core
Obs complexObs2 = handler.getObs(obs2, "RAW_VIEW");
assertEquals(complexObs1.getComplexData().getMimeType(), mimetype);
assertEquals(complexObs2.getComplexData().getMimeType(), mimetype);
代码示例来源:origin: openmrs/openmrs-core
Obs complexObs2 = handler.getObs(obs2, "RAW_VIEW");
assertEquals(complexObs1.getComplexData().getMimeType(), mimetype);
assertEquals(complexObs2.getComplexData().getMimeType(), mimetype);
代码示例来源:origin: openmrs/openmrs-core
Assert.assertTrue(complexObs.isComplex());
Assert.assertNotNull(complexObs.getValueComplex());
Assert.assertNotNull(complexObs.getComplexData());
Assert.assertEquals(complexObs, os.getObsByUuid(complexObs.getUuid()));
代码示例来源:origin: openmrs/openmrs-core
Obs complexObs2 = handler.getObs(obs2, "RAW_VIEW");
assertEquals(complexObs1.getComplexData().getMimeType(), mimetype);
assertEquals(complexObs2.getComplexData().getMimeType(), mimetype);
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsService#purgeObs(Obs)
*/
@Test
public void purgeObs_shouldDeleteTheGivenObsFromTheDatabase() {
ObsService obsService = Context.getObsService();
Obs obs = obsService.getObs(7);
obsService.purgeObs(obs);
Assert.assertNull(obsService.getObs(7));
executeDataSet(COMPLEX_OBS_XML);
Obs complexObs = obsService.getComplexObs(44, ComplexObsHandler.RAW_VIEW);
// obs #44 is coded by the concept complex #8473 pointing to ImageHandler
// ImageHandler inherits AbstractHandler which handles complex data files on disk
assertNotNull(complexObs.getComplexData());
AdministrationService as = Context.getAdministrationService();
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as
.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR));
for (File file : complexObsDir.listFiles()) {
file.delete();
}
obsService.purgeObs(complexObs);
assertNull(obsService.getObs(obs.getObsId()));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ORUR01Handler#processMessage(Message)
*
*/
@Test
public void processMessage_shouldSetComplexDataForObsWithComplexConcepts() throws Exception {
ObsHandler handler = new ObsHandler();
final String handlerName = "NeigborHandler";
final String data = "{\"firstname\":\"Horatio\"}";
Context.getObsService().registerHandler(handlerName, handler);
try {
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r"
+ "PID|||3^^^^||John3^Doe^||\r"
+ "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r"
+ "ORC|RE||||||||20080226102537|1^Super User\r"
+ "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r"
+ "OBX|1|ED|6043^uiNEIHBOR^99DCT||^^^^" + data + "|||||||||20080206\r";
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
}
finally {
Context.getObsService().removeHandler(handlerName);
}
Assert.assertEquals(data, handler.getCreatedObs().getComplexData().getData());
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
ComplexData complexData = obs.getComplexData();
代码示例来源:origin: openmrs/openmrs-core
&& obs.getValueComplex() == null && obs.getValueDatetime() == null && obs.getValueDrug() == null
&& obs.getValueModifier() == null && obs.getValueNumeric() == null && obs.getValueText() == null
&& obs.getComplexData() == null) {
errors.reject("error.noValue");
代码示例来源:origin: openmrs/openmrs-core
newObs.setComplexData(obsToCopy.getComplexData());
newObs.setFormField(obsToCopy.getFormFieldNamespace(),obsToCopy.getFormFieldPath());
代码示例来源:origin: openmrs/openmrs-module-htmlformentry
} else if (HtmlFormEntryConstants.COMPLEX_UUID.equals(dt.getUuid())) {
obs.setComplexData((ComplexData) value);
obs.setValueComplex(obs.getComplexData().getTitle());
} else if (dt.isText()) {
if (value instanceof Location) {
内容来源于网络,如有侵权,请联系作者删除!