Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • BackTrack 5 R2
  • Wine 1.4 / 1.5.5
  • Mozilla Firefox 12...
  • Ubuntu 11.04
  • Angry Birds 1.1.2.1
  • Ubuntu 10.04.4 LTS
  • Linux Kernel 3.4
  • Ubuntu Manual 10.10
  • Adobe Flash Player...
  • Pidgin 2.10.4
  • Home > Linux > Internet > HTTP (WWW)

    harvest-vocab 0.9.1 Beta 8

    Download button

    No screenshots available
    Downloads: 97  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Byron Ruth | More programs
    BSD License / FREE
    March 16th, 2012, 03:30 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    harvest-vocab description

    A Harvest Stack app for modeling hierarchical data

    harvest-vocab is a Harvest Stack app provides abstract models for defining vocabulary-like models and building a corresponding index for hierarchical self-related data.

    For example, this is how you could define models for storing ICD9 codes:

    from vocab.models import AbstractItem, AbstractItemIndex

    class Diagnosis(AbstractItem):
     description = models.CharField(max_length=50)
     code = models.CharField(max_length=10)
     parent = models.ForeignKey('self', related_name='children')


    ICD9 codes are hierachical therefore when I ask the questions, "Give me all the patients who have a diagnosis in ICD9 367 (Disorders of refraction and accommodation)", then this should not only query 367, but all descendent diagnoses as well (which includes another 2 levels).

    This kind of query becomes difficult to write since you only have access to the direct parent of the a particular diagnosis, thus the query would look like this.

    from django.db.models import Q
    Diagnosis.objects.filter(Q(code='367') | Q(parent__code='367'))


    The obvious problem here is that any diagnoses 2+ levels down from '367' are not included.

    Create A Flat Index

    To alleviate this issue, an AbstractItemIndex subclass can be defined which will build a flat index for an AbstractItem subclass. Simply define it like this:

    class DiagnosisIndex(AbstractItemIndex):
     item = models.ForeignKey(Diagnosis, related_name='item_indexes')
     parent = models.ForeignKey(Diagnosis, related_name='parent_indexes')

    # builds the index for Diagnosis
    DiagnosisIndex.objects.index()


    The last line generates a flat index of the hierarchy which alleviates the unknown depth issue. So now, the same question stated above can be answered this way:

    # either the item has this code or one of it's parents has this code
    condition = Q(item__code='367') | Q(parent__code='367')
    item_ids = DiagnosisIndex.objects.filter(condition).values_list('item__id', flat=True)
    diagnoses = Diagnosis.objects.filter(id__in=item_ids)



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    Harvest Stack | data modeling | Harvest | Stack | modeling



    HTML code for linking to this page:


    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM