def singlePharmMsg(singlePharm):
    print(singlePharm)
    pharmName=singlePharm['phName']
    pharmNumber=singlePharm['phTel']
    pharmAddress=singlePharm['phAdd']
    pharmLineId=singlePharm['LineID']

    flex=deepcopy(contactPharmFlex)
    flex["hero"]["url"]=getPicUrl('pharminfoResult_pic_url')
    flex["body"]["contents"][0]["text"]=pharmName
    flex["body"]["contents"][1]["contents"][0]["contents"][0]["text"]="電話:"+pharmNumber
    flex["body"]["contents"][1]["contents"][0]["contents"][1]["text"]="地址:"+pharmAddress
    flex["footer"]["contents"][0]["contents"][0]["url"]=getPicUrl('phone_icon_url')
    flex["footer"]["contents"][0]["action"]["text"]="請撥打 "+pharmName+":\n"+pharmNumber
    flex["footer"]["contents"][1]["contents"][0]["url"]=getPicUrl('line_icon_url')
    flex["footer"]["contents"][1]["action"]["uri"]='https://line.me/R/ti/p/{LINE_id}'.format(LINE_id=pharmLineId)

    return FlexSendMessage(alt_text='藥局資訊',contents=flex) 
def sendcontactPharmWithUndo(jsonData):
  flex=deepcopy(contactPharmFlexWithUndo)
  path=urllib.parse.urljoin(config.get('server_urls','backend_url'),"postPh/")
  print("pharName")
  print(jsonData)
  search=jsonData["pharName"]#'小光藥局'
  print(urllib.parse.urljoin(path,search))
  data=requests.get(urllib.parse.urljoin(path,search),headers=headers_to_db).content
  data=json.loads(data)
  data=data[0]
  print(data)
  
  phName=jsonData["pharName"]#data["phName"]
  phTel=data["phTel"]
  phAdd=data["phAdd"]
  phLineId=data["LineID"]
  flex["hero"]["url"]=getPicUrl('pharminfoResult_pic_url')
  print(flex["hero"]["url"])
  flex["body"]["contents"][0]["text"]=phName
  flex["body"]["contents"][1]["contents"][0]["contents"][0]["text"]=phTel
  flex["body"]["contents"][1]["contents"][0]["contents"][1]["text"]=phAdd
  ''' 
  dataToSend={
    "type":"resendReminderFlex",
    "data":{
      "postId":""
    }
  }
  dataToSend["data"]["postId"]=jsonData["postId"]
  dataToSend=json.dumps(dataToSend)'''
  #print('test3')
  #print(type(jsonData["postId"]))
  #print(jsonData["postId"])
  #print('test4')
  #path=urllib.parse.urljoin('sendReminder/',jsonData["postId"])
  flex["footer"]["contents"][2]["action"]["data"]="postId="+jsonData["postId"]
  flex["footer"]["contents"][0]["action"]["text"]="請撥打:"+phTel
  flex["footer"]["contents"][1]["action"]["uri"]=urllib.parse.urljoin('https://line.me/R/ti/p/',phLineId)
  flex["hero"]["url"]=getPicUrl('contactPharm_pic_url')
  return FlexSendMessage(alt_text='聯繫藥局詢問',contents=flex)
Beispiel #3
0
def sendInstrucMsg():
    msgObjs = []
    msgObjs.append(
        TextSendMessage(text=config.get('instrucMsg', 'auth_complete')))
    greetImgUrl = getPicUrl('greeting_pic_url')
    msgObjs.append(
        ImageSendMessage(type="image",
                         original_content_url=greetImgUrl,
                         preview_image_url=greetImgUrl))
    msgObjs.append(
        TextSendMessage(
            text=config.get('instrucMsg', 'instruc'),
            quick_reply=QuickReply(items=[
                QuickReplyButton(
                    action=MessageAction(label="跳過教學", text="跳過教學")),
                QuickReplyButton(
                    action=MessageAction(label="好的!顯示使用說明", text="好的!顯示使用說明"))
            ])))
    return msgObjs
def sendRemindConfirmMsg(postConfirmParam):
    msgObjs=[]
    msgObjs.append(TextSendMessage(text=getContents.getTextContents('msg_contents','reply_pickmedi_confirmed')))
    #get patient pick med info with patient id

    #requests.post('{postParam}'.format(postParam=postPatientIdParam))
    patientName=postConfirmParam["patientName"]
    pickDate1=postConfirmParam["pickDate1"]
    pickDate2=postConfirmParam["pickDate2"]
    weekday1=postConfirmParam["weekday1"]
    weekday2=postConfirmParam["weekday2"]
    symptom=postConfirmParam["symptom"]
    flex=deepcopy(mediConfirmFlex)
    flex["hero"]["url"]=getContents.getPicUrl('pick_medi_confirm_url')
    flex["body"]["contents"][0]["text"]=patientName+":"+symptom
    msg='慢性處方箋領藥日:\n'+pickDate1+getContents.getWeekDay(weekday1)+"~"+pickDate2+getContents.getWeekDay(weekday2)
    flex["footer"]["contents"][0]["text"]=msg
    #+" 您好,\n已確認您的預約慢性處方箋領藥日:"+pickDate1+getContents.getWeekDay(weekday1)+"~"+pickDate2+getContents.getWeekDay(weekday2)
    msgObjs.append(FlexSendMessage(alt_text='慢箋領藥時間確認',contents=flex))
    return msgObjs
