Пример #1
0
    def Auth(self, loginName, password):
        dict = json.loads(
            self.http_post(self.ApiRoot + '/api/Auth', {
                'loginName': loginName,
                'password': password
            }))

        resp = JSON.DictToInst(dict, Resp())

        #resp = Resp()
        #for k, v in dict.iteritems():
        #    setattr(resp, k, v)
        '''
        print 'total    :', resp.total
        print 'PageMax  :', resp.PageMax
        print 'pageIndex:', resp.pageIndex
        print 'pageSize :', resp.pageSize
        print 'Request  :', resp.Request
        print 'Status   :', resp.Status
        print 'ResType  :', resp.ResType
        print 'Error    :', resp.Error
        print 'data     :', resp.data
        '''
        print 'Status', resp.Status
        raw_input('any key to continue')

        if resp.Status != 'OK':
            print resp.Error
            raise Exception(resp.Error)
        self.AccessKey = resp.data["accessKey"]
        return True
 def EditDiagnosisConclusion(self, thingUnique, expertUnique,
                             expertDiagnosis, expertAdvice):
     url = self.ApiRoot + '/api/Diagnosis/EditDiagnosisConclusion?accessKey=' + self.AccessKey + '&thingUnique=' + thingUnique + '&expertUnique=' + expertUnique + '&expertDiagnosis=' + urllib.quote(
         expertDiagnosis.encode('utf8')) + '&expertAdvice=' + urllib.quote(
             expertAdvice.encode('utf8'))
     resp = JSON.DictToInst(json.loads(self.http_post(url, {})), Resp())
     if resp.Status != 'OK':
         print thingUnique
         print resp.Error
         raise Exception(resp.Error)
     return True
 def DocGetThingList(self, args):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot + '/api/Thing/DocGetThingList?accessKey=' +
                 self.AccessKey, args)), Resp())
     if resp.Status != 'OK':
         print args
         print resp.Error
         raise Exception(resp.Error)
     return resp
 def CloseDiagnosis(self, thingUnique):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot + '/api/Diagnosis/CloseDiagnosis?accessKey=' +
                 self.AccessKey + '&thingUnique=' + thingUnique, {})),
         Resp())
     if resp.Status != 'OK':
         print thingUnique
         print resp.Error
         raise Exception(resp.Error)
     return True
 def MarkedThing(self, jsonThingUniqueList):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot + '/api/Thing/MarkedThing?accessKey=' +
                 self.AccessKey + '&jsonThingUniqueList=' +
                 jsonThingUniqueList, {})), Resp())
     if resp.Status != 'OK':
         print jsonThingUniqueList
         print resp.Error
         raise Exception(resp.Error)
     return True
 def Auth(self, loginName, password):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(self.ApiRoot + '/api/Auth', {
                 'loginName': loginName,
                 'password': password
             })), Resp())
     if resp.Status != 'OK':
         print resp.Error
         raise Exception(resp.Error)
     self.AccessKey = resp.data["accessKey"]
     self.UserUnique = resp.data["userUnique"]
     return True
 def SetThingPatientInfo(self, thingUnique, args):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot +
                 '/api/Thing/SetThingPatientInfo?accessKey=' +
                 self.AccessKey + '&thingUnique=' + thingUnique, args)),
         Resp())
     if resp.Status != 'OK':
         print args
         print resp.Error
         raise Exception(resp.Error)
     return True
 def GetDocInfo(self):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot +
                 '/api/Doctor/GetDocInfo?accessKey={0}'.format(
                     self.AccessKey), {})), Resp())
     if resp.Status != 'OK':
         print resp.Error
         raise Exception(resp.Error)
     if len(resp.data) < 1:
         print resp.Error
         raise Exception(resp.Error)
     return resp.data[0]
 def AddThingForTest(self, args):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot +
                 '/api/Thing/AddThingForTest?transServiceAccessKey=' +
                 self.TransServiceAccessKey, args)), Resp())
     if resp.Status != 'OK':
         print args
         print resp.Error
         raise Exception(resp.Error)
     if len(resp.data) < 1:
         print resp.Error
         raise Exception(resp.Error)
     return resp.data
 def SchemeSubscription(self, userUnique, schemeUnique):
     # /api/Scheme/SchemeSubscription?accessKey=e6Kt3s13y0I&userUnique=GjgsJ7jcRE8&schemeUnique=PaJxQ4AL20M
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot +
                 '/api/Scheme/SchemeSubscription?accessKey={0}&userUnique={1}&schemeUnique={2}'
                 .format(self.AccessKey, userUnique, schemeUnique), {})),
         Resp())
     if resp.Status != 'OK':
         print 'userUnique:', userUnique
         print 'schemeUnique:', schemeUnique
         print resp.Error
         raise Exception(resp.Error)
     return True
 def SendMessage(self, thingUnique, content):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot + '/api/IM/SendMessage?accessKey=' +
                 self.AccessKey, {
                     'thingUnique': thingUnique,
                     'from': '',
                     'to': '',
                     'content': content,
                     'msgType': 0
                 })), Resp())
     if resp.Status != 'OK':
         print thingUnique
         print resp.Error
         raise Exception(resp.Error)
     return True
