Skip to content

Commit

Permalink
Merge pull request #1417 from SwanseaUniversityMedical/Development
Browse files Browse the repository at this point in the history
DFTM - Concept Library v2.0.0
  • Loading branch information
elmessary authored Oct 9, 2023
2 parents 00dda8a + a0d757d commit b244083
Show file tree
Hide file tree
Showing 855 changed files with 51,345 additions and 79,534 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/issues_close_projects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/issue-states@v3
- uses: dessant/issue-states@v2
with:
github-token: ${{ github.token }}
open-issue-columns: ''
closed-issue-columns: 'Current Sprint: Deploy to Demo / Waiting Deployment to Live / In Production'
closed-issue-columns: 'Done / Deployed'
log-output: false
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
HARBOR_REPO: ${{ vars.HARBOR_REPO }}
HARBOR_USER: ${{ vars.HARBOR_USER }}
HARBOR_TOKEN: ${{ secrets.HARBOR_TOKEN }}
SERVER_NAME: 'conceptlibrary.saildatabank.com'

jobs:
release-container:
Expand All @@ -26,7 +27,7 @@ jobs:

- name: build container
run: |
docker build -t image -f "Dockerfile" .
docker build -t image -f "docker/production/build.Dockerfile" --build-arg server_name="$SERVER_NAME" .
- name: registry login
run: |
Expand Down
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
*.pyc
__pycache__
.project
.pydevproject
.DS_Store
docker/
CodeListLibrary_project/.settings/org.eclipse.core.resources.prefs
.settings/org.eclipse.ltk.core.refactoring.prefs
requirements/base - Django2.txt
docs/~$plication Guide.docx
**/docker/**/backup
*.backup
git.token
CodeListLibrary_project/debug.log
.vscode
.settings/org.eclipse.core.resources.prefs
venv
**/dump.rdb
CodeListLibrary_project/staticroot/*
CodeListLibrary_project/media/*
docker/development/db/postgresql.conf
docker/CodeListLibrary_project

# macOS system files
.DS_Stores
.idea
92 changes: 68 additions & 24 deletions CodeListLibrary_project/clinicalcode/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from django.contrib import admin
from django.contrib.auth.models import Group, User
from django.utils import timezone

from .models import (Brand, CodingSystem, CodingSystemFilter, DataSource, Operator, Tag)
import datetime

# from forms import GroupAdminForm
# from django import forms
# from django.forms.models import inlineformset_factory, ModelChoiceField
from .models import (Brand, CodingSystem, CodingSystemFilter, DataSource, Operator, Tag)
from .models.EntityClass import EntityClass
from .models.GenericEntity import GenericEntity
from .models.Template import Template
from .forms.TemplateForm import TemplateAdminForm
from .forms.EntityClassForm import EntityAdminForm

# Register your models here.

@admin.register(CodingSystemFilter)
class CodingSystemFilterAdmin(admin.ModelAdmin):
Expand All @@ -21,7 +23,7 @@ class OperatorAdmin(admin.ModelAdmin):

@admin.register(Tag)
class TagAdmin(admin.ModelAdmin):
list_display = ['id', 'description', 'display', 'tag_type', 'collection_brand'] #'updated_by' 'created_by' , 'created', 'modified'
list_display = ['id', 'description', 'display', 'tag_type', 'collection_brand']
list_filter = ['collection_brand', 'tag_type', 'display']
search_fields = ['description']
exclude = ['created_by', 'updated_by']
Expand All @@ -34,13 +36,13 @@ def save_model(self, request, obj, form, change):
instance.created_by = user

instance.updated_by = user
instance.modified = datetime.datetime.now()
instance.save()
form.save_m2m()

return instance


#admin.site.register(Brand)
@admin.register(Brand)
class BrandAdmin(admin.ModelAdmin):
list_display = ['name', 'id', 'logo_path', 'owner', 'description']
Expand All @@ -56,6 +58,7 @@ class DataSourceAdmin(admin.ModelAdmin):
search_fields = ['name', 'url', 'uid']
exclude = []


@admin.register(CodingSystem)
class CodingSystemAdmin(admin.ModelAdmin):
list_display = ['id', 'codingsystem_id', 'name', 'description']
Expand All @@ -64,19 +67,60 @@ class CodingSystemAdmin(admin.ModelAdmin):
exclude = []


#admin.site.register(CodingSystem)

# ############################################
# # Unregister the original Group admin.
# admin.site.unregister(Group)
#
# # Create a new Group admin.
# class GroupAdmin(admin.ModelAdmin):
# # Use our custom form.
# form = GroupAdminForm
# #form_class = GroupAdminForm
# # Filter permissions horizontal as well.
# filter_horizontal = ['permissions']
#
# # Register the new Group ModelAdmin.
# admin.site.register(Group, GroupAdmin)
@admin.register(Template)
class TemplateAdmin(admin.ModelAdmin):
readonly_fields = ['template_version']
list_display = ['id', 'name', 'description', 'template_version']
list_filter = ['name']
search_fields = ['name']
exclude = ['created_by', 'updated_by']
form = TemplateAdminForm

def save_model(self, request, obj, form, change):
"""
- Responsible for version history
-> template_version computed from JSONB data, never updated unless dictdiff and/or purposefully changed
- Responsible for computing the 'layout_order' field within the template definition
-> Iterates through the template prior to JSONB reordering and creates a 'layout_order' key [array, def. order] (Postgres stores arrays in semantic order)
-> Adds 'order' field to the template's individual fields
"""
if obj.definition is not None and 'fields' in obj.definition:
order = []
for field in obj.definition['fields']:
obj.definition['fields'][field]['order'] = len(order)
order.append(field)
obj.definition['layout_order'] = order

details = obj.definition.get('template_details') or { }
version = details.get('version', None)
if version != obj.template_version:
obj.template_version = version

if not change or not obj.created_by:
obj.created_by = request.user

obj.updated_by = request.user
obj.modified = datetime.datetime.now()

obj.save()


@admin.register(GenericEntity)
class GenericEntityAdmin(admin.ModelAdmin):
readonly_fields = ['template_version']
list_display = ['id', 'name', 'template', 'template_version']
exclude = []


@admin.register(EntityClass)
class EntityClassAdmin(admin.ModelAdmin):
list_display = ['id', 'name', 'entity_prefix', 'entity_count', 'modified_by', 'modified']
exclude = []
form = EntityAdminForm

def save_model(self, request, obj, form, change):
if not obj.created_by or not obj.created_by.id:
obj.created_by = request.user
obj.modified_by = request.user
obj.modified = timezone.now()
obj.save()
13 changes: 0 additions & 13 deletions CodeListLibrary_project/clinicalcode/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,38 @@

from ..models import (Code, Concept, DataSource, Tag, CodingSystem)


class ConceptSerializer(serializers.ModelSerializer):

class Meta:
model = Concept
fields = '__all__'


class CodeSerializer(serializers.ModelSerializer):

class Meta:
model = Code
#fields = ('id', 'code', 'description', 'code_list')
fields = '__all__'


class TagSerializer(serializers.ModelSerializer):

class Meta:
model = Tag
#fields = '__all__'
fields = (
'id', 'description', 'display', 'get_display_display', 'tag_type',
'get_tag_type_display', 'collection_brand'
#' , 'created_by' , 'updated_by'
)


class DataSourceSerializer(serializers.ModelSerializer):

class Meta:
model = DataSource
fields = (
'id', 'name', 'uid', 'url', 'description', 'datasource_id'
# , 'created_by' , 'updated_by'
)


class CodingSystemSerializer(serializers.ModelSerializer):

class Meta:
model = CodingSystem
fields = (
'id', 'name', 'description', 'codingsystem_id'
)



Loading

0 comments on commit b244083

Please sign in to comment.