當前位置: 首頁>>代碼示例>>Java>>正文


Java ConceptService類代碼示例

本文整理匯總了Java中org.openmrs.api.ConceptService的典型用法代碼示例。如果您正苦於以下問題:Java ConceptService類的具體用法?Java ConceptService怎麽用?Java ConceptService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConceptService類屬於org.openmrs.api包,在下文中一共展示了ConceptService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:17,代碼來源:DWRConceptService.java

示例2: findDrugs

import org.openmrs.api.ConceptService; //導入依賴的package包/類
public List<Object> findDrugs(String phrase, boolean includeRetired) throws APIException {
	if (includeRetired) {
		throw new APIException("you.should.not.included.voideds", (Object[]) null);
	}
	Locale locale = Context.getLocale();
	ConceptService cs = Context.getConceptService();
	
	List<Object> items = new ArrayList<Object>();
	
	// find drugs for this concept
	Set<Drug> drugs = new HashSet<Drug>();
	
	// also find drugs by given phrase, assuming that 
	// this phrase is a list of concept words
	drugs.addAll(cs.getDrugs(phrase));
	
	// miniaturize our drug objects
	for (Drug drug : drugs) {
		items.add(new ConceptDrugListItem(drug, locale));
	}
	
	return items;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:24,代碼來源:DWRConceptService.java

示例3: processFormSubmission

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * @see org.springframework.web.servlet.mvc.AbstractFormController#processFormSubmission(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object object,
        BindException errors) throws Exception {
	
	Concept concept = (Concept) object;
	ConceptService cs = Context.getConceptService();
	
	// check to see if they clicked next/previous concept:
	String jumpAction = request.getParameter("jumpAction");
	if (jumpAction != null) {
		Concept newConcept = null;
		if ("previous".equals(jumpAction)) {
			newConcept = cs.getPrevConcept(concept);
		} else if ("next".equals(jumpAction)) {
			newConcept = cs.getNextConcept(concept);
		}
		
		if (newConcept != null) {
			return new ModelAndView(new RedirectView(getSuccessView() + "?conceptId=" + newConcept.getConceptId()));
		}
		
	}
	
	return new ModelAndView(new RedirectView(getSuccessView()));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:30,代碼來源:ConceptStatsFormController.java

示例4: handleSubmission

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * Handle the delete action
 * 
 * @param session http session
 * @param conceptStopWordsToBeDeleted array of words to be deleted
 * @return ConceptStopWordList view
 * @should delete the given ConceptStopWord in the request parameter
 * @should add the success delete message in session attribute
 * @should add the already deleted error message in session attribute if delete the same word
 *         twice
 */
@RequestMapping(method = RequestMethod.POST)
public String handleSubmission(HttpSession session,
        @RequestParam(required = false, value = "conceptStopWord") String[] conceptStopWordsToBeDeleted) {
	if (conceptStopWordsToBeDeleted != null) {
		
		ConceptService conceptService = Context.getConceptService();
		for (String conceptStopWordToBeDeleted : conceptStopWordsToBeDeleted) {
			try {
				conceptService.deleteConceptStopWord(Integer.valueOf(conceptStopWordToBeDeleted));
				session.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "general.deleted");
			}
			catch (ConceptStopWordException e) {
				session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, e.getMessage());
			}
		}
	} else {
		session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "ConceptStopWord.error.notSelect");
	}
	
	return showForm(session);
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:33,代碼來源:ConceptStopWordListController.java

示例5: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 * 
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	ConceptProposal cp = null;
	
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		String id = request.getParameter("conceptProposalId");
		if (id != null) {
			cp = cs.getConceptProposal(Integer.valueOf(id));
		}
	}
	
	if (cp == null) {
		cp = new ConceptProposal();
	}
	
	return cp;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:25,代碼來源:ConceptProposalFormController.java

