Search in sources :

Example 1 with ConceptProposal

use of org.openmrs.ConceptProposal in project openmrs-core by openmrs.

the class ObsServiceTest method purgeObs_shouldDeleteAnyObsGroupMembersBeforeDeletingTheObs.

/**
 * @see ObsService#purgeObs(Obs,boolean)
 */
@Test
public void purgeObs_shouldDeleteAnyObsGroupMembersBeforeDeletingTheObs() {
    executeDataSet(INITIAL_OBS_XML);
    ObsService obsService = Context.getObsService();
    final int parentObsId = 1;
    Obs obs = obsService.getObs(parentObsId);
    final int childObsId = 2;
    final int unrelatedObsId = 3;
    final int orderReferencingObsId = 4;
    obs.addGroupMember(obsService.getObs(childObsId));
    obs.addGroupMember(obsService.getObs(orderReferencingObsId));
    final int conceptProposalObsId = 5;
    ConceptProposal conceptProposal = new ConceptProposal();
    conceptProposal.setObs(obsService.getObs(conceptProposalObsId));
    obs.addGroupMember(conceptProposal.getObs());
    // before calling purgeObs method the Obs exists
    Assert.assertNotNull(obsService.getObs(parentObsId));
    Assert.assertNotNull(obsService.getObs(childObsId));
    Assert.assertNotNull(obsService.getObs(unrelatedObsId));
    Assert.assertNotNull(obsService.getObs(orderReferencingObsId));
    Assert.assertNotNull(obsService.getObs(conceptProposalObsId));
    Context.getObsService().purgeObs(obs, false);
    // After calling purgeObs method Obs are deleted
    Assert.assertNull(obsService.getObs(parentObsId));
    Assert.assertNull(obsService.getObs(childObsId));
    Assert.assertNotNull(obsService.getObs(unrelatedObsId));
    Assert.assertNull(obsService.getObs(orderReferencingObsId));
    Assert.assertNull(obsService.getObs(conceptProposalObsId));
}
Also used : Obs(org.openmrs.Obs) ConceptProposal(org.openmrs.ConceptProposal) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 2 with ConceptProposal

use of org.openmrs.ConceptProposal in project openmrs-core by openmrs.

the class ConceptServiceImplTest method mapConceptProposalToConcept_shouldThrowAPIExceptionWhenMappingToNullConcept.

/**
 * @see ConceptServiceImpl#mapConceptProposalToConcept(ConceptProposal, Concept, Locale)
 */
@Test
public void mapConceptProposalToConcept_shouldThrowAPIExceptionWhenMappingToNullConcept() {
    ConceptProposal cp = conceptService.getConceptProposal(2);
    Locale locale = new Locale("en", "GB");
    expectedException.expect(APIException.class);
    conceptService.mapConceptProposalToConcept(cp, null, locale);
}
Also used : Locale(java.util.Locale) ConceptProposal(org.openmrs.ConceptProposal) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with ConceptProposal

use of org.openmrs.ConceptProposal in project openmrs-core by openmrs.

the class ConceptServiceTest method mapConceptProposalToConcept_shouldFailWhenAddingADuplicateSyonymn.

/**
 * @see ConceptService#mapConceptProposalToConcept(ConceptProposal,Concept,Locale)
 */
@Test(expected = DuplicateConceptNameException.class)
public void mapConceptProposalToConcept_shouldFailWhenAddingADuplicateSyonymn() {
    executeDataSet("org/openmrs/api/include/ConceptServiceTest-proposals.xml");
    ConceptService cs = Context.getConceptService();
    ConceptProposal cp = cs.getConceptProposal(10);
    cp.setFinalText(cp.getOriginalText());
    cp.setState(OpenmrsConstants.CONCEPT_PROPOSAL_SYNONYM);
    Concept mappedConcept = cs.getConcept(5);
    Locale locale = new Locale("en", "GB");
    mappedConcept.addDescription(new ConceptDescription("some description", locale));
    Assert.assertTrue(mappedConcept.hasName(cp.getFinalText(), locale));
    cs.mapConceptProposalToConcept(cp, mappedConcept, locale);
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) Locale(java.util.Locale) ConceptProposal(org.openmrs.ConceptProposal) ConceptDescription(org.openmrs.ConceptDescription) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 4 with ConceptProposal