Пример #12
0
    def Auth(self, loginName, password):
        resp = JSON.DictToInst(
            json.loads(
                self.http_post(self.ApiRoot + '/api/Auth', {
                    'loginName': loginName,
                    'password': password
                })), Resp())

        print 'Status', resp.Status
        print 'ResType', resp.ResType
        raw_input('any key to continue')

        if resp.Status != 'OK':
            print resp.Error
            raise Exception(resp.Error)
        self.AccessKey = resp.data["accessKey"]
        return True
 def AddDoc(self, args):
     '''
     print args
     xbody = self.http_post(self.ApiRoot + '/api/Doctor/AddDoc?accessKey='+self.AccessKey, args)
     print 'xbody:', xbody
     raw_input('...')
     resp = JSON.DictToInst(json.loads(xbody),Resp())
     '''
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot + '/api/Doctor/AddDoc?accessKey=' +
                 self.AccessKey, args)), Resp())
     if resp.Status != 'OK':
         print args
         print resp.Error
         raise Exception(resp.Error)
     return True
 def MgrGetSchemeInfo(self, schemeName):
     resp = JSON.DictToInst(
         json.loads(
             self.http_post(
                 self.ApiRoot +
                 '/api/Scheme/MgrGetSchemeList?accessKey={0}'.format(
                     self.AccessKey), {
                         'pageIndex': 0,
                         'pageSize': 1,
                         'SchemeCode': schemeName,
                         'SchemeEnabled': 1,
                         'SchemeType': -1,
                         'PerCharge': '',
                         'CreateDateFrom': '',
                         'CreateDateDateTo': ''
                     })), Resp())
     if resp.Status != 'OK':
         print resp.Error
         raise Exception(resp.Error)
     if len(resp.data) < 1:
         print resp.Error
         raise Exception(resp.Error)
     return resp.data[0]
Пример #15
0
     exit('[exportPath] 目录不存在!')  # 检查 心电文件导出目标路径是否存在
 dah = ApiHelper(apiRoot, transKey)  # 初始化医生客户端
 cah = ApiHelper(apiRoot, transKey)  # 初始化客服客户端
 mah = ApiHelper(apiRoot, transKey)  # 初始化主管客户端
 eah = ApiHelper(apiRoot, transKey)  # 初始化专家客户端
 if mah.Auth(mgrAccount, password):
     Log(u'主管 建权成功: {0}'.format(mah.AccessKey))
 if cah.Auth(cusAccount, password):
     Log(u'客服 建权成功: {0}'.format(cah.AccessKey))
 if eah.Auth(expAccount, password):
     Log(u'专家 建权成功: {0}'.format(eah.AccessKey))
 countSucceed = 0
 schemeUnique = mah.MgrGetSchemeInfo(schemeName)['Unique']  # 获取套餐编码
 Log(u'读取EcgCareOnline平台用户列表')
 allText = File.ReadAllText(ecgCareOLPath + 'Users.json')
 jsonUsers = JSON.Deserialize(allText)
 totalUser = len(jsonUsers)
 Log(u'共需要迁移 {0} 个用户...'.format(totalUser))
 indexUser = 0
 for jsonUser in jsonUsers:
     indexUser += 1
     Log(u'正在迁移第 {0} 个用户, 共 {1} 个用户需要迁移'.format(indexUser, totalUser))
     user = JSON.DictToInst(jsonUser, UserModel())
     if 0 == len(user.userAddr):
         Log(u'!!!医生地址不得为空! 已置为缺省值.')
         user.userAddr = DefaultUserAddr
     if u'已作废' == user.userName:
         Log(u'!!!已作废 记录, 跳过, {0}'.format(user.loginName))
         continue
     if u'作废账号' == user.userName:
         Log(u'!!!已作废 记录, 跳过, {0}'.format(user.loginName))