use of org.openmrs.ConceptSource in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method searchNonCoded.
public List<SimpleObject> searchNonCoded(UiSessionContext context, UiUtils ui, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("emrConceptService") EmrConceptService emrConceptService, @RequestParam("term") String query, @RequestParam(value = "start", defaultValue = "0") Integer start, @RequestParam(value = "size", defaultValue = "50") Integer size) throws Exception {
Collection<Concept> diagnosisSets = emrApiProperties.getDiagnosisSets();
Locale locale = context.getLocale();
List<ConceptSource> sources = emrApiProperties.getConceptSourcesForDiagnosisSearch();
List<ConceptSearchResult> hits = emrConceptService.conceptSearch(query, locale, null, diagnosisSets, sources, null);
List<SimpleObject> ret = new ArrayList<SimpleObject>();
for (ConceptSearchResult hit : hits) {
ret.add(simplify(hit, ui, locale));
}
return ret;
}
use of org.openmrs.ConceptSource in project openmrs-module-coreapps by openmrs.
the class EncounterDiagnosesElement method generateHtml.
@Override
public String generateHtml(FormEntryContext context) {
List<Diagnosis> existingDiagnoses = getExistingDiagnoses(context, emrApiProperties.getDiagnosisMetadata());
if (FormEntryContext.Mode.VIEW == context.getMode()) {
StringBuilder sb = new StringBuilder();
if (existingDiagnoses != null) {
List<ConceptSource> conceptSourcesForDiagnosisSearch = emrApiProperties.getConceptSourcesForDiagnosisSearch();
for (Diagnosis diagnosis : existingDiagnoses) {
sb.append("<p><small>");
// question (e.g. "Primary diagnosis")
sb.append(message("coreapps.patientDashBoard.diagnosisQuestion." + diagnosis.getOrder()));
sb.append("</small><span>");
// answer (e.g. "(Confirmed) Malaria [code]")
sb.append("(" + message("coreapps.Diagnosis.Certainty." + diagnosis.getCertainty()) + ") ");
sb.append(diagnosis.getDiagnosis().formatWithCode(getLocale(), conceptSourcesForDiagnosisSearch));
sb.append("</span></p>");
}
}
return sb.toString();
} else {
hiddenDiagnoses = new HiddenFieldWidget();
errorWidget = new ErrorWidget();
context.registerWidget(hiddenDiagnoses);
context.registerErrorWidget(hiddenDiagnoses, errorWidget);
try {
Map<String, Object> fragmentConfig = new HashMap<String, Object>();
fragmentConfig.put("formFieldName", "encounterDiagnoses");
fragmentConfig.put("existingDiagnoses", existingDiagnoses);
// add the prior diagnoses if requested
if (FormEntryContext.Mode.ENTER == context.getMode() && dispositionTypeForPriorDiagnoses != null) {
fragmentConfig.put("priorDiagnoses", getPriorDiagnoses(context, dispositionTypeForPriorDiagnoses));
}
try {
StringBuilder output = new StringBuilder();
output.append(errorWidget.generateHtml(context));
output.append(uiUtils.includeFragment("coreapps", "diagnosis/encounterDiagnoses", fragmentConfig));
if (selectedDiagnosesTarget != null) {
output.append("\n <script type=\"text/javascript\"> \n $(function() { $('#display-encounter-diagnoses-container').appendTo('" + selectedDiagnosesTarget + "'); }); \n </script>");
}
return output.toString();
} catch (NullPointerException ex) {
// (This is hacky, but I don't see a better way to do it.)
return "Submitting the form, so we don't generate HTML";
}
} catch (PageAction pageAction) {
throw new IllegalStateException("Included fragment threw a PageAction", pageAction);
}
}
}
use of org.openmrs.ConceptSource in project openmrs-module-coreapps by openmrs.
the class DiagnosesFragmentController method search.
public List<SimpleObject> search(UiSessionContext context, UiUtils ui, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("emrConceptService") EmrConceptService emrConceptService, @RequestParam("term") String query, @RequestParam(value = "start", defaultValue = "0") Integer start, @RequestParam(value = "size", defaultValue = "50") Integer size) throws Exception {
Collection<Concept> diagnosisSets = emrApiProperties.getDiagnosisSets();
Locale locale = context.getLocale();
List<ConceptSource> sources = emrApiProperties.getConceptSourcesForDiagnosisSearch();
List<ConceptSearchResult> hits = emrConceptService.conceptSearch(query, locale, null, diagnosisSets, sources, null);
List<SimpleObject> ret = new ArrayList<SimpleObject>();
for (ConceptSearchResult hit : hits) {
ret.add(simplify(hit, ui, locale));
}
return ret;
}
use of org.openmrs.ConceptSource in project openmrs-module-pihcore by PIH.
the class FamilyHistoryRelativeCheckboxesTagHandlerTest 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);
// standardTestDataset actually has "is-a" instead of narrower than. Hopefully this works for our test
ConceptMapType narrowerThan = MetadataUtils.existing(ConceptMapType.class, "1ce7a784-7d8f-11e1-909d-c80aa9edcf4e");
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 famHxDiagnosis = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_DIAGNOSIS).datatype(coded).conceptClass(// CIEL says Diagnosis, but this is wrong
misc).name("109016BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history diagnosis", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).mapping(new ConceptMapBuilder("217715ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160592").build()).build());
// CIEL:1560 (Family Member) is both a question and an answer. At PIH we have two existing concepts for this purpose.
// This one is only used as a question, so we mark it as NARROWER-THAN CIEL:1560. (And we want to test this here.)
Concept famHxRelationship = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_RELATIONSHIP).datatype(coded).conceptClass(question).name("3e2256c6-26fe-102b-80cb-0017a47871b2", "RELATIONSHIP OF RELATIVE TO PATIENT", Locale.ENGLISH, // locale-preferred
ConceptNameType.FULLY_SPECIFIED).name("93bc0d72-07d4-102c-b5fa-0017a47871b2", "CONTACT_REL", Locale.ENGLISH, ConceptNameType.SHORT).name("f672a35a-d5db-102d-ad2a-000c29c2a5d7", "RELATION DU PARENT PAR RAPPORT AU PATIENT", Locale.FRENCH, // locale-preferred
null).description("ecf0bb66-07fe-102c-b5fa-0017a47871b2", "What is the relationship of this relative to this patient?", Locale.ENGLISH).mapping(new ConceptMapBuilder("e9335480-d593-11e4-9dcf-b36e1005e77b").type(narrowerThan).ensureTerm(ciel, "1560").build()).answers(// other options not needed for this test
father).build());
Concept famHxComment = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_COMMENT).datatype(text).conceptClass(question).name("109055BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history comment", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).mapping(new ConceptMapBuilder("217741ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160618").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());
Concept famHxConstruct = install(new ConceptBuilder(ClinicalConsultationConcepts.Concepts.FAMILY_HISTORY_CONSTRUCT).datatype(notApplicable).conceptClass(// CIEL says Finding but that's not necessary for the test
misc).name("109017BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Patient's family history list", Locale.ENGLISH, ConceptNameType.FULLY_SPECIFIED).name("109019BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB", "Family history list", Locale.ENGLISH, null).setMembers(famHxDiagnosis, famHxRelationship, isSymptomPresent, famHxComment).mapping(new ConceptMapBuilder("217716ABBBBBBBBBBBBBBBBBBBBBBBBBBBBB").type(sameAs).ensureTerm(ciel, "160593").build()).build());
}
use of org.openmrs.ConceptSource in project openmrs-core by openmrs.
the class AdministrationServiceImpl method setImplementationId.
/**
* @see org.openmrs.api.AdministrationService#setImplementationId(org.openmrs.ImplementationId)
*/
@Override
public void setImplementationId(ImplementationId implementationId) throws APIException {
if (implementationId == null) {
return;
}
// check the validity of this implementation id with the server
String description = implementationId.getDescription();
try {
// check that source id is valid
description = checkImplementationIdValidity(implementationId.getImplementationId(), description, implementationId.getPassphrase());
// save the server's description back to this concept source object
implementationId.setDescription(description);
boolean foundMatchingSource = false;
// loop over the concept sources to make sure one exists for this hl7Code/implementationId
List<ConceptSource> sources = Context.getConceptService().getAllConceptSources(false);
if (sources != null) {
for (ConceptSource source : sources) {
if (implementationId.getImplementationId().equals(source.getHl7Code())) {
foundMatchingSource = true;
}
}
}
// as a new ConceptSource
if (!foundMatchingSource) {
ConceptSource newConceptSource = new ConceptSource();
newConceptSource.setName(implementationId.getName());
newConceptSource.setDescription(implementationId.getDescription());
newConceptSource.setHl7Code(implementationId.getImplementationId());
if (Context.getAuthenticatedUser() == null) {
// (hackish)
// fake the user because no one is logged in
newConceptSource.setCreator(new User(1));
}
Context.getConceptService().saveConceptSource(newConceptSource);
}
// serialize and save the ImplementationId to the global properties table
String value = Context.getSerializationService().getDefaultSerializer().serialize(implementationId);
Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_IMPLEMENTATION_ID, value));
} catch (APIException e) {
throw e;
} catch (Exception e) {
// pass any other exceptions on up the train
throw new APIException(e);
} finally {
// save an empty concept source to the database when something fails?
}
}
Aggregations