use of org.openmrs.ConceptProposal in project openmrs-core by openmrs.

the class ConceptServiceTest method getConceptProposalByUuid_shouldFindObjectGivenValidUuid.

/**
 * @see ConceptService#getConceptProposalByUuid(String)
 */
@Test
public void getConceptProposalByUuid_shouldFindObjectGivenValidUuid() {
    String uuid = "57a68666-5067-11de-80cb-001e378eb67e";
    ConceptProposal conceptProposal = Context.getConceptService().getConceptProposalByUuid(uuid);
    Assert.assertEquals(1, (int) conceptProposal.getConceptProposalId());
}
Also used : ConceptProposal(org.openmrs.ConceptProposal) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 5 with ConceptProposal

use of org.openmrs.ConceptProposal in project openmrs-core by openmrs.

the class ConceptServiceTest method mapConceptProposalToConcept_shouldNotSetValueCodedNameWhenAddConceptIsSelected.

/**
 * @see ConceptService#mapConceptProposalToConcept(ConceptProposal,Concept,Locale)
 */
@Test
public void mapConceptProposalToConcept_shouldNotSetValueCodedNameWhenAddConceptIsSelected() {
    ConceptProposal cp = conceptService.getConceptProposal(2);
    Assert.assertEquals(OpenmrsConstants.CONCEPT_PROPOSAL_UNMAPPED, cp.getState());
    final Concept civilStatusConcept = conceptService.getConcept(4);
    final int mappedConceptId = 6;
    Assert.assertTrue(Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept).isEmpty());
    Concept mappedConcept = conceptService.getConcept(mappedConceptId);
    cp.setObsConcept(civilStatusConcept);
    cp.setState(OpenmrsConstants.CONCEPT_PROPOSAL_CONCEPT);
    conceptService.mapConceptProposalToConcept(cp, mappedConcept, null);
    mappedConcept = conceptService.getConcept(mappedConceptId);
    List<Obs> observations = Context.getObsService().getObservationsByPersonAndConcept(cp.getEncounter().getPatient(), civilStatusConcept);
    Assert.assertEquals(1, observations.size());
    Obs obs = observations.get(0);
    Assert.assertNull(obs.getValueCodedName());
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) Obs(org.openmrs.Obs) ConceptProposal(org.openmrs.ConceptProposal) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Aggregations

ConceptProposal (org.openmrs.ConceptProposal)11 Test (org.junit.Test)9 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)9 Concept (org.openmrs.Concept)5 Obs (org.openmrs.Obs)4 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)4 Locale (java.util.Locale)2 ConceptDescription (org.openmrs.ConceptDescription)2 Patient (org.openmrs.Patient)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 ApplicationException (ca.uhn.hl7v2.app.ApplicationException)1 DataTypeException (ca.uhn.hl7v2.model.DataTypeException)1 Message (ca.uhn.hl7v2.model.Message)1 FT (ca.uhn.hl7v2.model.v25.datatype.FT)1 ORU_R01_ORDER_OBSERVATION (ca.uhn.hl7v2.model.v25.group.ORU_R01_ORDER_OBSERVATION)1 ORU_R01_PATIENT_RESULT (ca.uhn.hl7v2.model.v25.group.ORU_R01_PATIENT_RESULT)1 MSH (ca.uhn.hl7v2.model.v25.segment.MSH)1 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)1 OBR (ca.uhn.hl7v2.model.v25.segment.OBR)1 OBX (ca.uhn.hl7v2.model.v25.segment.OBX)1