Beispiel #5
0
def setSinglePharmFlex(singleInfo):  
    flex=deepcopy(pharmacyInfoFlex)
    pharmPicUrl=getPicUrl('pharminfo_pic_url')
    pharmFBPicUrl=getPicUrl('pharminfo_pic_url')
    pharmLinePicUrl=getPicUrl('pharminfo_pic_url')
    
    pharmFBUrl=singleInfo["WebURL"]
    pharmName=singleInfo['phName']
    pharmNumber=singleInfo['phTel']
    pharmAddress=singleInfo['phAdd']
    pharmLineId=singleInfo['LineID']
    
    flex["contents"][0]["hero"]["url"]=pharmPicUrl
    flex["contents"][0]["body"]["contents"][0]["text"]=pharmName
    flex["contents"][0]["body"]["contents"][1]["contents"][0]["text"]="電話:"+pharmNumber
    flex["contents"][0]["body"]["contents"][2]["contents"][0]["contents"][0]["text"]="地址:"+pharmAddress
    flex["contents"][0]["footer"]["contents"][0]["url"]=getPicUrl('phone_icon_url')
    flex["contents"][0]["footer"]["action"]["text"]="請撥打 藥局名稱: "+pharmNumber

    if(pharmFBUrl==None):
        del flex["contents"][2]
    else:
        flex["contents"][2]["hero"]["url"]=pharmFBPicUrl
        flex["contents"][2]["body"]["contents"][0]["text"]=pharmName+"FB粉專"
        flex["contents"][2]["body"]["contents"][1]["contents"][0]["url"]=getPicUrl('search_icon_url')
        flex["contents"][2]["body"]["contents"][1]["contents"][1]["text"]=pharmName
        flex["contents"][2]["footer"]["contents"][0]["url"]=getPicUrl('link_icon_url')
        flex["contents"][2]["footer"]["action"]["uri"]=pharmFBUrl
    
    if(pharmLineId==None):
        del flex["contents"][1]
    else:
        flex["contents"][1]["hero"]["url"]=pharmLinePicUrl
        flex["contents"][1]["body"]["contents"][0]["text"]=pharmName+"Line客服"
        flex["contents"][1]["body"]["contents"][1]["contents"][0]["text"]="ID: "+pharmLineId
        flex["contents"][1]["footer"]["contents"][0]["url"]=getPicUrl('line_icon_url')
        flex["contents"][1]["footer"]["action"]["uri"]='https://line.me/R/ti/p/{LINE_id}'.format(LINE_id=pharmLineId)

    return FlexSendMessage(alt_text='藥局聯繫資訊',contents=flex) 
Beispiel #6
0
def replyDateSearch(pickMediDate):
    searchResults = []
    '''get patient name, gender, and date to pick up medi'''
    for mediDate in pickMediDate:
        flex = deepcopy(dateToPickFlex)
        symptom = mediDate["symptom"]
        name = mediDate["userName"]
        dayStart = mediDate["dayStart"]
        dayStart = dayStart[5:]
        weekDayStart = getContents.getWeekDay(mediDate["weekDayStart"])
        dayEnd = mediDate["dayEnd"]
        dayEnd = dayEnd[5:]
        weekDayEnd = getContents.getWeekDay(mediDate["weekDayEnd"])
        print(type(dayStart))
        ###put the string in config, replace character when read xxxx??
        dateToPickFlex["body"]["contents"][0]["text"] = name + ":" + symptom
        msg = '慢性處方箋領藥日:\n' + dayStart + weekDayStart + "~" + dayEnd + weekDayEnd  #+"\n請攜帶健保卡前來藥局領取慢箋藥品!\n屆時也會再通知您喔!"
        flex = deepcopy(dateToPickFlex)
        dateToPickFlex["hero"]["url"] = getContents.getPicUrl(
            'mediDateResult_pic_url')
        dateToPickFlex["footer"]["contents"][0]["text"] = msg
        searchResults.append(
            FlexSendMessage(alt_text="領藥時間查詢結果", contents=dateToPickFlex))
    return searchResults
