Custom Simple Concepts where we create??


(Hugo Lourenço) #1

Hello everyone,

We are testing our group’s module for dermatology, so we need to insert some tests concepts to make it work, but we need to insert them on the module load, which approach you guys suggest? Like insert on the DB??

Regards


(Daniel Kayiwa) #2

Is this of any help? https://wiki.openmrs.org/display/docs/Metadata+Deploy+Module


(Andrew Kanter) #3

Are these concepts in CIEL? If they are not just for testing but have real usefulness, I would want to know about them :slight_smile:


(Hugo Lourenço) #5

@akanter, This concepts are costume , they are from a conversation with a medic, they arent from any entity


(Andrew Kanter) #6

You can just use the UI to make the concepts but if you send them to me or list them here I can add them to the CIEL dictionary


(Hugo Lourenço) #7

@dkayiwa , i created my own concepts through the API, but now i want to everybody thats install the module get this concepts, i have been looking your link that you sent me, but theres non a Concept constructor…

can i do like this?

 Concept c = new ConceptBuilder("9876543210")
.datatype(existing(ConceptDatatype.class, "8d4a4ab4-c2cc-11de-8d13-0010c6dffd0f"))
.conceptClass(existing(ConceptClass.class, "a82ef63c-e4e4-48d6-988a-fdd74d7541a7"))
.name(new ConceptName("Test Concept", Locale.ENGLISH))
.description(new ConceptDescription("Its just a testing Concept", Locale.ENGLISH)).build();
deployService.installObject( c ); 

also, i didnt found any an example thats using AbstractMetadataBundle, because i cant config rigth the @Requires({ BaseMetadata.class }), im having issues loading on my intellij( Cant find BaseMetadata.class), so i tryed with @Requires({ }) empty, but theres a Spring error:

HTTP Status 500 - Error creating bean with name 'sessionFactory': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public java.util.Map org.openmrs.api.db.hibernate.HibernateSessionFactoryBean.interceptors; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.openmrs.module.dermatology.MyMetaData] for bean with name 'myMetaData' defined in URL [jar:file:/C:/Users/Hugo/openmrs/openmrs/.openmrs-lib-cache/dermatology/lib/dermatology-api-1.0.0-SNAPSHOT.jar!/org/openmrs/module/dermatology/MyMetaData.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/openmrs/module/metadatadeploy/bundle/AbstractMetadataBundle


(Daniel Kayiwa) #8

Is this method of help? https://github.com/openmrs/openmrs-module-referencemetadata/blob/master/api/src/main/java/org/openmrs/module/referencemetadata/ReferenceMetadataActivator.java#L77-L129

The concept files that are being loaded can be found at? https://github.com/openmrs/openmrs-module-referencemetadata/tree/master/api/src/main/resources


(Hugo Lourenço) #9

it gives me a Exception, this is weird because the project it builds without errors… not sure what is this time…

INFO - LoggingAdvice.invoke(155) |2018-07-06 14:37:51,104| Exiting method saveGlobalProperty
Exception in thread "Thread-8" java.lang.NoClassDefFoundError: org/openmrs/module/dataexchange/DataImporter
        at org.openmrs.module.dermatology.DermatologyActivator.started(DermatologyActivator.java:46)
        at org.openmrs.module.ModuleUtil.refreshApplicationContext(ModuleUtil.java:881)
        at org.openmrs.module.web.WebModuleUtil.refreshWAC(WebModuleUtil.java:866)
        at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:658)
        at org.openmrs.web.Listener.performWebStartOfModules(Listener.java:637)
        at org.openmrs.web.Listener.startOpenmrs(Listener.java:268)
        at org.openmrs.web.WebDaemon$1.run(WebDaemon.java:42)
Caused by: java.lang.ClassNotFoundException: org.openmrs.module.dataexchange.DataImporter
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)
        at org.openmrs.module.ModuleClassLoader.loadClass(ModuleClassLoader.java:571)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
WARN - OpenmrsUtil.getRuntimePropertiesFilePathName(2113) |2018-07-06 14:37:51,481| Unable to find a runtime properties file at C:\Users\Hugo\Desktop\openmrs-runtime.properties
jul 06, 2018 2:37:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]

my activator start method its here


(Daniel Kayiwa) #10

Have you added the dataexchange module as required in your module’s config.xml?


(Hugo Lourenço) #11

i didnt, Always on check :joy::joy::joy:


(Hugo Lourenço) #12

@dkayiwa , can i create “htmlformentry_html_form” from a xml, or is just a core thing?


(Daniel Kayiwa) #13

What is the use case?


(Hugo Lourenço) #14

its the same case, i have 3 forms all with an “htmlformentry_html_form” entry, or better doing load from the DB?


(Daniel Kayiwa) #15

You could load the forms like here: https://github.com/openmrs/openmrs-module-referenceapplication/blob/master/api/src/main/java/org/openmrs/module/referenceapplication/ReferenceApplicationActivator.java#L106


(Hugo Lourenço) #16

worked fine over here!!

Just more 1 question, i searched on “referenceapplication” but couldnt find anything, how to create from the Activator an entry on table “form_resource” by code?? so when i want my forms on the patient dashboard , or should i load them from DB


(Daniel Kayiwa) #17

You can save the necessary entries into the form_resource table from your module’s activator.


(Hugo Lourenço) #18

hello @dkayiwa , im having a problem on creating form_resource, i have this method running on Module Activator, i have zero errors but the problem is the form dont appears on “visit actions”. Then i went to Configure Metadata -> Forms, and there it was with the UI tab with visit actions so i clicked on edit and made no change then save… it started appears from that point… What im doing wrong?

Regards, Hugo


(Hugo Lourenço) #19

Solved, i was missing the new AppFrameworkActivator().contextRefreshed(); after the save