Ejemplo n.º 1
0
def populate():
    jill = add_user("jill")
    bob = add_user("bob")
    jen = add_user("jen")

    # TODO: add a few more reviews
    adhd = add_review(users=[jill, bob],
                      title="Investigating the effects of acupuncture on children with ADHD",
                      description="The purpose of this review is to identify any potential positive or negative "
                                  "effects when applying the practice of acupuncture to young children suffering from "
                                  "attention deficit hyperactivity disorder, which is more commonly referred to by its abbreviation, ADHD.",
                      date_created=generate_random_date(),
                      last_modified=generate_random_date(recent=True),
                      query="""(adhd OR adhs OR addh) AND (child OR adolescent) AND acupuncture""")

    lung_cancer = add_review(users=[jen],
                             title="Development of lung cancer from inhalation of soldering fumes",
                             description="This review will retrieve all papers discussing links between soldering fume "
                                         "inhalation and lung cancer.",
                             date_created=generate_random_date(),
                             last_modified=generate_random_date(recent=True),
                             query="(solder OR soldering) AND (lung AND cancer)")

    rsi = add_review(users=[jen, bob],
                     title="RSI in musicians such as drummers and guitarists",
                     description="This review explores any connection between the development of repetitive strain "
                                 "injury, which is more commonly known as RSI, in musicians, or more specifically, "
                                 "people who play drums or play guitar. This issue is more frequently discussed in "
                                 "the world of computer use and office life, but rarely in the performance of music.",
                     date_created=generate_random_date(),
                     last_modified=generate_random_date(recent=True),
                     query="(RSI OR repetitive OR strain OR injury) AND (drums OR drumming OR drummer OR guitar OR guitarist)")

    stress = add_review(users=[jill],
                        title="Stress experienced by students during examinations",
                        description="This review will retrieve all medical papers which discuss the issues regarding "
                                    "stress, anxiety, and a general lack of wellbeing of students while their "
                                    "educational establishment undergo examinations.",
                        date_created=generate_random_date(),
                        last_modified=generate_random_date(recent=True),
                        query="stress AND anxiety AND student AND (exam OR examination OR test) AND (university OR college)")

    reviews = [
        adhd,
        lung_cancer,
        rsi,
        stress,
    ]

    import time

    for review in reviews:
        start = time.time()

        Paper.create_papers_from_pubmed_ids(PubMed.get_ids_from_query(review.query), review)

        end = time.time()
        duration = (end - start)
        print "Populating %s took %f seconds" % (review.title, duration)
Ejemplo n.º 2
0
def add_paper_by_id(review, id):
    Paper.create_papers_from_pubmed_ids([id], review)
Ejemplo n.º 3
0
 def test_create_papers_from_ids(self):
     review = Review.objects.get_or_create(title="Investigating the effects of acupuncture on children with ADHD")[0]
     result = Paper.create_papers_from_pubmed_ids(self.test_ids, review)[0]
     self.assertEquals("[A Meta-analysis on Acupuncture Treatment of Attention Deficit/Hyperactivity Disorder].",
                       result.title)
Ejemplo n.º 4
0
def newSearch(request):
    if request.method == 'POST':
        query = request.POST.get('query')

        if query:
            # check to see if this query exists
            if len(Query.objects.filter(queryString__iexact=query)) != 0:
                prev_query = Query.objects.get(queryString=query)
                #return HttpResponse('query already saved (redirect to results for that query)')
                return HttpResponse('{"queryID":'+str(prev_query.queryID)+'}')

            result_list = run_query(query)
            obtained_ids = result_list.keys()
            new_query = Query(queryString=query, result=obtained_ids, poolSize=20, researcher=request.user.researcher)
            new_query.save()

            n = 0
            for key, item in result_list.iteritems():
                if item['Date_completed'] == 'incomplete':
                    new_paper = Paper(paperID=key,
                                      paperUrl=item['Link'],
                                      authors=item['Authors'],
                                      title=item['Article_title'],
                                      abstract=item['Abstract'],
                                      queryID=new_query,
                                      abstractApproved=False,
                                      documentApproved=False
                                      )
                elif item['Date_completed'] == '':
                    new_paper = Paper(paperID=key,
                                      paperUrl=item['Link'],
                                      authors=item['Authors'],
                                      title=item['Article_title'],
                                      abstract=item['Abstract'],
                                      queryID=new_query,
                                      abstractApproved=False,
                                      documentApproved=False
                                      )
                else:
                    new_paper = Paper(paperID=key,
                                      paperUrl=item['Link'],
                                      authors=item['Authors'],
                                      title=item['Article_title'],
                                      publishDate=item['Date_completed'],
                                      abstract=item['Abstract'],
                                      queryID=new_query,
                                      abstractApproved=False,
                                      documentApproved=False
                                      )
                new_paper.save()
                n += 1

            #return HttpResponse('query saved')
            return HttpResponse('{"queryID":'+str(new_query.queryID)+'}')

    context_dict = {"page_title": "Searches"}

    query_list = SavedQuery.objects.filter(researcher=request.user.researcher).reverse()
    saved_list = []

    for q in query_list:
        sl = { 'query' : q.queryID }
        sl['size'] = len(Paper.objects.filter(queryID=q.queryID, documentApproved=True))
        saved_list.append(sl)

    context_dict['saved_list'] = saved_list

    return render(request, "newSearch.html", context_dict)