lifen-postman/lifen-api.postman_collection.json
2021-09-08 13:07:14 +02:00

781 lines
35 KiB
JSON

{
"info": {
"_postman_id": "5764bcaa-18fb-4cdd-a909-cf604ea5ab47",
"name": "lifen-api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "a Json Web Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Auth succed\", function () {\r",
" if(pm.response.headers.get(\"Content-Type\") === \"application/json\") {\r",
" const responseJson = pm.response.json();\r",
" pm.globals.set(\"json_web_token\", responseJson.access_token);\r",
" now = new Date();\r",
" now.setTime(now.getTime() + (responseJson.expires_in * 1000));\r",
" pm.globals.set(\"token_expiration\", now);\r",
" // We save the expiration date to be challenged in each request. Renew it on pre-request script if necessary.\r",
" }\r",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\r\n\t\"client_id\": \"szVsMPaDPUdwqngGiLoHfXFT5XCYPFcy\",\r\n \"client_secret\": \"sMp2PB-QWBZupCB4IXJrWDJ-7tlpUl09vQ2tMKdy049He7-g93ofbXz7ESlAc82B\",\r\n \"audience\": \"post-prod-apis\",\r\n \"grant_type\": \"client_credentials\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://lifen-post-prod.eu.auth0.com/oauth/token",
"protocol": "https",
"host": [
"lifen-post-prod",
"eu",
"auth0",
"com"
],
"path": [
"oauth",
"token"
]
}
},
"response": []
},
{
"name": "Binary n°1615660",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Check that the binary exists\", function () {",
" // Chaiexcept syntax",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Check that the binary is a PDF type\", function () {",
" pm.expect(pm.response.headers.get(\"Content-Type\"), \"The response is not a PDF\").to.include(\"application/pdf\");",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://{{baseURL}}/fhir/Binary/1615660",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"Binary",
"1615660"
]
}
},
"response": []
},
{
"name": "DocumentReference",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.environment.set(\"documentReferenceId\", \"\");",
"",
"pm.test(\"The binary is correclty proccessed as a Document Reference in the server\", function () {",
" // chaisinon syntax",
" pm.response.to.have.status(201);",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.equal(\"application/fhir+json;charset=UTF-8\");",
"});",
"",
"const responseJson = pm.response.json();",
"",
"pm.test(\"The response is a DocumentReference\", function () {",
" pm.expect(responseJson.resourceType, \"The server did not returned a documentReferenceId\").to.eq(\"DocumentReference\");",
"});",
"",
"pm.test(\"The response have a documentReferenceId (and store it)\", function () {",
" pm.expect(responseJson.id, \"The server did not returned a documentReferenceId\").to.not.be.empty;",
" console.log(`Fetched documentReferenceId: ${responseJson.id}`);",
"",
" // Best practice : separate setup / teardown logic from the testscript itself (ie: action to store data outside of this function)",
" pm.environment.set(\"documentReferenceId\", responseJson.id);",
" pm.expect(pm.environment.get(\"documentReferenceId\")).to.not.be.empty;",
"});",
"",
"pm.test(\"The document Reference status is 'Current'\", function () {",
" pm.expect(responseJson.status).to.be.equals(\"current\");",
"});",
"",
"pm.test(\"The document Reference status is 'Draft'\", function () {",
" // This test SHOULD fail!!!",
" pm.expect(responseJson.status, \"This test MUST fail\").to.be.equals(\"draft\");",
"});",
"",
"pm.test(\"The document status is 'final'\", function () {",
" const responseJson = pm.response.json();",
" pm.expect(responseJson.docStatus).to.be.equals(\"final\");",
"});"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"current\",\r\n \"docStatus\": \"final\",\r\n \"type\": {\r\n \"coding\": [\r\n {\r\n \"system\": \"http://loinc.org\",\r\n \"code\": \"34109-9\",\r\n \"display\": \"Document médical\"\r\n }\r\n ]\r\n },\r\n \"indexed\": \"2021-02-11T09:25:39Z\",\r\n \"description\": \"aelgain-copiepatient.pdf\",\r\n \"content\": [\r\n {\r\n \"attachment\": {\r\n \"contentType\": \"application/pdf\",\r\n \"url\": \"Binary/1615660\",\r\n \"title\": \"aelgain-copiepatient.pdf\"\r\n }\r\n }\r\n ],\r\n \"resourceType\": \"DocumentReference\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{baseURL}}/fhir/DocumentReference",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"DocumentReference"
]
}
},
"response": [
{
"name": "DocumentReference",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"status\": \"current\",\r\n \"docStatus\": \"final\",\r\n \"type\": {\r\n \"coding\": [\r\n {\r\n \"system\": \"http://loinc.org\",\r\n \"code\": \"34109-9\",\r\n \"display\": \"Document médical\"\r\n }\r\n ]\r\n },\r\n \"indexed\": \"2021-02-11T09:25:39Z\",\r\n \"description\": \"aelgain-copiepatient.pdf\",\r\n \"content\": [\r\n {\r\n \"attachment\": {\r\n \"contentType\": \"application/pdf\",\r\n \"url\": \"Binary/1615660\",\r\n \"title\": \"aelgain-copiepatient.pdf\"\r\n }\r\n }\r\n ],\r\n \"resourceType\": \"DocumentReference\"\r\n}"
},
"url": {
"raw": "https://{{baseURL}}/fhir/DocumentReference",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"DocumentReference"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 02 Sep 2021 10:46:54 GMT"
},
{
"key": "Content-Type",
"value": "application/fhir+json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-B3-TraceId",
"value": "436009ec5e759266"
},
{
"key": "X-B3-SpanId",
"value": "436009ec5e759266"
},
{
"key": "X-B3-Sampled",
"value": "1"
},
{
"key": "X-Powered-By",
"value": "HAPI FHIR 4.2.0 REST Server (FHIR Server; FHIR 3.0.2/DSTU3)"
},
{
"key": "X-FHIR-Request-Validation",
"value": "No issues detected"
},
{
"key": "ETag",
"value": "W/\"1\""
},
{
"key": "X-Request-ID",
"value": "5192ef4952692aa423763c0e8ca8d950"
},
{
"key": "Content-Location",
"value": "https://fhir-api.public.post-prod.lifen.fr/fhir/dstu3/DocumentReference/1721103/_history/1"
},
{
"key": "Last-Modified",
"value": "Thu, 02 Sep 2021 10:46:51 GMT"
},
{
"key": "Location",
"value": "https://fhir-api.public.post-prod.lifen.fr/fhir/dstu3/DocumentReference/1721103/_history/1"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15724800; includeSubDomains"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Access-Control-Allow-Credentials",
"value": "true"
}
],
"cookie": [],
"body": "{\n \"resourceType\": \"DocumentReference\",\n \"id\": \"1721103\",\n \"meta\": {\n \"versionId\": \"1\",\n \"lastUpdated\": \"2021-09-02T10:46:51.615+00:00\",\n \"profile\": [\n \"http://lifen.fr/fhir/StructureDefinition/LifenDocumentReferenceCoreProfile\"\n ],\n \"tag\": [\n {\n \"system\": \"https://www.lifen.fr/default\",\n \"code\": \"DEFAULT\",\n \"display\": \"Default tag\"\n }\n ]\n },\n \"status\": \"current\",\n \"docStatus\": \"final\",\n \"type\": {\n \"coding\": [\n {\n \"system\": \"http://loinc.org\",\n \"code\": \"34109-9\",\n \"display\": \"Document médical\"\n }\n ]\n },\n \"indexed\": \"2021-02-11T09:25:39Z\",\n \"description\": \"aelgain-copiepatient.pdf\",\n \"content\": [\n {\n \"attachment\": {\n \"contentType\": \"application/pdf\",\n \"url\": \"Binary/1615660\",\n \"title\": \"aelgain-copiepatient.pdf\"\n }\n }\n ]\n}"
}
]
},
{
"name": "CommunicationRequest",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.environment.set(\"commuicationRequestId\", \"\");",
"",
"pm.test(\"The CommunicationRequest is created\", function () {",
" // chaisinon syntax",
" pm.response.to.have.status(201);",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.equal(\"application/fhir+json;charset=UTF-8\");",
"});",
"",
"const responseJson = pm.response.json();",
"",
"pm.test(\"The response have a communicationRequestId (and store it)\", function () {",
" pm.expect(responseJson.id, \"The server did not returned a CommunicationRequestId\").to.not.be.empty;",
" console.log(`Fetched commuicationRequestId: ${responseJson.id}`);",
"",
" // Best practice : separate setup / teardown logic from the testscript itself (ie: action to store data outside of this function)",
" pm.environment.set(\"commuicationRequestId\", responseJson.id);",
" pm.expect(pm.environment.get(\"commuicationRequestId\")).to.not.be.empty;",
"});",
"",
"pm.test(\"The CommunicationRequest status is 'Draft'\", function () {",
" pm.expect(responseJson.status).to.be.equals(\"draft\");",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"meta\": {\n \"tag\": [\n {\n \"system\": \"http://lifen.fr/fhir/tag/verified/sender\",\n \"code\": \"SENDER_VERIFIED\",\n \"display\": \"Sender is verified and should not be changed.\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/tag/processing/mode\",\n \"code\": \"IMMEDIATE_MODE\",\n \"display\": \"request should be treated in immediate mode\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/Resource/Tag/PatientAutomaticResending\",\n \"code\": \"NONE\",\n \"display\": \"Patient communication should not be resent\"\n }\n ]\n\t},\n \"status\": \"draft\",\n \"category\": [\n {\n \"coding\": [\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-category\",\n \"code\": \"MEDICAL_REPORT\"\n }\n ]\n }\n ],\n \"priority\": \"routine\",\n \"payload\": [\n {\n \"contentReference\": {\n \"reference\": \"DocumentReference/{{documentReferenceId}}\"\n }\n }\n ],\n \"sender\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/Resource/Extension/Source\",\n \"valueCode\": \"USER\"\n }\n ],\n \"reference\": \"Organization/2\"\n },\n \"requester\": {\n \"agent\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-requester-user-uuid\",\n \"valueString\": \"ea07d7c6-ff4b-43fc-9765-e4235886d30c\"\n }\n ],\n \"reference\": \"Organization/2\"\n }\n },\n \"resourceType\": \"CommunicationRequest\"\n}"
},
"url": {
"raw": "https://{{baseURL}}/fhir/CommunicationRequest",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"CommunicationRequest"
]
}
},
"response": [
{
"name": "CommunicationRequest",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n\t\"meta\": {\n \"tag\": [\n {\n \"system\": \"http://lifen.fr/fhir/tag/verified/sender\",\n \"code\": \"SENDER_VERIFIED\",\n \"display\": \"Sender is verified and should not be changed.\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/tag/processing/mode\",\n \"code\": \"IMMEDIATE_MODE\",\n \"display\": \"request should be treated in immediate mode\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/Resource/Tag/PatientAutomaticResending\",\n \"code\": \"NONE\",\n \"display\": \"Patient communication should not be resent\"\n }\n ]\n\t},\n \"status\": \"draft\",\n \"category\": [\n {\n \"coding\": [\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-category\",\n \"code\": \"MEDICAL_REPORT\"\n }\n ]\n }\n ],\n \"priority\": \"routine\",\n \"payload\": [\n {\n \"contentReference\": {\n \"reference\": \"DocumentReference/{{documentReferenceId}}\"\n }\n }\n ],\n \"sender\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/Resource/Extension/Source\",\n \"valueCode\": \"USER\"\n }\n ],\n \"reference\": \"Organization/2\"\n },\n \"requester\": {\n \"agent\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-requester-user-uuid\",\n \"valueString\": \"ea07d7c6-ff4b-43fc-9765-e4235886d30c\"\n }\n ],\n \"reference\": \"Organization/2\"\n }\n },\n \"resourceType\": \"CommunicationRequest\"\n}"
},
"url": {
"raw": "https://{{baseURL}}/fhir/CommunicationRequest",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"CommunicationRequest"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 02 Sep 2021 11:00:17 GMT"
},
{
"key": "Content-Type",
"value": "application/fhir+json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-B3-TraceId",
"value": "0226a8841b438fd4"
},
{
"key": "X-B3-SpanId",
"value": "0226a8841b438fd4"
},
{
"key": "X-B3-Sampled",
"value": "1"
},
{
"key": "X-Powered-By",
"value": "HAPI FHIR 4.2.0 REST Server (FHIR Server; FHIR 3.0.2/DSTU3)"
},
{
"key": "X-FHIR-Request-Validation",
"value": "No issues detected"
},
{
"key": "ETag",
"value": "W/\"1\""
},
{
"key": "X-Request-ID",
"value": "bb302f7a6e1c80901826d099d449c572"
},
{
"key": "Content-Location",
"value": "https://fhir-api.public.post-prod.lifen.fr/fhir/dstu3/CommunicationRequest/1721115/_history/1"
},
{
"key": "Last-Modified",
"value": "Thu, 02 Sep 2021 11:00:16 GMT"
},
{
"key": "Location",
"value": "https://fhir-api.public.post-prod.lifen.fr/fhir/dstu3/CommunicationRequest/1721115/_history/1"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15724800; includeSubDomains"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Access-Control-Allow-Credentials",
"value": "true"
}
],
"cookie": [],
"body": "{\n \"resourceType\": \"CommunicationRequest\",\n \"id\": \"1721115\",\n \"meta\": {\n \"versionId\": \"1\",\n \"lastUpdated\": \"2021-09-02T11:00:16.495+00:00\",\n \"profile\": [\n \"http://lifen.fr/fhir/StructureDefinition/LifenCommunicationRequestCoreProfile\"\n ],\n \"tag\": [\n {\n \"system\": \"http://lifen.fr/fhir/tag/verified/sender\",\n \"code\": \"SENDER_VERIFIED\",\n \"display\": \"Sender is verified and should not be changed.\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/tag/processing/mode\",\n \"code\": \"IMMEDIATE_MODE\",\n \"display\": \"request should be treated in immediate mode\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/Resource/Tag/PatientAutomaticResending\",\n \"code\": \"NONE\",\n \"display\": \"Patient communication should not be resent\"\n }\n ]\n },\n \"status\": \"draft\",\n \"category\": [\n {\n \"coding\": [\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-category\",\n \"code\": \"MEDICAL_REPORT\"\n }\n ]\n }\n ],\n \"priority\": \"routine\",\n \"payload\": [\n {\n \"contentReference\": {\n \"reference\": \"DocumentReference/1721113\"\n }\n }\n ],\n \"authoredOn\": \"2021-09-02T11:00:16+00:00\",\n \"sender\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/Resource/Extension/Source\",\n \"valueCode\": \"USER\"\n }\n ],\n \"reference\": \"Organization/2\"\n },\n \"requester\": {\n \"agent\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-requester-user-uuid\",\n \"valueString\": \"ea07d7c6-ff4b-43fc-9765-e4235886d30c\"\n }\n ],\n \"reference\": \"Organization/2\"\n }\n }\n}"
}
]
},
{
"name": "CommunicationRequest",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"setTimeout(function(){}, 10000);"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Created Communication Request exists\", function () {",
" pm.expect(pm.environment.get(\"commuicationRequestId\"), \"A commuicationRequestId is required for this test to pass :( \").to.not.be.empty;",
" // chai expect syntaxes",
" pm.response.to.have.status(200);",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.equal(\"application/fhir+json;charset=UTF-8\");",
"});",
"",
"const responseJson = pm.response.json();",
"",
"pm.test(\"It have a 'subject' section\", function() {",
" pm.expect(responseJson, \"The Communication Request must have a suject section\").to.have.property('subject').to.be.an('object');",
"});",
"",
"pm.test(\"It have a 'recipient' section\", function() {",
" pm.expect(responseJson, \"The Communication Request must have a recipient list\").to.have.property('recipient').to.be.an('array', \"Recipients must not be empty\").that.is.not.empty;",
"});",
"",
"pm.test(\"It have a Patient ID (and store it)\", function () {",
" pm.environment.set(\"patientId\", responseJson.subject.reference);",
" // note : we rely on the subject part to get the patientId, but it could not be reliable. Need more docs to select which one to choose.",
"",
" pm.expect(pm.environment.get(\"patientId\"), \"Saving the patientId failed.\").to.not.equal(\"\");",
" console.log(`Fetched patientId: ${responseJson.subject.reference}`);",
" // Best practice : separate setup / teardown logic from the testscript itself (ie: action to store outside of this function)",
"",
"});",
"",
"pm.test(\"That the CommunicationRequest status is 'Suspended'\", function () {",
" pm.expect(responseJson.status, \"The CommunicationRequest is not 'Suspended'\").to.be.equals(\"suspended\");",
" // could appreciate more intel on the workflow and possible statuses. It could be interesting to test that certains status transitions can't be performed (ie: suspended -> created) ",
"});",
"",
"pm.test(\"That recipients are referenced\", function() {",
" pm.expect(responseJson.recipient, \"Recipients must have a reference property\").to.satisfy(function(recipients) {",
" recipients.forEach((aRecipient) => {",
" if(!aRecipient.hasOwnProperty(\"reference\")) return false;",
" });",
" return true;",
" });",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://{{baseURL}}/fhir/CommunicationRequest/{{commuicationRequestId}}",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"CommunicationRequest",
"{{commuicationRequestId}}"
]
}
},
"response": [
{
"name": "CommunicationRequest",
"originalRequest": {
"method": "GET",
"header": [],
"url": {
"raw": "https://{{baseURL}}/fhir/CommunicationRequest/{{commuicationRequestId}}",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"CommunicationRequest",
"{{commuicationRequestId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Thu, 02 Sep 2021 11:01:25 GMT"
},
{
"key": "Content-Type",
"value": "application/fhir+json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-B3-TraceId",
"value": "197d894e89bb1bf5"
},
{
"key": "X-B3-SpanId",
"value": "197d894e89bb1bf5"
},
{
"key": "X-B3-Sampled",
"value": "1"
},
{
"key": "X-Powered-By",
"value": "HAPI FHIR 4.2.0 REST Server (FHIR Server; FHIR 3.0.2/DSTU3)"
},
{
"key": "ETag",
"value": "W/\"2\""
},
{
"key": "X-Request-ID",
"value": "44ff89f0b02d19e5cd4b286df64f02fe"
},
{
"key": "Content-Location",
"value": "https://fhir-api.public.post-prod.lifen.fr/fhir/dstu3/CommunicationRequest/1721115/_history/2"
},
{
"key": "Last-Modified",
"value": "Thu, 02 Sep 2021 11:00:33 GMT"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15724800; includeSubDomains"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Access-Control-Allow-Credentials",
"value": "true"
}
],
"cookie": [],
"body": "{\n \"resourceType\": \"CommunicationRequest\",\n \"id\": \"1721115\",\n \"meta\": {\n \"versionId\": \"2\",\n \"lastUpdated\": \"2021-09-02T11:00:33.000+00:00\",\n \"profile\": [\n \"http://lifen.fr/fhir/StructureDefinition/LifenCommunicationRequestCoreProfile\"\n ],\n \"tag\": [\n {\n \"system\": \"http://lifen.fr/fhir/tag/verified/sender\",\n \"code\": \"SENDER_VERIFIED\",\n \"display\": \"Sender is verified and should not be changed.\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/Resource/Tag/PatientAutomaticResending\",\n \"code\": \"NONE\",\n \"display\": \"Patient communication should not be resent\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/tag/processing/mode\",\n \"code\": \"IMMEDIATE_MODE\",\n \"display\": \"request should be treated in immediate mode\"\n },\n {\n \"system\": \"http://lifen.fr/fhir/tag/processing/ia\",\n \"code\": \"PROCESSED\",\n \"display\": \"ressource processed by Irene\"\n }\n ]\n },\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/LifenExtensionCommunicationRequestSendingStatus\",\n \"valueCode\": \"READY_TO_SEND\"\n }\n ],\n \"status\": \"suspended\",\n \"category\": [\n {\n \"coding\": [\n {\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-category\",\n \"code\": \"MEDICAL_REPORT\"\n }\n ]\n }\n ],\n \"priority\": \"routine\",\n \"medium\": [\n {\n \"coding\": [\n {\n \"id\": \"469965\",\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-medium\",\n \"code\": \"MSSANTE\",\n \"display\": \"william.eclancher@medecin.mssante.fr\"\n }\n ]\n },\n {\n \"coding\": [\n {\n \"id\": \"1309813159882648557\",\n \"system\": \"http://lifen.fr/fhir/CodeSystem/communication-medium\",\n \"code\": \"MAIL\",\n \"display\": \"ael.gain@lifen.fr\"\n }\n ]\n }\n ],\n \"subject\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/match-grade\",\n \"valueCode\": \"certain\"\n }\n ],\n \"reference\": \"Patient/1615460\"\n },\n \"recipient\": [\n {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-recipient-details\",\n \"valueContactPoint\": {\n \"id\": \"469965\",\n \"extension\": [\n {\n \"url\": \"http://interopsante.org/fhir/structuredefinition/fr-email-domain\",\n \"valueCoding\": {\n \"system\": \"http://interopsante.org/fhir/valueset/fr-email-domain\",\n \"code\": \"mssante\",\n \"display\": \"MSSanté\"\n }\n }\n ],\n \"system\": \"email\",\n \"value\": \"william.eclancher@medecin.mssante.fr\",\n \"use\": \"work\",\n \"rank\": 1\n }\n }\n ],\n \"reference\": \"Practitioner/120849\"\n },\n {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-recipient-details\",\n \"valueContactPoint\": {\n \"id\": \"1309813159882648557\",\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/Resource/Extension/EmailAddressVerification-1.0\",\n \"valueCode\": \"VALID\"\n }\n ],\n \"system\": \"email\",\n \"value\": \"ael.gain@lifen.fr\",\n \"use\": \"work\"\n }\n }\n ],\n \"reference\": \"Patient/1615460\"\n }\n ],\n \"payload\": [\n {\n \"contentReference\": {\n \"reference\": \"DocumentReference/1721113\"\n }\n }\n ],\n \"authoredOn\": \"2021-09-02T11:00:16+00:00\",\n \"sender\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/Resource/Extension/Source\",\n \"valueCode\": \"USER\"\n }\n ],\n \"reference\": \"Organization/2\"\n },\n \"requester\": {\n \"agent\": {\n \"extension\": [\n {\n \"url\": \"http://lifen.fr/fhir/StructureDefinition/communicationrequest-requester-user-uuid\",\n \"valueString\": \"ea07d7c6-ff4b-43fc-9765-e4235886d30c\"\n }\n ],\n \"reference\": \"Organization/2\"\n }\n }\n}"
}
]
},
{
"name": "Patient",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"The Patient exists\", function () {",
" pm.expect(pm.environment.get(\"patientId\"), \"A patientId is required for this test to pass :( \").to.not.be.empty;",
" // chai expect syntaxes",
" pm.response.to.have.status(200);",
" pm.expect(pm.response.headers.get(\"Content-Type\")).to.equal(\"application/fhir+json;charset=UTF-8\");",
"});",
"",
"const responseJson = pm.response.json();",
"",
"pm.test(\"It fetch the right Patient\", function () {",
" pm.expect(responseJson.id, \"The server did not returned the expected Patient\").to.equals(pm.environment.get(\"patientId\").split(\"/\")[1]);",
"});",
"",
"pm.test(\"That the patient have a at least one given name, and a last name\", function() {",
" pm.expect(responseJson.name, \"The Patient doesn't have a name\").to.be.an(\"array\").that.is.not.empty;",
" // Magic number, We can improve to check each item in the list.",
" pm.expect(responseJson.name[0], \"The Patient doesn't have a last name\").to.have.property('family');",
" pm.expect(responseJson.name[0], \"The Patient doesn't have a given name\").to.have.property('given').that.is.an(\"array\").that.is.not.empty; ",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://{{baseURL}}/fhir/{{patientId}}",
"protocol": "https",
"host": [
"{{baseURL}}"
],
"path": [
"fhir",
"{{patientId}}"
]
}
},
"response": []
}
],
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{json_web_token}}",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"now = new Date();",
"token_date = new Date(pm.globals.get(\"token_expiration\"));",
"// if current token is expired…",
"if(token_date < now){",
" // …request new one",
" const postRequest = {",
" url: 'https://lifen-post-prod.eu.auth0.com/oauth/token',",
" method: 'POST',",
" header: {",
" 'Content-Type': 'application/json',",
" },",
" body: {",
" mode: 'raw',",
" raw: JSON.stringify(",
" {",
" client_id: 'szVsMPaDPUdwqngGiLoHfXFT5XCYPFcy',",
" client_secret: 'sMp2PB-QWBZupCB4IXJrWDJ-7tlpUl09vQ2tMKdy049He7-g93ofbXz7ESlAc82B',",
" audience: 'post-prod-apis',",
" grant_type: 'client_credentials'",
" }",
" )",
" }",
" };",
" // save it in globals",
" pm.sendRequest(postRequest, function (err, response) {",
" if(err != undefined) throw err;",
" const responseJson = response.json();",
" pm.globals.set(\"json_web_token\", responseJson.access_token);",
" now.setTime(now.getTime() + (responseJson.expires_in * 1000));",
" pm.globals.set(\"token_expiration\", now);",
" });",
"}"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]
}