Package org.openmrs

Examples of org.openmrs.Concept


  }
 
  private Obs setObsValue(Obs obs, Object value) throws ResponseException {
    if (obs.getConcept().getDatatype().isCoded()) {
      // setValueAsString is not implemented for coded obs (in core)
      Concept valueCoded = (Concept) ConversionUtil.convert(value, Concept.class);
      obs.setValueCoded(valueCoded);
    } else if (obs.getConcept().getDatatype().isComplex()) {
      obs.setValueComplex(value.toString());
    } else {
      if (obs.getConcept().isNumeric()) {
View Full Code Here


    public void setUp() {
        patient = new Patient();
        encounter = new Encounter();
        encounter.setPatient(patient);

        unknownConcept = new Concept();

        patientService = mock(PatientService.class);
        submissionController = mock(FormSubmissionController.class);

        formEntrySession = mock(FormEntrySession.class);
View Full Code Here

    }

    @Test
    public void testSetupWithCauseOfDeath() throws Exception {
        int CONCEPT_ID = 12345;
        Concept causeOfDeath = new Concept(CONCEPT_ID);

        mockStatic(HtmlFormEntryUtil.class);
        when(HtmlFormEntryUtil.getConcept("" + CONCEPT_ID)).thenReturn(causeOfDeath);

        Map<String, String> arguments = new HashMap<String, String>();
View Full Code Here

        verify(patientService).savePatient(patient);
    }

    @Test
    public void testSettingCauseOfDeath() throws Exception {
        Concept causeOfDeath = new Concept();
        Concept lungCancer = new Concept();
        Obs causeOfDeathObs = new Obs();
        causeOfDeathObs.setConcept(causeOfDeath);
        causeOfDeathObs.setValueCoded(lungCancer);
        encounter.addObs(causeOfDeathObs);
View Full Code Here

        Map<String, String> attributes = getAttributes(node);
        if (attributes.get("groupingConceptId") == null) {
            throw new NullPointerException("obsgroup tag requires a groupingConceptId attribute");
        }
        Concept groupingConcept = HtmlFormEntryUtil.getConcept(attributes.get("groupingConceptId"));
        if (groupingConcept == null) {
            throw new NullPointerException("could not find concept " + attributes.get("groupingConceptId") + " as grouping obs for an obsgroup tag");
        }
        boolean ignoreIfEmpty = session.getContext().getMode() == Mode.VIEW && "false".equals(attributes.get("showIfEmpty"));
                   
        // avoid lazy init exception
        groupingConcept.getDatatype().getHl7Abbreviation();
              
        String name = attributes.get("label");
        // find relevant obs group to display for this element
        Obs thisGroup = findObsGroup(session, node, attributes.get("groupingConceptId"));
       
View Full Code Here

        context.registerWidget(discontinuedDateWidget);
        context.registerErrorWidget(discontinuedDateWidget, discontinuedDateErrorWidget);
        }
    if (parameters.get(FIELD_DISCONTINUED_REASON) != null){
        String discReasonConceptStr = (String) parameters.get(FIELD_DISCONTINUED_REASON);
        Concept discontineReasonConcept = HtmlFormEntryUtil.getConcept(discReasonConceptStr);
        if (discontineReasonConcept == null)
            throw new IllegalArgumentException("discontinuedReasonConceptId is not set to a valid conceptId or concept UUID");
        dof.setDiscontinuedReasonQuestion(discontineReasonConcept);

        discontinuedReasonWidget = new DropdownWidget();
        discontinuedReasonErrorWidget = new ErrorWidget();

        List<Option> discOptions = new ArrayList<Option>();
        discOptions.add(new Option("", "", false));

        if (parameters.get(FIELD_DISCONTINUED_REASON_ANSWERS) != null){
            //setup a list of the reason concepts
            List<Concept> discReasons = new ArrayList<Concept>();
            String discAnswersString = (String) parameters.get(FIELD_DISCONTINUED_REASON_ANSWERS);
            String[] strDiscAnswers = discAnswersString.split(",");
            for (int i = 0; i < strDiscAnswers.length; i++){
                String thisAnswer = strDiscAnswers[i];
                Concept answer = HtmlFormEntryUtil.getConcept(thisAnswer, "discontinueReasonAnswers includes a value that is not a valid conceptId or concept UUID");
                  discReasons.add(answer);
            }

            if (parameters.get(FIELD_DISCONTINUED_REASON_ANSWER_LABELS) != null){
                // use the listed discontinueReasons, and use labels:
View Full Code Here

        if (initialValue instanceof Drug) {
            Drug asDrug = (Drug) initialValue;
            this.initialValue = new Option(asDrug.getName(), "Drug:" + asDrug.getId(), true);
        }
        else if (initialValue instanceof Concept) {
            Concept asConcept = (Concept) initialValue;
            this.initialValue = new Option((asConcept.getName().getName()), asConcept.getConceptId().toString(), true);
        }
        else {
            this.initialValue = (Option) initialValue;
        }
    }
View Full Code Here

    @Override
    protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) throws BadFormDesignException {
        boolean deathDateFromEncounter = parseBooleanAttribute(parameters.get("deathDateFromEncounter"), true);
        boolean preserveExistingDeathDate = parseBooleanAttribute(parameters.get("preserveExistingDeathDate"), false);
        boolean preserveExistingCauseOfDeath = parseBooleanAttribute(parameters.get("preserveExistingCauseOfDeath"), false);
        Concept causeOfDeathFromObs = null;
        if (parameters.containsKey("causeOfDeathFromObs")) {
            causeOfDeathFromObs = HtmlFormEntryUtil.getConcept(parameters.get("causeOfDeathFromObs"));
        }

        Action action = new Action();
View Full Code Here

                if (patient.getDeathDate() == null || !preserveExistingDeathDate) {
                    patient.setDeathDate(encounter.getEncounterDatetime());
                }
            }
            if (patient.getCauseOfDeath() == null || !preserveExistingCauseOfDeath) {
                Concept causeOfDeath = null;
                if (causeOfDeathFromObs != null) {
                    causeOfDeath = findObsCodedValue(session.getEncounter(), causeOfDeathFromObs);
                }
                if (causeOfDeath == null) {
                    // don't overwrite with Unknown, even if we haven't specifically said to preserve existing
View Full Code Here

   * @verifies return concept id of a concept code or uuid
   */
  @Test
  public void getConcept_shouldReturnConceptWithGivenId() throws Exception {
    VelocityFunctions functions = setupFunctionsForPatient(7);
    Concept concept = Context.getConceptService ().getConcept (5089);
    Assert.assertEquals(concept.getDisplayString (), functions.getConcept ("5089").getDisplayString ());
  }
View Full Code Here

TOP

Related Classes of org.openmrs.Concept

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.