*** Settings ***
Documentation     查询病人详细信息
Test Setup        get_login_token    ${URL}    mao
Library           Collections
Library           HttpLibrary.HTTP
Library           RequestsLibrary

*** Variables ***
${uri}            /IPatientService
${method}         FindPatientByCodeAsync

*** Test Cases ***
Class_001_查询病人详细信息
    [Tags]    inexecution
    [Template]    findPatientByCode_assertClass
    ${token}    PatientInfoDO_202209060308023hLHXE

Class_002_查询病人详细信息,病人编码不存在
    [Tags]    inexecution
    [Template]    findPatientByCode_assertClassNull
    ${token}    PatientInfoDO_

Exception_001_Token非空校验
    [Tags]    inexecution
    [Template]    findPatientByCode_assertException
    ${EMPTY}    PatientInfoDO_20220516083707wCNXvA    1    Permission validation error

Exception_002_Token正确性校验
    [Tags]    inexecution
    [Template]    findPatientByCode_assertException
    111111    PatientInfoDO_20220516083707wCNXvA    1    Permission validation error

*** Keywords ***
findPatientByCode_Post
    [Arguments]    ${token}    ${code}
    ${param}    Create Dictionary
    Set To Dictionary    ${param}    Token    ${token}
    Set To Dictionary    ${param}    Code    ${code}
    ${data}    body_data_list    ${method}    ${param}
    Log    ${data}
    Log    ---开始断言验证---
    ${response}    request_post    ${URL}    ${uri}    ${data}
    #Log    ${response}
    #log    ${response.content}
    #${content}    Set Variable    ${response.content}
    #Log    ---输出返回内容---:
    #Log Json    ${content}    INFO
    #Log    ---开始断言验证---
    #Should Be True    ${response.status_code}==200
    ${content}    check_response    ${response}
    [Return]    ${content}

findPatientByCode_assertClass
    [Arguments]    ${token}    ${code}
    ${content}    findPatientByCode_Post    ${token}    ${code}
    ${result}    get_content_result    ${content}
    Log    ${result}
    ${patientCode}    Get From Dictionary    ${result}    PatientCode
    Should Be Equal As Strings    ${patientCode}    ${code}
    [Return]    ${content}

findPatientByCode_assertClassNull
    [Arguments]    ${token}    ${code}
    ${content}    findPatientByCode_Post    ${token}    ${code}
    ${result}    get_content_result    ${content}
    Should Be Equal As Strings    ${result}    ${null}
    [Return]    ${content}

findPatientByCode_assertException
    [Arguments]    ${token}    ${code}    ${error_code}    ${error_msg}
    ${content}    findPatientByCode_Post    ${token}    ${code}
    #${error}    Get From Dictionary    ${content.json()}    error
    #${code}    Get From Dictionary    ${error}    code
    #${message}    Get From Dictionary    ${error}    message
    #Should Be Equal As Numbers    ${code}    ${error_code}
    #Should Be String    ${message}    ${error_msg}
    ${res}    check_content_exception    ${content}    ${error_code}    ${error_msg}
    [Return]    ${content}