Skip to content

Commit

Permalink
concept dialog search for cui filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomolopolis committed Jul 1, 2024
1 parent 6c97269 commit 48ba4b8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
12 changes: 12 additions & 0 deletions webapp/api/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,18 @@ def generate_concept_filter(request):
return HttpResponseBadRequest('Missing either cuis or cdb_id param. Cannot generate filter.')


@api_view(http_method_names=['POST'])
def cuis_to_concepts(request):
cuis = request.data.get('cuis')
cdb_id = request.data.get('cdb_id')
if cuis is not None and cdb_id is not None:
cdb = get_cached_cdb(cdb_id, CDB_MAP)
concept_list = [{'cui': cui, 'name': cdb.cui2preferred_name[cui]} for cui in cuis]
resp = {'concept_list': concept_list}
return Response(resp)
return HttpResponseBadRequest('Missing either cuis or cdb_id param. Cannot produce concept list.')


@api_view(http_method_names=['GET'])
def project_progress(request):
projects = [int(p) for p in request.GET.get('projects', []).split(',')]
Expand Down
9 changes: 5 additions & 4 deletions webapp/api/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
path('api/concept-path/', api.views.cdb_concept_path),
path('api/generate-concept-filter-json/', api.views.generate_concept_filter_flat_json),
path('api/generate-concept-filter/', api.views.generate_concept_filter),
path('reset_password/', api.views.ResetPasswordView.as_view(), name ='reset_password'),
path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name ='password_reset_done'),
path('reset/<uidb64>/<token>', pw_views.PasswordResetConfirmView.as_view(), name ='password_reset_confirm'),
path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name ='password_reset_complete'),
path('api/cuis-to-concepts/', api.views.cuis_to_concepts),
path('reset_password/', api.views.ResetPasswordView.as_view(), name='reset_password'),
path('reset_password_sent/', pw_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
path('reset/<uidb64>/<token>', pw_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('reset_password_complete/', pw_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
re_path('^.*$', api.views.index, name='index'), # Match everything else to home
]
32 changes: 31 additions & 1 deletion webapp/frontend/src/views/TrainAnnotations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
:irrelevantEnabled="(project || {}).irrelevant_available"
:conceptSelection="conceptSynonymSelection"
@select:remove="markRemove" @select:correct="markCorrect"
@select:kill="markKill" @select:alternative="toggleAltSearch"
@select :kill="markKill" @select:alternative="toggleAltSearch"
@select:irrelevant="markIrrelevant" @submit="submitDoc"></task-bar>
</div>
</div>
Expand Down Expand Up @@ -96,6 +96,17 @@
<h4>Annotation Guidelines: <a :href="'' + project.annotation_guideline_link + ''">Guideline</a></h4>
</div>
<br>

<div>
<h4>Concepts Annotated</h4>
<div>
<loading-overlay :loading="loadingProjectConcepts">
<div slot="message">Loading Concepts</div>
</loading-overlay>

</div>
</div>
<br>
<h4>Keyboard Shortcuts</h4>
<table class="table">
<thead>
Expand Down Expand Up @@ -248,6 +259,7 @@ import MetaAnnotationTaskContainer from '@/components/usecases/MetaAnnotationTas
import RelationAnnotationTaskContainer from '@/components/usecases/RelationAnnotationTaskContainer.vue'
import AnnotationSummary from '@/components/common/AnnotationSummary.vue'
import { Multipane, MultipaneResizer } from 'vue-multipane'
import LoadingOverlay from "@/components/common/LoadingOverlay.vue"
const TASK_NAME = 'Concept Annotation'
const CONCEPT_CORRECT = 'Correct'
Expand All @@ -263,6 +275,7 @@ let LOAD_NUM_DOC_PAGES = 10 // 100 docs per page, 1000 documents
export default {
name: 'TrainAnnotations',
components: {
LoadingOverlay,
ConceptSummary,
DocumentSummary,
Modal,
Expand Down Expand Up @@ -314,6 +327,8 @@ export default {
resubmittingAllDocs: false,
resubmitSuccess: false,
helpModal: false,
projectConcepts: {},
loadingProjectConcepts: false,
projectCompleteModal: false,
resetModal: false,
conceptPickerOpen: true,
Expand Down Expand Up @@ -749,6 +764,21 @@ export default {
})
}
},
watch: {
helpModal () {
if (this.helpModal && this.projectConcepts) {
this.loadingProjectConcepts = true
let payload = {
cuis: this.project.cuis.split(','),
cdb_id: this.project.concept_db
}
this.$http.post('/api/cuis-to-concepts/', payload).then(resp => {
this.projectConcepts = resp.data.results.concept_list
this.loadingProjectConcepts = false
})
}
}
},
beforeDestroy () {
this.confirmSubmitListenerRemove()
}
Expand Down

0 comments on commit 48ba4b8

Please sign in to comment.