Add modality to display names table and group

Issue #312 resolved
Ed McDonagh created an issue

An established database might have a large number of rows in the display name table.

It would be really useful to group them by modality to help see which unit is which.

I'm not sure if this is possible without changing the model.

Thoughts, @dplatten

Comments (24)

  1. David Platten

    I would think it is possible to obtain the modality of each display name using a database query of some sort, as the records are related:

    Each entry in GeneralEquipmentModuleAttr contains a link to a single record in UniqueEquipmentNames

    Each entry in GeneralEquipmentModuleAttr also contains a link to a single record in GeneralStudyModuleAttr. That GeneraStudyModuleAttr record contains the modality type.

    I'm not able to look at this in more detail now, but will take a look at it at some point.

  2. David Platten

    OK. If you replace the display_names_view method in views.py with the following then it returns a list of the modality types, as well as the list of name information. Not great, but may be useful:

    def display_names_view(request):
        from remapp.models import UniqueEquipmentNames, GeneralEquipmentModuleAttr, GeneralStudyModuleAttr
        import pkg_resources # part of setuptools
    
        f = UniqueEquipmentNames.objects.order_by('display_name')
        modality_of_each_name = []
        for item in f:
            g = GeneralEquipmentModuleAttr.objects.filter(unique_equipment_name = item.pk)
            h = g.values("general_study_module_attributes")
            if len(h) > 0:
                modality_of_each_name.append(GeneralStudyModuleAttr.objects.filter(id = h[0].values()[0]).values("modality_type")[0].values()[0])
            else:
                modality_of_each_name.append(False)
    
        try:
            vers = pkg_resources.require("openrem")[0].version
        except:
            vers = ''
        admin = {'openremversion' : vers}
    
        for group in request.user.groups.all():
            admin[group.name] = True
    
        return_structure = {'name_list': f, 'modality_of_each_name': modality_of_each_name, 'admin':admin}
    
        return render_to_response(
            'remapp/displaynameview.html',
            return_structure,
            context_instance=RequestContext(request)
        )
    
  3. David Platten

    Added display of modality type when looking at the unique display names on the viewdosplaynames page. They're not grouped into modality yet. References issue #312

    → <<cset 5aa8db516003>>

  4. David Platten

    @edmcdonagh, this is pretty much sorted now. The modality type is currently displayed in the far right-hand column.

  5. Ed McDonagh reporter

    I was thinking of just having the modality specific tables. What do you think? I haven't tried it on a large database though - I'm in the process of installing a copy of my production database on the laptop so I can test. I think it will be ok!

  6. David Platten

    Hi @edmcdonagh. I agree, it would be neater to have the modality-specific tables. I'm testing this on a copy of my live database with 78000 studies and 28 different imaging systems. Seems to work fine. The only problem with my data is that three of the 28 systems don't have a proper modality name: one is "None", and the other two are simply blank. The modality-specific tables don't display these anomolies at the moment. Perhaps there could be another category of "Everything else", that shows all the rest. This would also cover us if things like RTIMAGE data were added in the future.

  7. Ed McDonagh reporter

    In my test database I have some of those where a study has been through the database and then been deleted, so there is an entry in the display names tables but no study to establish the modality from!

    Can we do a chained exclude to find anything that's not CT, MG, DX, CR, RF?

  8. Ed McDonagh reporter

    Added display of modality type when looking at the unique display names on the viewdosplaynames page. They're not grouped into modality yet. References issue #312

    → <<cset 5aa8db516003>>

  9. Log in to comment