Cannot create concepts of type numeric


I am trying to create concepts using a csv file. I was able to create concepts with all other datatypes apart numeric concepts.

Sample CSV file:

“concept”,“Concept Name”,“Concept Description”,“Concept Type”,“Concept Class”,“Coded Options”,“Concept UUID”,“Is a Set”,“Set Members”,“shouldUpdate”

“987654”,“Pain Level”,"",“Numeric”,“Symptom”,"",“970a017c-195b-4fc0-9608-9a4679987654”,“false”,"",“false”

So what i am trying to do is create a concept numeric using the following logic:

if (dataType.isNumeric()) {

			concept = new ConceptNumericBuilder(uuid).name(conceptName).datatype(dataType).precise(true)
			        .description(uuid, description, Locale.ENGLISH).conceptClass(dataClass).build();

So this works and I am able to create a concept numeric with entries in concept and conceptnumeric table… But I want to edit the concept id with the id provided in the file.

I normally do it using service.saveConcept(id);

but in this case since the id is present as a foreign key in concept_numeric table. It doesnt let me update the id with foreign key constraint error.

I would like to know if there is a way to create a concept first so that i can update the concept id from csv and use that concept to create numeric?

1 Like

You should never be assigning values for a database primary key column.


I understand, but the id’s are used in html forms and so we need to create those concepts with the same ID’s. I was able to do it using the following:

Created a concept first and then updated concept’s id concept.setConceptId(id)); Then I did the following:

ConceptNumeric conceptNumeric = new ConceptNumeric(concept);



I believe html forms support uuids, you should be fixing the forms instead to use uuids and not ids.

I agree html forms should use uuid’s but the here the developers used conceptid’s instead and it will be a pain to go to all the forms and update the concept ID’s with uuid’s now.

Well, you can’t update the conceptId, you only got 2 options, either to set the id before saving the concept or update your forms to use uuids.

The dataexchange module allows you to create concepts with specified concept_ids. It is used in the referenceapplication here:

I went with option 1 for now, till we find a way to update uuid’s in the forms. Created a concept with the id in the file first and then created a concept numeric using:

ConceptNumeric conceptNumeric = new ConceptNumeric(concept);

Worked! Thanks! See you next week.