def sendMediRemind(postId):
    try:
        headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'}
        url=urllib.parse.urljoin(getContents.getServerUrl(),"postInfo/")#'https://805c36b4842b.ngrok.io/postInfo/371'
        url=urllib.parse.urljoin(url,postId)
        result=requests.get(url,headers=headers).content
        data=result.decode('ASCII')
        if (data=='Post not exist'):
          return 'Post not exist',200
        elif (data=='Patient not exist'):
          return 'Patient not exist',200
        elif (data=='Pharmacy null'):
          return 'Pharmacy null',200
        else: 
            #data=dict(request.form)
            data=json.loads(result)[0]
            print(data)
            flex=deepcopy(mediRemindFlex)

            postNumber=data['postID']#data['']
            pharName=data['PhName']#'213'#data['pharName']
            patientName=data['Name']#'123'#data['patientName']
            gender=data['Gender']#data['gender']
            pickDate1=data['dayStart'][5:]#'123'#data['pickdate1']
            pickDate2=data['dayEnd'][5:]#'123'#data['pickdate2']
            weekday1=data['weekDayStart']
            weekday2=data['weekDayEnd']
            user_lineid=data['lineID']#'123'#data['user_lineid']
            symptom=data['symptom']

            confirmData2=deepcopy(confirmData)
            confirmData2["data"]["postId"]=postId
            #print("test1")
            confirmData2["data"]["postNumber"]=postNumber
            confirmData2["data"]["patientName"]=patientName
            confirmData2["data"]["pickDate1"]=pickDate1
            confirmData2["data"]["pickDate2"]=pickDate2
            confirmData2["data"]["weekday1"]=weekday1  #tell亮亮
            confirmData2["data"]["weekday2"]=weekday2
            confirmData2["data"]["user_lineid"]=user_lineid
            confirmData2["data"]["symptom"]=symptom
            confirmData2=json.dumps(confirmData2)
            print("confirmData2:")
            print(confirmData2)

            if gender=='male':
                title='先生'
            else:
                title='小姐'

            flex["body"]["contents"][0]["text"]=pharName+"提醒您:\n"+patientName+title+"您的  "+symptom+"  慢箋領藥時間快到了!\n請於 "+pickDate1+getContents.getWeekDay(weekday1)+"~ "+pickDate2+getContents.getWeekDay(weekday2)+"\n攜帶健保卡,前來  "+pharName+"  領取慢箋藥品!"
            flex["footer"]["contents"][0]["action"]["data"]=confirmData2

            stringFormData={
              "type":"ask_when_send_reminder",
              "data":{
                "postId":"",
                "pharName":""
              }
            }
            
            stringFormData["data"]["postId"]=postId
            stringFormData["data"]['pharName']=pharName
            stringFormData=json.dumps(stringFormData)
            flex["footer"]["contents"][1]["action"]["data"]=stringFormData
            flex["hero"]["url"]=getContents.getPicUrl('pick_medi_reminder_url')
            line_bot_api.push_message(user_lineid,FlexSendMessage(alt_text='慢箋領藥時間提醒',contents=flex))

            return 'reminder sent',200

    except:
        return 'err', 500

    return 'ok', 200
def sendMediRemind(pharName, pharmLineId, patientName, patientId, gender, pickDate1, pickDate2):
    flex=deepcopy(mediRemindFlex)
    flex["hero"]["url"]=getContents.getPicUrl('pick_medi_reminder_url')
    flex["body"]["contents"][0]["text"]=pharName+"提醒您:\n"+patientName+gender+"您的慢箋領藥時間快到了!請於"+pickDate1+"~ "+pickDate2+"\n攜帶健保卡,前來領取慢箋藥品!"
    flex["footer"]["contents"][0]["action"]["data"]="patientId={id}".format(id=patientId)
    return FlexSendMessage(alt_text='慢箋領藥時間提醒',contents=flex)
Beispiel #9
0
def replyNoNeedToPick():
    msg = getContents.getTextContents('msg_contents', 'no_medi_to_pick')
    dateToPickFlex["hero"]["url"] = getContents.getPicUrl(
        'mediDateResult_pic_url')
    dateToPickFlex["body"]["contents"][0]["contents"][0]["text"] = msg
    return FlexSendMessage(alt_text="領藥時間查詢結果", contents=dateToPickFlex)
def mediQuestions():
    mediQuestionflex["contents"][0]["hero"]["url"] = getContents.getPicUrl(
        'mediQuestion_pic_url')
    mediQuestionflex["contents"][1]["hero"]["url"] = getContents.getPicUrl(
        'mediQuestion_pic_url')
    return FlexSendMessage(alt_text="選擇問題類型", contents=mediQuestionflex)
def sendOtherFuncMsg():
    flex=deepcopy(otherFuncFlex)
    flex["hero"]["url"]=getContents.getPicUrl('other_func_pic_url')
    #flex["footer"]["contents"][0]["uri"]=
    return FlexSendMessage(alt_text="其他功能", contents=flex)