示例6: onSubmit

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * The onSubmit function receives the form/command object that was modified by the input form
 * and saves it to the db
 *
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 */
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj,
        BindException errors) throws Exception {
	
	HttpSession httpSession = request.getSession();
	
	String view = getFormView();
	
	if (Context.isAuthenticated()) {
		// this concept proposal
		ConceptProposal cp = (ConceptProposal) obj;
		
		// this proposal's final text
		ConceptService cs = Context.getConceptService();
		
		cp.setCreator(Context.getAuthenticatedUser());
		cp.setDateCreated(new Date());
		
		cs.saveConceptProposal(cp);
		
		view = getSuccessView();
		httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "ConceptProposal.proposed");
	}
	
	return new ModelAndView(new RedirectView(view));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:34,代碼來源:ProposeConceptFormController.java

示例7: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 *
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	ConceptProposal cp = new ConceptProposal();
	
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		EncounterService es = Context.getEncounterService();
		String id = ServletRequestUtils.getStringParameter(request, "encounterId");
		if (id != null) {
			cp.setEncounter(es.getEncounter(Integer.valueOf(id)));
		}
		
		id = ServletRequestUtils.getStringParameter(request, "obsConceptId");
		if (id != null) {
			cp.setObsConcept(cs.getConcept(Integer.valueOf(id)));
		}
		
	}
	
	return cp;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:28,代碼來源:ProposeConceptFormController.java

示例8: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 * 
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	Drug drug = null;
	
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		String id = request.getParameter("drugId");
		if (id != null) {
			drug = cs.getDrug(Integer.valueOf(id));
		}
	}
	
	if (drug == null) {
		drug = new Drug();
	}
	
	return drug;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:25,代碼來源:ConceptDrugFormController.java

示例9: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 * 
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */

protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	//HttpSession httpSession = request.getSession();
	
	// default empty Object
	List<Drug> conceptDrugList = new Vector<Drug>();
	
	//only fill the Object if the user has authenticated properly
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		conceptDrugList = cs.getAllDrugs();
	}
	
	return conceptDrugList;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:23,代碼來源:ConceptDrugListController.java

示例10: handleSubmit

import org.openmrs.api.ConceptService; //導入依賴的package包/類
@RequestMapping(value = "/admin/concepts/conceptAttributeType", method = RequestMethod.POST)
public String handleSubmit(WebRequest request, @ModelAttribute("attributeType") ConceptAttributeType conceptAttributeType,
                           BindingResult errors) {
    if(Context.isAuthenticated()) {
        ConceptService conceptService = Context.getConceptService();
        if (request.getParameter("purge") != null) {
            return purgeConceptAttributeType(request, conceptAttributeType, conceptService);
        }
        new ConceptAttributeTypeValidator().validate(conceptAttributeType, errors);
        if (!errors.hasErrors()) {
            if (request.getParameter("retire") != null) {
                return retireConceptAttributeType(request, conceptAttributeType, errors);
            }
            if (request.getParameter("save") != null) {
                return saveConceptAttributeType(request, conceptAttributeType, conceptService);
            }
            if (request.getParameter("unretire") != null) {
                return unretireConceptAttributeType(request, conceptAttributeType);
            }
        }
    }
    return null;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:24,代碼來源:ConceptAttributeTypeFormController.java

示例11: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 *
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	ConceptClass conceptClass = null;
	
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		String conceptClassId = request.getParameter("conceptClassId");
		if (conceptClassId != null) {
			conceptClass = cs.getConceptClass(Integer.valueOf(conceptClassId));
		}
	}
	
	if (conceptClass == null) {
		conceptClass = new ConceptClass();
	}
	
	return conceptClass;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:25,代碼來源:ConceptClassFormController.java

示例12: formBackingObject

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 *
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 */
protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	
	ConceptSource conceptSource = null;
	
	if (Context.isAuthenticated()) {
		ConceptService cs = Context.getConceptService();
		String conceptSourceId = request.getParameter("conceptSourceId");
		if (conceptSourceId != null) {
			conceptSource = cs.getConceptSource(Integer.valueOf(conceptSourceId));
		}
	}
	
	if (conceptSource == null) {
		conceptSource = new ConceptSource();
	}
	
	return conceptSource;
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:25,代碼來源:ConceptSourceFormController.java

示例13: printConcept_shouldPrintTheNameWithTheCorrectLocaleNameAndType

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * @see FormatTag#printConcept(StringBuilder,Concept)
 * @verifies print the name with the correct name, and type
 */
