0

Cerner EHR から患者の詳細を取得する API を呼び出そうとしています。システムベースの SMART アプリを使用しています。しかし、それを呼び出そうとすると、エラーが発生します

無効なスコープ。
「スコープ」:「システム/Observation.write システム/Patient.read システム/Patient.write システム/Observation.read」

私は郵便配達員でこれを試しましたが、CURL は両方とも完全に正常に動作します。

しかし、スコープを指定する場合、'scope':'system/Patient.write system/Patient.read system/Observation.write system/Observation.read'つまり、system/Patient.write または他のスコープを最初のスコープとして指定すると、患者の詳細を取得できません。system/Patient.read を最初のスコープ自体として指定する必要があります。患者の詳細を読むことができます。ここでスコープの順序が重要な理由がわかりません。

アクセス トークンを取得するためのコードは次のとおりです。

const getAuth = async () => {
 try{
    const token_url = 'token-url endpoint';
    const data = qs.stringify({'grant_type':'client_credentials','scope':'system/Patient.write system/Patient.read system/Observation.write  system/Observation.read '});
    console.log(data)
    const opts = {
    headers: { 
      'Authorization': `Basic ${auth_token}`,
      'Content-Type': 'application/x-www-form-urlencoded',
      'Accept': 'application/json',
      'Content-Length': '61',
      'Connection':'close',
      'cache-control': 'no-cache'  
     }
    };

    const response = await axios.post(token_url, data, opts);
  
    return response.data.access_token;

  }catch(error){
    console.log( error);
  }
}

この後、関数を呼び出して患者の詳細を取得します。関数コードは以下のとおりです。

async function getFunction(){
    const bearer_token=await getAuth();
  
  const get_url = 'get endpoint';
  const get_header = {
    headers: {
      'Authorization': `Bearer ${bearer_token}`,
      'Accept': 'application/json+fhir'
   }
  }
    console.log(bearer_token);
     
      const get_respone = await axios.get(get_url, get_header);
      let data = get_respone.data;
      console.log(data);
      return data;
    
    }

しかし、エラーは次のように表示されます:

データ: { resourceType: 'OperationOutcome', issue: [ { 重大度: 'エラー', コード: '禁止', 診断: 'ベアラー レルム="fhir-ehr-code.cerner.com", エラー="insufficient_scope"',式: [ 'http.Authorization' ] } ] }

しかし、スコープを次のように変更してアクセストークンを取得している場合:

'scope':'system/Patient.read system/Patient.write system/Observation.write  system/Observation.read'

system/Patient.read次に、スコープの先頭にスコープを追加したので、患者の詳細を取得します。

この SMART アプリのバックエンドとして Node.js を使用していますが、Node.js の初心者なので、API を呼び出す際にスコープの順序が重要である理由がわかりません。誰もこれを知っていますか?

4

0 に答える 0