Skip to content

Commit

Permalink
feat: mesh codes
Browse files Browse the repository at this point in the history
fix!: fix code list regex issue; note the class name changes to elements
  • Loading branch information
JackScanlon committed Nov 4, 2024
1 parent 386f3c2 commit 6e47737
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.1.2 on 2024-10-24 14:23

import django.contrib.postgres.indexes
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('clinicalcode', '0116_ontology_descendants'),
]

operations = [
migrations.AddIndex(
model_name='icd_9_codes',
index=django.contrib.postgres.indexes.GinIndex(fields=['code'], name='icd9_code_ln_gin_idx', opclasses=['gin_trgm_ops']),
),
migrations.AddIndex(
model_name='icd_9_codes',
index=django.contrib.postgres.indexes.GinIndex(fields=['description'], name='icd9_desc_ln_gin_idx', opclasses=['gin_trgm_ops']),
),
]
33 changes: 33 additions & 0 deletions CodeListLibrary_project/clinicalcode/migrations/0118_mesh_codes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.1.2 on 2024-11-04 20:13

import datetime
import django.contrib.postgres.fields
import django.contrib.postgres.indexes
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('clinicalcode', '0117_icd_9_codes_icd9_code_ln_gin_idx_and_more'),
]

operations = [
migrations.CreateModel(
name='MESH_CODES',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
('code', models.CharField(blank=True, default='', max_length=10, null=True)),
('description', models.CharField(blank=True, default='', max_length=256, null=True)),
('parent_codes', django.contrib.postgres.fields.ArrayField(base_field=models.TextField(), blank=True, null=True, size=None)),
('record_type', models.IntegerField(blank=True, default=0, null=True)),
('record_category', models.IntegerField(blank=True, default=0, null=True)),
('record_modifier', models.IntegerField(blank=True, default=0, null=True)),
('active', models.BooleanField(blank=True, default=True, null=True)),
('effective_time', models.DateField(blank=True, default=datetime.date.today, null=True)),
],
options={
'indexes': [django.contrib.postgres.indexes.GinIndex(fields=['code'], name='mesh_code_ln_gin_idx', opclasses=['gin_trgm_ops']), django.contrib.postgres.indexes.GinIndex(fields=['description'], name='mesh_desc_ln_gin_idx', opclasses=['gin_trgm_ops'])],
},
),
]
15 changes: 15 additions & 0 deletions CodeListLibrary_project/clinicalcode/models/ICD_9_CODES.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.db import models
from django.contrib.postgres.indexes import GinIndex

class ICD_9_CODES(models.Model):
code = models.CharField(max_length=50, null=True, blank=True)
Expand All @@ -10,3 +11,17 @@ class ICD_9_CODES(models.Model):
effective_from = models.DateTimeField(null=True, blank=True)
effective_to = models.DateField(null=True, blank=True)
avail_from_dt = models.DateField(null=True, blank=True)

class Meta:
indexes = [
GinIndex(
name='icd9_code_ln_gin_idx',
fields=['code'],
opclasses=['gin_trgm_ops']
),
GinIndex(
name='icd9_desc_ln_gin_idx',
fields=['description'],
opclasses=['gin_trgm_ops']
),
]
35 changes: 35 additions & 0 deletions CodeListLibrary_project/clinicalcode/models/MESH_CODES.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from django.db import models
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.search import SearchVectorField
from django.contrib.postgres.indexes import GinIndex

import datetime

from ..entity_utils import constants

class MESH_CODES(models.Model):
# Top-level
id = models.BigAutoField(auto_created=True, primary_key=True)
code = models.CharField(max_length=10, null=True, blank=True, unique=False, default='')
description = models.CharField(max_length=256, null=True, blank=True, default='')
parent_codes = ArrayField(models.TextField(), blank=True, null=True)
record_type = models.IntegerField(null=True, blank=True, default=0)
record_category = models.IntegerField(null=True, blank=True, default=0)
record_modifier = models.IntegerField(null=True, blank=True, default=0)
active = models.BooleanField(null=True, blank=True, default=True)
effective_time = models.DateField(null=True, blank=True, default=datetime.date.today)