@Test
public void printConcept_shouldPrintTheNameWithTheCorrectLocaleNameAndType() throws Exception {
	ConceptService service = Context.getConceptService();
	Locale locale = Context.getLocale();
	ConceptNameTag tag = service.getConceptNameTag(5);
	ConceptNameTag anotherTag = service.getConceptNameTag(6);
	Context.flushSession();
	
	Concept c = new Concept();
	c.addName(buildName("English fully specified", locale, true, ConceptNameType.FULLY_SPECIFIED, null));
	c.addName(buildName("English synonym", locale, false, null, null));
	c.addName(buildName("English tag", locale, false, null, tag));
	c.addName(buildName("English another tag", locale, false, null, anotherTag));
	c.addDescription(new ConceptDescription("some description", null));
	c.setDatatype(service.getConceptDatatype(1));
	c.setConceptClass(service.getConceptClass(1));
	
	Context.getConceptService().saveConcept(c);
	
	assertPrintConcept("English fully specified", c, null, null);
	assertPrintConcept("English fully specified", c, ConceptNameType.FULLY_SPECIFIED.toString(), null);
	assertPrintConcept("English tag", c, null, tag.getTag());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:28,代碼來源:FormatTagTest.java

示例14: printConcept_shouldEscapeHtmlTags

import org.openmrs.api.ConceptService; //導入依賴的package包/類
/**
 * @see FormatTag#printConcept(StringBuilder,Concept)
 * @verifies escape html tags
 */
@Test
public void printConcept_shouldEscapeHtmlTags() throws Exception {
	ConceptService service = Context.getConceptService();
	Locale locale = Context.getLocale();
	ConceptNameTag tag = service.getConceptNameTag(5);
	ConceptNameTag anotherTag = service.getConceptNameTag(6);
	Context.flushSession();
	
	Concept c = new Concept();
	c.addName(buildName("English fully\"><script>alert('xss possible!')</script> specified", locale, true,
	    ConceptNameType.FULLY_SPECIFIED, null));
	c.addDescription(new ConceptDescription("some description", null));
	c.setDatatype(service.getConceptDatatype(1));
	c.setConceptClass(service.getConceptClass(1));
	
	Context.getConceptService().saveConcept(c);
	FormatTag format = new FormatTag();
	format.setWithConceptNameType(ConceptNameType.FULLY_SPECIFIED.toString());
	format.setWithConceptNameTag(null);
	StringBuilder sb = new StringBuilder();
	format.printConcept(sb, c);
	
	Assert.assertThat(sb.toString(), Matchers.not(Matchers.containsString("<script>")));
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:29,代碼來源:FormatTagTest.java

示例15: createObservation_shouldCreateObservationWithCodedConcept

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 coded concepts", method = "createObs(Integer, Integer,Integer, String, String)")
public void createObservation_shouldCreateObservationWithCodedConcept() throws Exception {
	DWRObsService dwrService = new DWRObsService();
	ConceptService conceptService = Context.getConceptService();
	ObsService obsService = Context.getObsService();
	Person person = Context.getPersonService().getPerson(2);
	Concept concept = conceptService.getConcept(21);
	List<Obs> obsListBefore = obsService.getObservationsByPersonAndConcept(person, concept);
	dwrService.createObs(2, null, 21, "7", "1/12/2014");
	List<Obs> obsListAfter = obsService.getObservationsByPersonAndConcept(person, concept);
	assertEquals(obsListBefore.size() + 1, obsListAfter.size());
	Concept answerConcept = conceptService.getConcept(7);
	Obs addedObs = (Obs) CollectionUtils.subtract(obsListAfter, obsListBefore).iterator().next();
	assertNotNull(addedObs);
	assertNotNull(addedObs.getValueCoded());
	assertEquals(answerConcept, addedObs.getValueCoded());
}
 
開發者ID:openmrs,項目名稱:openmrs-module-legacyui,代碼行數:22,代碼來源:DWRObservationServiceTest.java


注:本文中的org.openmrs.api.ConceptService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。