我有一个已经过POSTMAN测试的Azure FHIR服务器,我能够使用POSTMAN和Oauth令牌读取患者以及POST患者。
我现在创建了一个JavaScript Post方法,以便可以使用自己的方法而不是使用POSTMAN发布数据。我从这里开始遵循基本指南Creating a resource 我可以使用POSTMAN获取访问令牌,并且可以在POST方法中使用该访问令牌。
我的方法和发布数据如下。
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
(async () => {
const rawResponse = await fetch('https://smarthealth.azurehealthcareapis.com/Patient', {
method: 'POST',
Authorization: 'Bearer DGRijc8LrnjCrhRFRSn2Jnf89q2wGT_gxNHtJt',
headers: {
'Access-Control-Allow-Origin': '*',
'Accept': 'application/json',
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'http://localhost:3000',
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS'
},
body: JSON.stringify({
"resourceType": "Patient",
"id": "9184e31a-a2b3-4b8d-9032-d5377cabaa08",
"extension": [
{
"url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
"extension": [
{
"url": "ombCategory",
"valueCoding": {
"system": "urn:oid:2.16.840.1.113883.6.238",
"code": "2106-3",
"display": "White"
}
},
{
"url": "text",
"valueString": "White"
}
]
},
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthPlace",
"valueAddress": {
"city": "Mashpee",
"state": "Massachusetts",
"country": "US"
}
},
],
"name": [
{
"use": "official",
"family": "Kutch",
"given": [
"Sherron"
]
}
],
"gender": "female",
"birthDate": "2009-04-29",
})
});
const content = await rawResponse.json();
console.log(content);
})();
</script>
</head>
<body>
Javascript Azure FHIR Post Request Test
</body>
</html>
您可以尝试按照以下格式发送请求。