use of org.openmrs.ConceptDatatype in project openmrs-module-pihcore by PIH.
the class PastMedicalHistoryCheckboxTagHandlerTest method setupConcepts.
private void setupConcepts() throws Exception {
// copied from some pihcore concept setup, but tweaked to work with standardTestDataset.xml
ConceptDatatype coded = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.CODED);
ConceptDatatype text = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.TEXT);
ConceptDatatype notApplicable = MetadataUtils.existing(ConceptDatatype.class, CoreConceptMetadataBundle.ConceptDatatypes.N_A);
ConceptClass diagnosis = MetadataUtils.existing(ConceptClass.class, "938834bf-a745-4dbd-b611-f06a9a5a3060");
ConceptClass question = MetadataUtils.existing(ConceptClass.class, "a82ef63c-e4e4-48d6-988a-fdd74d7541a7");
ConceptClass misc = MetadataUtils.existing(ConceptClass.class, "ecdee8a7-d741-4fe7-8e01-f79cacbe97bc");
ConceptMapType sameAs = MetadataUtils.existing(ConceptMapType.class, CoreConceptMetadataBundle.ConceptMapTypes.SAME_AS);
ConceptSource ciel = conceptSource("CIEL", "Columbia International eHealth Laboratory concept ID", null, CoreConceptMetadataBundle.ConceptSources.CIEL);
conceptService.saveConceptSource(ciel);
// these are in standardTestDataset.xml
Concept no = conceptService.getConcept(8);
Concept unknown = conceptService.getConcept(22);
// need this to have a different UUID to match our dictionary
yes = conceptService.getConcept(7);
yes.setUuid(CommonConcepts.Concepts.YES);
conceptService.saveConcept(yes);
Concept pmhWhich = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_FINDING).datatype(coded).conceptClass(diagnosis).name("1908BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Past medical history finding", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).description("1470FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "Coded list of past medical history problems but not procedures which are coded under Past Surgical History.", Locale.ENGLISH).mapping(new ConceptMapBuilder("171868ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "1628").build()).build());
Concept isSymptomPresent = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_PRESENCE).datatype(coded).conceptClass(diagnosis).name("2009BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Sign/symptom present", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).answers(yes, no, unknown).mapping(new ConceptMapBuilder("171968ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "1729").build()).build());
// TODO waiting for confirmation from Andy that this is appropriate as comments
Concept pmhComment = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_COMMENT).datatype(text).conceptClass(question).name("108123BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Past medical history added (text)", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).mapping(new ConceptMapBuilder("217354ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160221").build()).build());
Concept pmhConstruct = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.PAST_MEDICAL_HISTORY_CONSTRUCT).datatype(notApplicable).conceptClass(misc).name("1913BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Past medical history", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).name("86916BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "PMH", Locale.ENGLISH, ConceptNameType.SHORT).setMembers(pmhWhich, isSymptomPresent, pmhComment).mapping(new ConceptMapBuilder("171873ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "1633").build()).build());
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class HibernateConceptDAO method getSavedConceptDatatype.
/**
* @see org.openmrs.api.db.ConceptDAO#getSavedConceptDatatype(org.openmrs.Concept)
*/
@Override
public ConceptDatatype getSavedConceptDatatype(Concept concept) {
SQLQuery sql = sessionFactory.getCurrentSession().createSQLQuery("select datatype.* from " + "concept_datatype datatype, " + "concept concept " + "where " + "datatype.concept_datatype_id = concept.datatype_id " + "and concept.concept_id=:conceptId").addEntity(ConceptDatatype.class);
sql.setInteger("conceptId", concept.getConceptId());
return (ConceptDatatype) sql.uniqueResult();
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class OrderServiceTest method saveOrderFrequency_shouldAddANewOrderFrequencyToTheDatabase.
/**
* @see OrderService#saveOrderFrequency(OrderFrequency)
*/
@Test
public void saveOrderFrequency_shouldAddANewOrderFrequencyToTheDatabase() {
Concept concept = new Concept();
concept.addName(new ConceptName("new name", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setDatatype(new ConceptDatatype(1));
concept.setConceptClass(conceptService.getConceptClassByName("Frequency"));
concept = conceptService.saveConcept(concept);
Integer originalSize = orderService.getOrderFrequencies(true).size();
OrderFrequency orderFrequency = new OrderFrequency();
orderFrequency.setConcept(concept);
orderFrequency.setFrequencyPerDay(2d);
orderFrequency = orderService.saveOrderFrequency(orderFrequency);
assertNotNull(orderFrequency.getId());
assertNotNull(orderFrequency.getUuid());
assertNotNull(orderFrequency.getCreator());
assertNotNull(orderFrequency.getDateCreated());
assertEquals(originalSize + 1, orderService.getOrderFrequencies(true).size());
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldPassIfTheConceptHasASynonymThatIsAlsoAShortName.
@Test
public void validate_shouldPassIfTheConceptHasASynonymThatIsAlsoAShortName() {
concept.addName(new ConceptName("CD4", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass());
concept.setDatatype(new ConceptDatatype());
// Add the short name. Because the short name is not counted as a Synonym.
// ConceptValidator will not record any errors.
ConceptName name = new ConceptName("CD4", Context.getLocale());
name.setConceptNameType(ConceptNameType.SHORT);
concept.addName(name);
validator.validate(concept, errors);
Assert.assertFalse(errors.hasErrors());
}
use of org.openmrs.ConceptDatatype in project openmrs-core by openmrs.
the class ConceptValidatorTest method validate_shouldFailValidationIfFieldLengthsAreNotCorrect.
@Test
public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
concept.addName(new ConceptName("CD4", Context.getLocale()));
concept.addDescription(new ConceptDescription("some description", null));
concept.setConceptClass(new ConceptClass());
concept.setDatatype(new ConceptDatatype());
concept.setVersion("too long text too long text too long text too long text");
concept.setRetireReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
validator.validate(concept, errors);
assertThat(errors, hasFieldErrors("version", "error.exceededMaxLengthOfField"));
assertThat(errors, hasFieldErrors("retireReason", "error.exceededMaxLengthOfField"));
}
Aggregations