class Meta:
# Index reference
indexes = [
GinIndex(
name='mesh_code_ln_gin_idx',
fields=['code'],
opclasses=['gin_trgm_ops']
),
GinIndex(
name='mesh_desc_ln_gin_idx',
fields=['description'],
opclasses=['gin_trgm_ops']
),
]
1 change: 1 addition & 0 deletions CodeListLibrary_project/clinicalcode/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from .GPRD_PRODUCT_CODES import GPRD_PRODUCT_CODES
from .EMIS_CODES import EMIS_CODES
from .VISION_CODES import VISION_CODES
from .MESH_CODES import MESH_CODES

from .Template import Template
from .GenericEntity import GenericEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1974,7 +1974,7 @@ export default class ConceptCreator {
let caseSensitive = input.parentNode.parentNode.querySelector('input[name="search-sensitive"]:checked');
caseSensitive = !isNullOrUndefined(caseSensitive);

let useDesc = input.parentNode.parentNode.querySelector('input[type="radio"]:checked');
let useDesc = input.parentNode.parentNode.querySelector('input[x-item="search-by"]:checked');
useDesc = !isNullOrUndefined(useDesc) ? useDesc.getAttribute('x-target') : CONCEPT_CREATOR_SEARCH_METHODS.CODES;
useDesc = useDesc !== CONCEPT_CREATOR_SEARCH_METHODS.CODES;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,12 @@ <h3 class="detailed-input-group__title sm">Searchterm Rule</h3>
<fieldset class="search-options justify-content-end align-items-center">
<div class="search-options__container">
<p class="search-options__title"><strong>Fields:</strong></p>
<input class="search-options__input" aria-label="Search by Codes" type="radio" id="search-codes-${id}" name="search-by-option-${id}" x-target="codes" ${used_code}>
<input class="search-options__input" aria-label="Search by Codes" type="radio" id="search-codes-${id}" name="search-by-option-${id}" x-item="search-by" x-target="codes" ${used_code}>
<label class="search-options__label" role="button" tabindex="0" for="search-codes-${id}">
<span class="search-options__label-icon"></span>
Code
</label>
<input class="search-options__input" aria-label="Search by Description" type="radio" id="search-desc-${id}" name="search-by-option-${id}" x-target="description" ${used_description}>
<input class="search-options__input" aria-label="Search by Description" type="radio" id="search-desc-${id}" name="search-by-option-${id}" x-item="search-by" x-target="description" ${used_description}>
<label class="search-options__label" role="button" tabindex="0" for="search-desc-${id}">
<span class="search-options__label-icon"></span>
Description
Expand Down
2 changes: 1 addition & 1 deletion docker/development/env/web/dev.compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CELERY_BACKEND=redis://redis:6379/0

## 2. Database settings
## - Settings used by the `postgres` service
POSTGRES_HOST="localhost"
POSTGRES_HOST="postgres"
POSTGRES_DB="concept_library"
POSTGRES_USER="clluser"
POSTGRES_PASSWORD="password"
Expand Down
2 changes: 1 addition & 1 deletion docker/development/env/web/live.compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CELERY_BACKEND=redis://redis:6379/0

## 2. Database settings
## - Settings used by the `postgres` service
POSTGRES_HOST="localhost"
POSTGRES_HOST="postgres"
POSTGRES_DB="concept_library"
POSTGRES_USER="clluser"
POSTGRES_PASSWORD="password"
Expand Down
2 changes: 1 addition & 1 deletion docker/development/env/web/test.compose.env
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ CELERY_BACKEND=redis://redis:6379/0

## 2. Database settings
## - Settings used by the `postgres` service
POSTGRES_HOST="localhost"
POSTGRES_HOST="postgres"
POSTGRES_DB="concept_library"
POSTGRES_USER="clluser"
POSTGRES_PASSWORD="password"
Expand Down

0 comments on commit 6e47737

Please sign in to comment.