本文整理了Java中org.openmrs.Obs.getUuid()
方法的一些代码示例,展示了Obs.getUuid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.getUuid()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:getUuid
暂无
代码示例来源: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
@Test
public void getOutputFileToWrite_shouldCorrectlyNameNullTitledFile() throws IOException, ParseException {
ComplexData complexDataWithNullTitle = new ComplexData(null, null);
Obs obsWithNullTitle = new Obs();
obsWithNullTitle.setComplexData(complexDataWithNullTitle);
File nullTitleFile = handler.getOutputFileToWrite(obsWithNullTitle);
nullTitleFile.createNewFile();
String[] nameWithNullTitle = nullTitleFile.getName().split("\\.");
String uuidPartWithNullTitle = nameWithNullTitle[0];
String extensionPartWithNullTitle = nameWithNullTitle[1];
assertEquals(extensionPartWithNullTitle, "dat");
assertEquals(uuidPartWithNullTitle, obsWithNullTitle.getUuid());
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void getOutputFileToWrite_shouldCorrectlyNameTitledFileWithoutExtension() throws IOException, ParseException {
ComplexData complexDataWithoutExtension = new ComplexData(FilenameUtils.removeExtension(FILENAME), null);
Obs obsWithoutExtension = new Obs();
obsWithoutExtension.setComplexData(complexDataWithoutExtension);
File extensionlessFile = handler.getOutputFileToWrite(obsWithoutExtension);
extensionlessFile.createNewFile();
String[] nameWithoutExtension = extensionlessFile.getName().split("_|\\.");
String titlePartExtensionless = nameWithoutExtension[0];
String uuidPartExtensionless = nameWithoutExtension[1];
String extensionPartExtensionless = nameWithoutExtension[2];
assertEquals(titlePartExtensionless, FilenameUtils.removeExtension(FILENAME));
assertEquals(extensionPartExtensionless, "dat");
assertEquals(uuidPartExtensionless, obsWithoutExtension.getUuid());
}
代码示例来源:origin: openmrs/openmrs-core
private void mergeObservationsNotContainedInEncounters(Patient preferred, Patient notPreferred,
PersonMergeLogData mergedData) {
// move all obs that weren't contained in encounters
// TODO: this should be a copy, not a move
ObsService obsService = Context.getObsService();
for (Obs obs : obsService.getObservationsByPerson(notPreferred)) {
if (obs.getEncounter() == null && !obs.getVoided()) {
obs.setPerson(preferred);
Obs persisted = obsService.saveObs(obs, "Merged from patient #" + notPreferred.getPatientId());
mergedData.addMovedIndependentObservation(persisted.getUuid());
}
}
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void getOutputFileToWrite_shouldCorrectlyNameTitledFileWithExtension() throws IOException, ParseException {
ComplexData complexDataWithTitle = new ComplexData(FILENAME, null);
Obs obsWithTitle = new Obs();
obsWithTitle.setComplexData(complexDataWithTitle);
File titledFile = handler.getOutputFileToWrite(obsWithTitle);
titledFile.createNewFile();
String[] nameWithTitle = titledFile.getName().split("_|\\.");
String titlePart = nameWithTitle[0];
String uuidPartWithTitle = nameWithTitle[1];
String extensionPart = nameWithTitle[2];
assertEquals(titlePart, FilenameUtils.removeExtension(FILENAME));
assertEquals(extensionPart, "txt");
assertEquals(uuidPartWithTitle, obsWithTitle.getUuid());
}
代码示例来源:origin: openmrs/openmrs-core
String filename = "nameOfFile_" + obsToSave.getUuid() + ".txt";
File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as
.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR));
代码示例来源:origin: openmrs/openmrs-core
ob.setLocation(cp.getEncounter().getLocation());
ob.setPerson(cp.getEncounter().getPatient());
if (ob.getUuid() == null) {
ob.setUuid(UUID.randomUUID().toString());
代码示例来源:origin: openmrs/openmrs-core
@Test
public void newInstance_shouldCopyMostFields() throws Exception {
Obs obs = new Obs();
obs.setStatus(Obs.Status.PRELIMINARY);
obs.setInterpretation(Obs.Interpretation.LOW);
obs.setConcept(new Concept());
obs.setValueNumeric(1.2);
Obs copy = Obs.newInstance(obs);
// these fields are not copied
assertThat(copy.getObsId(), nullValue());
assertThat(copy.getUuid(), not(obs.getUuid()));
// other fields are copied
assertThat(copy.getConcept(), is(obs.getConcept()));
assertThat(copy.getValueNumeric(), is(obs.getValueNumeric()));
assertThat(copy.getStatus(), is(obs.getStatus()));
assertThat(copy.getInterpretation(), is(obs.getInterpretation()));
// TODO test that the rest of the fields are set
}
代码示例来源:origin: openmrs/openmrs-core
Assert.assertNotNull(complexObs.getValueComplex());
Assert.assertNotNull(complexObs.getComplexData());
Assert.assertEquals(complexObs, os.getObsByUuid(complexObs.getUuid()));
代码示例来源:origin: openmrs/openmrs-core
/**
* @see PatientService#mergePatients(Patient,Patient)
*/
@Test
public void mergePatients_shouldAuditMovedIndependentObservations() throws Exception {
//retrieve patients
Patient preferred = patientService.getPatient(999);
Patient notPreferred = patientService.getPatient(7);
voidOrders(Collections.singleton(notPreferred));
//get an observation for notPreferred and make it independent from any encounter
Obs obs = Context.getObsService().getObs(7);
obs.setEncounter(null);
obs.setComment("this observation is for testing the merge");
Context.getObsService().saveObs(obs, "Reason cannot be blank");
//merge the two patients and retrieve the audit object
PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred);
String uuid = null;
List<Obs> observations = Context.getObsService().getObservationsByPerson(preferred);
for (Obs o : observations) {
if (obs.getComment().equals(o.getComment())) {
uuid = o.getUuid();
}
}
Assert.assertTrue("moving of independent observation was not audited",
isValueInList(uuid, audit.getPersonMergeLogData().getMovedIndependentObservations()));
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
byte[] bytes = DatatypeConverter.parseBase64Binary(value.toString());
ComplexData complexData = new ComplexData(obs.getUuid() + ".raw", new ByteArrayInputStream(bytes));
obs.setComplexData(complexData);
} else if (obs.getConcept().getDatatype().isCoded()) {
内容来源于网络,如有侵权,请联系作者删除!