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));
}
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);
}
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);
}
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());
}
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());
}
Aggregations