本文整理匯總了Java中org.openmrs.api.ConceptService.getConcept方法的典型用法代碼示例。如果您正苦於以下問題:Java ConceptService.getConcept方法的具體用法?Java ConceptService.getConcept怎麽用?Java ConceptService.getConcept使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openmrs.api.ConceptService
的用法示例。
在下文中一共展示了ConceptService.getConcept方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSubmit_shouldSetTheLocalPreferredName
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see ConceptFormController#onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
*/
@Test
@Verifies(value = "should set the local preferred name", method = "onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)")
public void onSubmit_shouldSetTheLocalPreferredName() throws Exception {
ConceptService cs = Context.getConceptService();
Concept concept = cs.getConcept(5497);
//sanity check, the current preferred Name should be different from what will get set in the form
Assert.assertNotSame("CD3+CD4+ABS CNT", concept.getPreferredName(britishEn).getName());
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "5497");
mockRequest.setParameter("preferredNamesByLocale[en_GB]", "CD3+CD4+ABS CNT");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Assert.assertEquals("CD3+CD4+ABS CNT", concept.getPreferredName(britishEn).getName());
//preferred name should be the new one that has been set from the form
Assert.assertEquals(true, concept.getPreferredName(britishEn).isLocalePreferred());
}
示例2: shouldRemoveConceptAnswersIfDatatypeChangedFromCoded
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* This test makes sure that all answers are deleted if the user changes this concept's datatype
* to something other than "Coded"
*
* @throws Exception
*/
@Test
public void shouldRemoveConceptAnswersIfDatatypeChangedFromCoded() throws Exception {
ConceptService cs = Context.getConceptService();
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "4"); // this must be a concept id that is not used in an observation in order to be changed
mockRequest.setParameter("namesByLocale[en_GB].name", "CIVIL STATUS");
mockRequest.setParameter("concept.datatype", "1"); // set it to something other than "Coded"
mockRequest.setParameter("concept.class", "10");
mockRequest.setParameter("concept.answers", "5 6");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Concept concept = cs.getConcept(4);
assertNotNull(concept);
assertEquals(0, concept.getAnswers(false).size());
}
示例3: getQuestionsForAnswer
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
public List<ConceptListItem> getQuestionsForAnswer(Integer conceptId) {
Locale locale = Context.getLocale();
ConceptService cs = Context.getConceptService();
Concept concept = cs.getConcept(conceptId);
List<Concept> concepts = cs.getConceptsByAnswer(concept);
List<ConceptListItem> items = new ArrayList<ConceptListItem>();
for (Concept c : concepts) {
ConceptName cn = c.getName(locale);
items.add(new ConceptListItem(c, cn, locale));
}
return items;
}
示例4: createObservation_shouldCreateObservationWithBooleanConceptWithValueYes
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value yes", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueYes() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "1/12/2014";
dwrService.createObs(2, null, 18, "Yes", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.true");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例5: createObservation_shouldCreateObservationWithBooleanConceptWithValueTrue
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value true", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueTrue() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "3/12/2014";
dwrService.createObs(2, null, 18, "True", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.true");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例6: createObservation_shouldCreateObservationWithBooleanConceptWithValueFalse
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value false", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueFalse() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "4/12/2014";
dwrService.createObs(2, null, 18, "False", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.false");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例7: createObservation_shouldCreateObservationWithBooleanConceptWithValueZero
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see org.openmrs.web.dwr.DWRObsService#createObs(Integer, Integer, Integer, String, String)
*/
@Test
@Verifies(value = "should pass test on saving observation with boolean concepts with value zero", method = "createObs(Integer, Integer, Integer, String, String)")
public void createObservation_shouldCreateObservationWithBooleanConceptWithValueZero() throws Exception {
DWRObsService dwrService = new DWRObsService();
ConceptService conceptService = Context.getConceptService();
ObsService obsService = Context.getObsService();
AdministrationService administrationService = Context.getAdministrationService();
Person person = Context.getPersonService().getPerson(2);
Concept concept = conceptService.getConcept(18);
List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
int obsListSizeBeforeSaveObs = obsListBefore.size();
String obsDateTime = "5/12/2014";
dwrService.createObs(2, null, 18, "0", obsDateTime);
List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
assertEquals(obsListSizeBeforeSaveObs + 1, obsListAfter.size());
String booleanConceptId = administrationService.getGlobalProperty("concept.false");
Concept booleanConcept = Context.getConceptService().getConcept(Integer.parseInt(booleanConceptId));
Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
assertNotNull(addedObs);
assertNotNull(addedObs.getValueCoded());
assertEquals(booleanConcept, addedObs.getValueCoded());
}
示例8: shouldRemoveConceptSet
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* This tests removing a concept set
*
* @throws Exception
*/
@Test
public void shouldRemoveConceptSet() throws Exception {
ConceptService cs = Context.getConceptService();
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "23");
mockRequest.setParameter("namesByLocale[en_GB].name", "FOOD CONSTRUCT");
mockRequest.setParameter("concept.datatype", "4");
mockRequest.setParameter("concept.class", "10");
mockRequest.setParameter("concept.conceptSets", "18 19");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Concept concept = cs.getConcept(23);
assertNotNull(concept);
assertEquals(2, concept.getConceptSets().size());
}
示例9: shouldRemoveConceptAnswer
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* This tests removing an answer
*
* @throws Exception
*/
@Test
public void shouldRemoveConceptAnswer() throws Exception {
ConceptService cs = Context.getConceptService();
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "21");
mockRequest.setParameter("namesByLocale[en_GB].name", "FOOD ASSISTANCE FOR ENTIRE FAMILY");
mockRequest.setParameter("concept.datatype", "2");
mockRequest.setParameter("concept.class", "7");
mockRequest.setParameter("concept.answers", "7 8");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Concept concept = cs.getConcept(21);
assertNotNull(concept);
assertEquals(2, concept.getAnswers(false).size());
}
示例10: getConcept
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* Get a {@link ConceptListItem} by its internal database id.
*
* @param conceptId the id to look for
* @return a {@link ConceptListItem} or null if conceptId is not found
*/
public ConceptListItem getConcept(Integer conceptId) {
Locale locale = Context.getLocale();
ConceptService cs = Context.getConceptService();
Concept c = cs.getConcept(conceptId);
if (c == null) {
return null;
}
ConceptName cn = c.getName(locale);
return new ConceptListItem(c, cn, locale);
}
示例11: getConceptSet
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
public List<Object> getConceptSet(Integer conceptId) {
Locale locale = Context.getLocale();
ConceptService cs = Context.getConceptService();
FormService fs = Context.getFormService();
Concept concept = cs.getConcept(conceptId);
List<Object> returnList = new ArrayList<Object>();
if (concept.isSet()) {
for (ConceptSet set : concept.getConceptSets()) {
Field field = null;
ConceptName cn = set.getConcept().getName(locale);
ConceptDescription description = set.getConcept().getDescription(locale);
if (description != null) {
for (Field f : fs.getFieldsByConcept(set.getConcept())) {
if (OpenmrsUtil.nullSafeEquals(f.getName(), cn.getName())
&& OpenmrsUtil.nullSafeEquals(f.getDescription(), description.getDescription())
&& f.isSelectMultiple().equals(false)) {
field = f;
}
}
}
if (field == null) {
returnList.add(new ConceptListItem(set.getConcept(), cn, locale));
} else {
returnList.add(new FieldListItem(field, locale));
}
}
}
return returnList;
}
示例12: getDrugs
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
public List<Object> getDrugs(Integer conceptId, boolean showConcept) {
Locale locale = Context.getLocale();
ConceptService cs = Context.getConceptService();
Concept concept = cs.getConcept(conceptId);
List<Object> items = new ArrayList<Object>();
// Add this concept as the first option in the list
// If there are no drugs to choose from, this will be automatically
// selected
// by the openmrsSearch.fillTable(objs) function
if (showConcept) {
ConceptDrugListItem thisConcept = new ConceptDrugListItem(null, conceptId, concept.getName(locale, false)
.getName());
items.add(thisConcept);
}
// find drugs for this concept
List<Drug> drugs = cs.getDrugsByConcept(concept);
// if there are drugs to choose from, add some instructions
if (drugs.size() > 0 && showConcept) {
items.add("Or choose a form of " + concept.getName(locale, false).getName());
}
// miniaturize our drug objects
for (Drug drug : drugs) {
items.add(new ConceptDrugListItem(drug, locale));
}
return items;
}
示例13: shouldEditConceptComplex
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* This test makes sure that ConceptComplex objects can be edited
*
* @throws Exception
*/
@Test
public void shouldEditConceptComplex() throws Exception {
executeDataSet("org/openmrs/api/include/ObsServiceTest-complex.xml");
ConceptService cs = Context.getConceptService();
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", "8473");
mockRequest.setParameter("namesByLocale[en_GB].name", "A complex concept");
mockRequest.setParameter("descriptionsByLocale[en_GB].description", "some description");
mockRequest.setParameter("concept.datatype", "13");
mockRequest.setParameter("concept.class", "5");
mockRequest.setParameter("handlerKey", "TextHandler"); // switching it from an ImageHandler to a TextHandler
ModelAndView mav = conceptFormController.handleRequest(mockRequest, new MockHttpServletResponse());
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Concept concept = cs.getConcept(8473);
assertEquals(ConceptComplex.class, concept.getClass());
ConceptComplex complex = (ConceptComplex) concept;
assertEquals("TextHandler", complex.getHandler());
}
示例14: onSubmit_shouldAddANewConceptMapToAnExistingConcept
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
/**
* @see ConceptFormController#onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)
*/
@Test
@Verifies(value = "should add a new Concept map to an existing concept", method = "onSubmit(HttpServletRequest,HttpServletResponse,Object,BindException)")
public void onSubmit_shouldAddANewConceptMapToAnExistingConcept() throws Exception {
ConceptService cs = Context.getConceptService();
int conceptId = 3;
// make sure the concept already exists
Concept concept = cs.getConcept(conceptId);
assertNotNull(concept);
int initialConceptMappingCount = concept.getConceptMappings().size();
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", concept.getConceptId().toString());
mockRequest.setParameter("conceptMappings[0].conceptReferenceTerm", "1");
mockRequest.setParameter("conceptMappings[0].conceptMapType", "3");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
assertEquals(initialConceptMappingCount + 1, cs.getConcept(conceptId).getConceptMappings().size());
}
示例15: shouldRemoveConceptDescriptionIfRemovedFromUI
import org.openmrs.api.ConceptService; //導入方法依賴的package包/類
@Test
public void shouldRemoveConceptDescriptionIfRemovedFromUI() throws Exception {
ConceptService cs = Context.getConceptService();
final String espaniol = "es";
AdministrationService as = Context.getAdministrationService();
GlobalProperty gp = as.getGlobalPropertyObject(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST);
gp.setPropertyValue("en_GB, " + espaniol);
as.saveGlobalProperty(gp);
// make sure the concept already exists
Concept concept = cs.getConcept(3);
assertNotNull(concept);
Locale spanish = LocaleUtility.fromSpecification(espaniol);
assertNotNull(concept.getDescription(britishEn, true));
assertNull(concept.getDescription(spanish, true));
ConceptFormController conceptFormController = (ConceptFormController) applicationContext.getBean("conceptForm");
MockHttpServletRequest mockRequest = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
mockRequest.setMethod("POST");
mockRequest.setParameter("action", "");
mockRequest.setParameter("conceptId", concept.getConceptId().toString());
mockRequest.setParameter("descriptionsByLocale[en_GB].description", "");
mockRequest.setParameter("descriptionsByLocale[es].description", "new spanish description");
ModelAndView mav = conceptFormController.handleRequest(mockRequest, response);
assertNotNull(mav);
assertTrue(mav.getModel().isEmpty());
Concept actualConcept = cs.getConcept(3);
assertNotNull(actualConcept);
assertNull(concept.getDescription(britishEn, true));
assertNotNull(concept.getDescription(spanish, true));
}