コード例 #1
0
    def post(self):
        query = self.request.get('query')
        id = self.request.get('id')

        idn, sym, dis = summarize.seq1(query)
        q = patient.all(keys_only=True)
        q.filter("__key__ >=", Key.from_path('patient', id))
        res = q.get()
        #logging.info("res : " + res)
        if res:

            if (idn == 1):
                result = "Please Input Some Relevant Query"
            elif (idn == 2):
                result = "Very weak symptoms. No Medicines required currently, however we suggest to consult a doctor before if symptoms aggravate"
                rec = record(parent=res,
                             symptoms=sym,
                             medicine='not_any',
                             doc='ehealth')
                rec.rec_date = datetime.datetime.now().date()
                rec.put()
            elif (idn == 3):
                result = "No decision could be taken for this set of symptoms. We have recorded this query and will furthur look into it. <br> <b> Please consult a doctor . </b>"
                rec = record(parent=res,
                             symptoms=sym,
                             medicine='not_checked',
                             doc='ehealth')
                rec.rec_date = datetime.datetime.now().date()
                rec.put()
            elif (idn == 4):
                result = "Your symptoms strongly match the following: " + (
                    ','.join(dis)) + "<br><b>Please consult a doctor .</b>"
                rec = record(parent=res,
                             symptoms=sym,
                             disease=dis,
                             doc='ehealth')
                rec.rec_date = datetime.datetime.now().date()
                rec.put()
            elif (idn == 5):
                result = "Your symptoms strongly match " + str(
                    dis[0]
                ) + ".<br> We suggest based on your medical history, the medicine :" + (
                    ','.join(dis[1])) + "."
                rec = record(parent=res,
                             symptoms=sym,
                             disease=[dis[0]],
                             medicine=(','.join(dis[1])),
                             doc='ehealth')
                rec.rec_date = datetime.datetime.now().date()
                rec.put()
        else:
            result = "Invalid ID"

        template_values = {'result': result, 'name': self.request.get('name')}
        template = jinja_environment.get_template('process.html')
        self.response.out.write(template.render(template_values))
コード例 #2
0
    def receive(self, mail_message):
        logging.info("Received a message from: " + mail_message.sender)
        plaintext_bodies = mail_message.bodies('text/plain')

        reply = ''
        temp = ''

        for content_type, body in plaintext_bodies:
            temp = body.decode().split()
            pos = temp.index('7568805699')
            reply = reply + ' '.join(temp[pos + 1:])
            num = temp[pos - 6][1:-1]
        message = mail.EmailMessage(
            sender=
            "E-Health App <*****@*****.**>",
            subject="Reply")
        message.to = 'Application Archive <*****@*****.**>'

        logging.info("replying message with : " + reply)
        #call(reply,num)
        #print plaintext_bodies
        #logging.info("Sending message to : " +message.to)
        #logging.info("With data : " +reply)

        idn, sym, dis = summarize.seq1(reply)
        if (idn == 1):
            result = "Please Input Some Relevant Query"
        elif (idn == 2):
            result = "Very weak symptoms. No Medicines required currently, however we suggest to consult a doctor before if symptoms aggravate"
        elif (idn == 3):
            result = "No decision could be taken for this set of symptoms. We have recorded this query and will furthur look into it.Please consult a doctor ."
        elif (idn == 4):
            result = "Your symptoms strongly match the following: " + (
                ', '.join(dis)) + "Please consult a doctor ."
        elif (idn == 5):
            result = "Your symptoms strongly match " + str(
                dis[0]
            ) + ".We suggest based on your medical history, the medicine :" + (
                ', '.join(dis[1])) + "."

        sms = ""
        message.body = num + ' ' + result

        for x in result.split(' '):
            if ((len(sms) + len(x)) >= 160):
                call(sms, num)
                sms = ""
            sms = sms + str(x) + " "

        if (len(sms) > 0):
            call(sms, num)
        message.send()
コード例 #3
0
 def receive(self, mail_message):
     logging.info("Received a message from: " + mail_message.sender)
     plaintext_bodies = mail_message.bodies('text/plain')
     
     reply=''
     temp=''
     
     
     for content_type,body in  plaintext_bodies:
         temp= body.decode().split()
         pos = temp.index('7568805699')
         reply =reply + ' '.join(temp[pos+1:])
         num = temp[pos-6][1:-1]
     message = mail.EmailMessage(sender="E-Health App <*****@*****.**>",subject="Reply")
     message.to = 'Application Archive <*****@*****.**>'
     
     logging.info("replying message with : " + reply)
     #call(reply,num)
     #print plaintext_bodies
     #logging.info("Sending message to : " +message.to)
     #logging.info("With data : " +reply)
     
     idn, sym, dis  = summarize.seq1(reply)
     if(idn==1):
             result = "Please Input Some Relevant Query"
     elif( idn==2):
             result = "Very weak symptoms. No Medicines required currently, however we suggest to consult a doctor before if symptoms aggravate"                
     elif(idn==3):
             result ="No decision could be taken for this set of symptoms. We have recorded this query and will furthur look into it.Please consult a doctor ."      
     elif(idn==4):
             result ="Your symptoms strongly match the following: "+(', '.join(dis))+"Please consult a doctor ."                
     elif(idn==5):
             result ="Your symptoms strongly match "+str(dis[0])+".We suggest based on your medical history, the medicine :"+(', '.join(dis[1]))+"."
     
     sms=""
     message.body = num + ' ' +result
     
     for x in result.split(' '):
         if( (len(sms) + len(x))>=160):
             call(sms,num)
             sms=""
         sms=sms+str(x)+" "
     
     if(len(sms)>0):
         call(sms,num)
     message.send()
コード例 #4
0
 def post(self):
     query = self.request.get('query')
     id= self.request.get('id')
     		
     idn, sym, dis  = summarize.seq1(query)
     q= patient.all(keys_only=True)
     q.filter("__key__ >=", Key.from_path('patient', id))
     res = q.get()
     #logging.info("res : " + res)
     if res:
     
         if(idn==1):
             result = "Please Input Some Relevant Query"
         elif( idn==2):
             result = "Very weak symptoms. No Medicines required currently, however we suggest to consult a doctor before if symptoms aggravate"
             rec = record(parent=res, symptoms = sym, medicine = 'not_any', doc = 'ehealth')
             rec.rec_date =datetime.datetime.now().date()
             rec.put()
         elif(idn==3):
             result ="No decision could be taken for this set of symptoms. We have recorded this query and will furthur look into it. <br> <b> Please consult a doctor . </b>"
             rec = record(parent=res, symptoms = sym, medicine = 'not_checked', doc = 'ehealth')
             rec.rec_date =datetime.datetime.now().date()
             rec.put()
         elif(idn==4):
             result ="Your symptoms strongly match the following: "+(','.join(dis))+"<br><b>Please consult a doctor .</b>"
             rec = record(parent=res, symptoms = sym, disease =dis, doc = 'ehealth')
             rec.rec_date =datetime.datetime.now().date()
             rec.put()
         elif(idn==5):
             result ="Your symptoms strongly match "+str(dis[0])+".<br> We suggest based on your medical history, the medicine :"+(','.join(dis[1]))+"."
             rec = record(parent=res, symptoms = sym, disease =[dis[0]],medicine= (','.join(dis[1])), doc = 'ehealth')
             rec.rec_date =datetime.datetime.now().date()
             rec.put()
     else:
         result = "Invalid ID"
     
     template_values = {
     'result': result,
     'name':self.request.get('name')
     }
     template = jinja_environment.get_template('process.html')
     self.response.out.write(template.render(template_values))