diff --git a/bruno/PDM/.gitignore b/bruno/PDM/.gitignore new file mode 100644 index 0000000..18aeac8 --- /dev/null +++ b/bruno/PDM/.gitignore @@ -0,0 +1,3 @@ + +**/node_modules/** + diff --git a/bruno/PDM/Bundle/Post_a_Batch_Bundle_with_gets.bru b/bruno/PDM/Bundle/Post_a_Batch_Bundle_with_gets.bru new file mode 100644 index 0000000..5cad76b --- /dev/null +++ b/bruno/PDM/Bundle/Post_a_Batch_Bundle_with_gets.bru @@ -0,0 +1,36 @@ +meta { + name: Post a Batch Bundle with gets + type: http + seq: 4 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/ + body: json + auth: inherit +} + +headers { + X-Request-ID: bf95293b-13d3-46a4-abe0-f64f7ed9adfd + Content-Type: application/fhir+json +} + +body:json { + { + "resourceType": "Bundle", + "type": "transaction", + "entry": [ + { + "request": { + "method": "GET", + "url": "Observation/b9d8d29f-ced1-3d02-b55b-3c01f24c51fd" + } + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru b/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru new file mode 100644 index 0000000..459ae42 --- /dev/null +++ b/bruno/PDM/Bundle/Post_a_Transaction_Bundle.bru @@ -0,0 +1,135 @@ +meta { + name: Post a Transaction Bundle + type: http + seq: 5 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/ + body: json + auth: inherit +} + +headers { + X-Request-ID: bf95293b-13d3-46a4-abe0-f64f7ed9adfd +} + +body:json { + { + "resourceType": "Bundle", + "type": "transaction", + "entry": [ + { + "request": { + "method": "PUT", + "url": "Observation/ec5e3a08-a4fe-462b-b627-d553b53a66f2", + "ifMatch": "0" + }, + "resource": { + "resourceType": "Observation", + "id": "ec5e3a08-a4fe-462b-b627-d553b53a66f2", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Observation-Group-Lab" + ] + }, + "identifier": [ + { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "331b7489-c241-4235-93e6-614579d7e14e" + } + ], + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "252167001", + "display": "Urea and electrolytes" + } + ] + }, + "subject": { + "reference": "urn:uuid:45d437b5-52b9-42a6-aafd-2bbe967f00d8", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "issued": "2022-03-08T14:23:00+00:00", + "performer": [ + { + "reference": "urn:uuid:1847e638-1b68-4d7a-965f-6d5739b4b16e", + "display": "TD008362 PATH LAB 001" + } + ], + "hasMember": [ + { + "reference": "urn:uuid:e6556c4a-cf31-43b2-af6f-9c8604b650f9" + } + ] + } + }, + { + "request": { + "method": "PUT", + "url": "Specimen/57f7db59-e1f9-4b77-903f-7f0441467cb9", + "ifMatch": "0" + }, + "resource": { + "resourceType": "Specimen", + "id": "57f7db59-e1f9-4b77-903f-7f0441467cb9", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Specimen" + ] + }, + "identifier": [ + { + "system": "http://B82033-pickeringmedicalpractice.com/specimen", + "value": "SPC-REQ-20220129-000362" + } + ], + "status": "available", + "type": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "122555007", + "display": "Venous blood specimen" + } + ] + }, + "subject": { + "reference": "urn:uuid:45d437b5-52b9-42a6-aafd-2bbe967f00d8", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "collection": { + "collectedDateTime": "2022-01-29T10:18:00+00:00" + } + } + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Bundle/folder.bru b/bruno/PDM/Bundle/folder.bru new file mode 100644 index 0000000..a9ae5e9 --- /dev/null +++ b/bruno/PDM/Bundle/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Bundle + seq: 6 +} + +auth { + mode: inherit +} diff --git a/bruno/PDM/Document/Post_a_Document.bru b/bruno/PDM/Document/Post_a_Document.bru new file mode 100644 index 0000000..a76c22f --- /dev/null +++ b/bruno/PDM/Document/Post_a_Document.bru @@ -0,0 +1,164 @@ +meta { + name: Post a Document + type: http + seq: 3 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + X-Request-ID: ed338135-a16a-49ab-a139-9bf0b76f9b2e +} + +body:json { + { + "resourceType": "Bundle", + "id": "ab3c95c5-9484-4ba5-b04e-49e148411387", + "identifier": { + "system": "http://healthintersections.com.au/test", + "value": "test_value" + }, + "type": "document", + "timestamp": "2020-12-11T14:30:00+01:00", + "entry": [ + { + "fullUrl": "urn:uuid:88c5f0ec-6751-43c7-83eb-c374ef43d69b", + "resource": { + "id": "88c5f0ec-6751-43c7-83eb-c374ef43d69b", + "resourceType": "Composition", + "type": { + "coding": [ + { + "system": "http://loinc.org", + "code": "00", + "display": "test comp for specimen" + } + ] + }, + "status": "final", + "date": "2020-12-11T14:30:00+01:00", + "author": [ + { + "reference": "urn:uuid:45271f7f-63ab-4946-970f-3daaaa0663ff" + } + ], + "subject": { + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "encounter": {"reference": "urn:uuid:4a98915e-7b58-4f9d-ae3e-ae4bccb6769b"}, + "title": "test document" + } + }, + { + "fullUrl": "urn:uuid:45271f7f-63ab-4946-970f-3daaaa0663ff", + "resource": { + "resourceType": "Practitioner", + "id": "45271f7f-63ab-4946-970f-3daaaa0663ff", + "active": true, + "name": [ + { + "family": "Doe", + "given": ["John"] + } + ] + } + }, + { + "fullUrl": "urn:uuid:4a98915e-7b58-4f9d-ae3e-ae4bccb6769b", + "resource": { + "resourceType": "Encounter", + "id": "4a98915e-7b58-4f9d-ae3e-ae4bccb6769b", + "status": "finished", + "class": { + "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode", + "code": "IMP", + "display": "inpatient encounter" + }, + "type": [ + { + "text": "Orthopedic Admission" + } + ], + "subject": { + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + } + } + }, + { + "fullUrl": "urn:uuid:64a7c79b-21e1-46b3-985d-9da9600350a8", + "resource": { + "resourceType": "Observation", + "id": "64a7c79b-21e1-46b3-985d-9da9600350a8", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Observation-Group-Lab" + ] + }, + "identifier": [ + { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "331b7489-c241-4235-93e6-614579d7e14e" + } + ], + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "252167001", + "display": "Urea and electrolytes" + } + ] + }, + "subject": { + "display": "WELSH, Joel", + "identifier": + { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "issued": "2022-03-08T14:23:00+00:00", + "performer": [ + { + "reference": "urn:uuid:45271f7f-63ab-4946-970f-3daaaa0663ff", + "display": "Something Else" + } + ], + "hasMember": [ + { + "reference": "urn:uuid:e6556c4a-cf31-43b2-af6f-9c8604b650f9" + } + ] + } + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Document/Post_a_Document_Pathology-Bundle-CRP-Report-Document-Example.bru b/bruno/PDM/Document/Post_a_Document_Pathology-Bundle-CRP-Report-Document-Example.bru new file mode 100644 index 0000000..a9ad773 --- /dev/null +++ b/bruno/PDM/Document/Post_a_Document_Pathology-Bundle-CRP-Report-Document-Example.bru @@ -0,0 +1,473 @@ +meta { + name: Post_a_Document_Pathology-Bundle-CRP-Report-Document-Example + type: http + seq: 1 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Bundle + body: json + auth: inherit +} + +headers { + X-Request-ID: e317708a-741e-45f7-be6c-b8b4ff86cbb9 +} + +body:json { + { + "resourceType": "Bundle", + "id": "3fab3fe5-1304-40bc-ba8b-9f85c3e3f4aa", + "meta": { + "lastUpdated": "2022-03-08T12:09:00+00:00" + }, + "identifier": { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "1f859037-2942-4117-884a-f51b62db5a52" + }, + "type": "document", + "timestamp": "2022-03-08T12:09:00+00:00", + "entry": [ + { + "fullUrl": "urn:uuid:ce2073cd-7f19-4fd8-9956-f30ef7b4bd44", + "resource": { + "resourceType": "Composition", + "id": "ce2073cd-7f19-4fd8-9956-f30ef7b4bd44", + "extension": [ + { + "url": "http://hl7.eu/fhir/StructureDefinition/composition-basedOn-order-or-requisition", + "valueReference": { + "reference": "urn:uuid:1c38d507-9ad7-4b49-ba91-7da204842cac" + } + }, + { + "url": "http://hl7.eu/fhir/laboratory/StructureDefinition/composition-diagnosticReportReference", + "valueReference": { + "reference": "urn:uuid:35d46ca1-f253-4c97-b7ee-fb5fccdf6c20" + } + } + ], + "identifier": { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "c3d5e6f7-8901-2345-6789-0abcdef12345" + }, + "status": "final", + "type": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "721981007", + "display": "Diagnostic studies report" + } + ] + }, + "category": [ + { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "394915009", + "display": "General pathology (specialty)" + } + ] + } + ], + "subject": { + "reference": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "date": "2022-03-08T12:09:00+00:00", + "author": [ + { + "reference": "urn:uuid:8a6d85b8-9837-4fed-a257-4cf207988338", + "display": "TD008362 PATH LAB 001" + } + ], + "title": "Laboratory Report", + "section": [ + { + "title": "CRP (C reactive protein) mass concentration in serum", + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "1106741000000105", + "display": "CRP (C reactive protein) mass concentration in serum" + } + ] + }, + "entry": [ + { + "reference": "urn:uuid:8697e1ea-a15d-4cab-95d9-7335f4b57e22" + } + ] + } + ] + } + }, + { + "fullUrl": "urn:uuid:8a6d85b8-9837-4fed-a257-4cf207988338", + "resource": { + "resourceType": "Organization", + "id": "8a6d85b8-9837-4fed-a257-4cf207988338", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "Y8J7D" + } + ], + "name": "TD008362 PATH LAB 001", + "address": [ + { + "line": [ + "PATHOLOGY LAB", + "7-8 WELLINGTON PLACE" + ], + "city": "LEEDS", + "district": "WEST YORKSHIRE", + "postalCode": "LS1 4AP" + } + ] + } + }, + { + "fullUrl": "urn:uuid:3c43b5b3-06d6-445f-ae9a-48d5f05df434", + "resource": { + "resourceType": "Organization", + "id": "3c43b5b3-06d6-445f-ae9a-48d5f05df434", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/ods-organization-code", + "value": "B82033" + } + ], + "name": "PICKERING MEDICAL PRACTICE", + "address": [ + { + "line": [ + "SOUTHGATE" + ], + "city": "PICKERING", + "district": "NORTH YORKSHIRE", + "postalCode": "YO18 8BL" + } + ] + } + }, + { + "fullUrl": "urn:uuid:9a835acf-d715-4d84-8dcf-a8435f6417fe", + "resource": { + "resourceType": "Practitioner", + "id": "9a835acf-d715-4d84-8dcf-a8435f6417fe", + "identifier": [ + { + "system": "https://fhir.hl7.org.uk/Id/gmc-number", + "value": "C1008215" + } + ], + "name": [ + { + "use": "official", + "family": "GASKELL", + "given": [ + "Gale" + ], + "prefix": [ + "Dr" + ] + } + ] + } + }, + { + "fullUrl": "urn:uuid:d4f5e6a1-2b3c-4d5e-9f6a-7b8c9d0e1f2a", + "resource": { + "resourceType": "PractitionerRole", + "id": "d4f5e6a1-2b3c-4d5e-9f6a-7b8c9d0e1f2a", + "practitioner": { + "reference": "urn:uuid:9a835acf-d715-4d84-8dcf-a8435f6417fe" + }, + "organization": { + "reference": "urn:uuid:3c43b5b3-06d6-445f-ae9a-48d5f05df434", + "display": "PICKERING MEDICAL PRACTICE" + } + } + }, + { + "fullUrl": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "resource": { + "resourceType": "Patient", + "id": "ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "identifier": [ + { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638", + "use": "official" + } + ] + } + }, + { + "fullUrl": "urn:uuid:1c38d507-9ad7-4b49-ba91-7da204842cac", + "resource": { + "resourceType": "ServiceRequest", + "id": "1c38d507-9ad7-4b49-ba91-7da204842cac", + "identifier": [ + { + "system": "http://B82033-pickeringmedicalpractice.com/labrequest", + "value": "REQ-20220307-000142" + } + ], + "status": "active", + "intent": "order", + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "135842001", + "display": "Serum C reactive protein level" + } + ] + }, + "subject": { + "reference": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "authoredOn": "2022-01-29T10:24:00+00:00", + "requester": { + "reference": "urn:uuid:d4f5e6a1-2b3c-4d5e-9f6a-7b8c9d0e1f2a" + }, + "performer": [ + { + "reference": "urn:uuid:8a6d85b8-9837-4fed-a257-4cf207988338", + "display": "TD008362 PATH LAB 001" + } + ], + "specimen": [ + { + "reference": "urn:uuid:bab0eaec-1ec5-4598-b660-90bb38a1030d" + } + ] + } + }, + { + "fullUrl": "urn:uuid:35d46ca1-f253-4c97-b7ee-fb5fccdf6c20", + "resource": { + "resourceType": "DiagnosticReport", + "id": "35d46ca1-f253-4c97-b7ee-fb5fccdf6c20", + "identifier": [ + { + "system": "http://Y8J7D-pathlab001.com/report", + "value": "REP-20220308-004205" + } + ], + "basedOn": [ + { + "reference": "urn:uuid:1c38d507-9ad7-4b49-ba91-7da204842cac" + } + ], + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0074", + "code": "LAB", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "721981007", + "display": "Diagnostic studies report" + } + ] + }, + "subject": { + "reference": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "issued": "2022-03-08T12:09:00+00:00", + "performer": [ + { + "reference": "urn:uuid:8a6d85b8-9837-4fed-a257-4cf207988338", + "display": "TD008362 PATH LAB 001" + } + ], + "specimen": [ + { + "reference": "urn:uuid:bab0eaec-1ec5-4598-b660-90bb38a1030d" + } + ], + "result": [ + { + "reference": "urn:uuid:8697e1ea-a15d-4cab-95d9-7335f4b57e22" + } + ] + } + }, + { + "fullUrl": "urn:uuid:bab0eaec-1ec5-4598-b660-90bb38a1030d", + "resource": { + "resourceType": "Specimen", + "id": "bab0eaec-1ec5-4598-b660-90bb38a1030d", + "identifier": [ + { + "system": "http://B82033-pickeringmedicalpractice.com/specimen", + "value": "SPC-REQ-20220307-000105" + } + ], + "accessionIdentifier": { + "system": "http://Y8J7D-pathlab001.com/specimen", + "value": "SPC-Lab-20220307-007856" + }, + "status": "available", + "type": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "122555007", + "display": "Venous blood specimen" + } + ] + }, + "subject": { + "reference": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "receivedTime": "2022-03-07T14:58:00+00:00", + "collection": { + "collectedDateTime": "2022-03-07T11:42:00+00:00" + } + } + }, + { + "fullUrl": "urn:uuid:8697e1ea-a15d-4cab-95d9-7335f4b57e22", + "resource": { + "resourceType": "Observation", + "id": "8697e1ea-a15d-4cab-95d9-7335f4b57e22", + "identifier": [ + { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "09fd65ba-4bbb-49dd-9d16-ca74f885db6c" + } + ], + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/valueset-reference", + "valueUri": "https://fhir.hl7.org.uk/ValueSet/UKCore-PathologyBoundedCodeListObservables" + } + ], + "system": "http://snomed.info/sct", + "code": "1001371000000100", + "display": "Serum CRP (C reactive protein) level" + }, + { + "extension": [ + { + "url": "http://hl7.org/fhir/StructureDefinition/valueset-reference", + "valueUri": "https://fhir.hl7.org.uk/ValueSet/UKCore-PathologyAndLaboratoryMedicineObservables" + } + ], + "system": "http://snomed.info/sct", + "code": "1106741000000105", + "display": "CRP (C reactive protein) mass concentration in serum" + } + ] + }, + "subject": { + "reference": "urn:uuid:ab87a3f8-1d37-44a9-804e-5e962598a6e4", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "issued": "2022-03-08T12:09:00+00:00", + "performer": [ + { + "reference": "urn:uuid:8a6d85b8-9837-4fed-a257-4cf207988338", + "display": "TD008362 PATH LAB 001" + } + ], + "valueQuantity": { + "value": 200, + "unit": "mg/L", + "system": "http://unitsofmeasure.org", + "code": "mg/L" + }, + "interpretation": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation", + "code": "H", + "display": "High" + } + ] + } + ], + "specimen": { + "reference": "urn:uuid:bab0eaec-1ec5-4598-b660-90bb38a1030d" + }, + "referenceRange": [ + { + "low": { + "value": 0, + "unit": "mg/L", + "system": "http://unitsofmeasure.org", + "code": "mg/L" + }, + "high": { + "value": 5, + "unit": "mg/L", + "system": "http://unitsofmeasure.org", + "code": "mg/L" + } + } + ] + } + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Document/Retrieve_Document.bru b/bruno/PDM/Document/Retrieve_Document.bru new file mode 100644 index 0000000..c5831f6 --- /dev/null +++ b/bruno/PDM/Document/Retrieve_Document.bru @@ -0,0 +1,27 @@ +meta { + name: Retrieve Document + type: http + seq: 4 +} + +get { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Bundle/6a0c6a4d-9941-35cf-b83d-76fa4b880a85 + body: none + auth: inherit +} + +headers { + X-Request-ID: Set By Script + X-Correlation-ID: Set By Script +} + +script:pre-request { + const crypto = require("crypto"); + req.setHeader('X-Request-ID', crypto.randomUUID()) + req.setHeader('X-Correlation-ID', crypto.randomUUID()) +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Document/folder.bru b/bruno/PDM/Document/folder.bru new file mode 100644 index 0000000..0139902 --- /dev/null +++ b/bruno/PDM/Document/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Document + seq: 5 +} + +auth { + mode: inherit +} diff --git a/bruno/PDM/Get_Auth_Token.bru b/bruno/PDM/Get_Auth_Token.bru new file mode 100644 index 0000000..d8045d5 --- /dev/null +++ b/bruno/PDM/Get_Auth_Token.bru @@ -0,0 +1,72 @@ +meta { + name: Get Auth Token + type: http + seq: 2 +} + +post { + url: https://int.api.service.nhs.uk/oauth2/token + body: formUrlEncoded + auth: none +} + +body:form-urlencoded { + grant_type: client_credentials + client_assertion_type: urn:ietf:params:oauth:client-assertion-type:jwt-bearer +} + +script:pre-request { + const jwt = require("jsonwebtoken"); + const fs = require("fs"); + const crypto = require("crypto"); + + // Read env vars + const secret = bru.getEnvVar("JWT_SECRET"); + const privateKeyPath = bru.getEnvVar("PRIVATE_KEY_PATH"); + + // Enviroment variables check + if (!secret) { + throw new Error("JWT_SECRET environment variable is missing."); + } + if (!privateKeyPath) { + throw new Error("PRIVATE_KEY_PATH environment variable is missing."); + } + + const privateKey = fs.readFileSync(privateKeyPath) + + const payload = { + sub: secret, + iss: secret, + jti: crypto.randomUUID(), + aud: "https://int.api.service.nhs.uk/oauth2/token", + exp: (Date.now()/1000) + 300 + }; + + const options = { + algorithm:'RS512', + header: {kid: "INT-1"} + } + + + // Sign token + const token = jwt.sign(payload, privateKey, options); + + + let new_body = req.getBody(); + new_body.push({name: "client_assertion", value:token}) + + req.setBody(new_body) + + + // For debugging: see the generated token in the console + // console.log("Generated JWT:", token); +} + +script:post-response { + bru.setEnvVar("auth_token", res.getBody().access_token) +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Observation/Create_Observation.bru b/bruno/PDM/Observation/Create_Observation.bru new file mode 100644 index 0000000..15cdb7a --- /dev/null +++ b/bruno/PDM/Observation/Create_Observation.bru @@ -0,0 +1,79 @@ +meta { + name: Create an Observation + type: http + seq: 1 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Observation + body: json + auth: inherit +} + +headers { + X-Request-ID: a1b2c03d-7ebf-4bb9-8167-398b2ea1daa3 +} + +body:json { + { + "resourceType": "Observation", + "id": "3206e042-1851-4e80-8a54-8146e61c1d5d", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Observation-Group-Lab" + ] + }, + "identifier": [ + { + "system": "https://tools.ietf.org/html/rfc4122", + "value": "331b7489-c241-4235-93e6-614579d7e14e" + } + ], + "status": "final", + "category": [ + { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/observation-category", + "code": "laboratory", + "display": "Laboratory" + } + ] + } + ], + "code": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "252167001", + "display": "Urea and electrolytes" + } + ] + }, + "subject": { + "reference": "urn:uuid:45d437b5-52b9-42a6-aafd-2bbe967f00d8", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "issued": "2023-03-08T14:23:00+00:00", + "performer": [ + { + "reference": "urn:uuid:1847e638-1b68-4d7a-965f-6d5739b4b16e", + "display": "TD008362 PATH LAB 001" + } + ], + "hasMember": [ + { + "reference": "urn:uuid:e6556c4a-cf31-43b2-af6f-9c8604b650f9" + } + ] + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Observation/Retrieve_Observation.bru b/bruno/PDM/Observation/Retrieve_Observation.bru new file mode 100644 index 0000000..fceaaee --- /dev/null +++ b/bruno/PDM/Observation/Retrieve_Observation.bru @@ -0,0 +1,20 @@ +meta { + name: Retrieve Observation + type: http + seq: 2 +} + +get { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Observation/ec5e3a08-a4fe-462b-b627-d553b53a66f2 + body: none + auth: inherit +} + +headers { + X-Request-ID: 3f99b84f-361c-4ec7-a7b4-5104ed70afd5 +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Observation/folder.bru b/bruno/PDM/Observation/folder.bru new file mode 100644 index 0000000..91b09ac --- /dev/null +++ b/bruno/PDM/Observation/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Observation + seq: 3 +} + +auth { + mode: inherit +} diff --git a/bruno/PDM/README.md b/bruno/PDM/README.md new file mode 100644 index 0000000..b6e4e7e --- /dev/null +++ b/bruno/PDM/README.md @@ -0,0 +1,13 @@ +# PDM Collection Setup + +## Install dependencies + +While in the dev container, navigate to the PDM collection directory and run the command `npm install` + +## Authentication Setup + +Follow the instructions on this [confluence page](https://nhsd-confluence.digital.nhs.uk/x/ixnIT) to setup Bruno with the PDM INT Environment + +## Getting Auth Token + +Once you have completed the previous instructions you should be able to run the Get Auth Token request, once the request is complete it should copy the returned token into the `auth_token` environment variable. The collection has been setup to automatically use this variable to authenticate requests diff --git a/bruno/PDM/Specimen/Create_Specimen.bru b/bruno/PDM/Specimen/Create_Specimen.bru new file mode 100644 index 0000000..24b9f59 --- /dev/null +++ b/bruno/PDM/Specimen/Create_Specimen.bru @@ -0,0 +1,59 @@ +meta { + name: Create a Specimen + type: http + seq: 2 +} + +post { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Specimen + body: json + auth: inherit +} + +headers { + X-Request-ID: bc3baa9e-75f6-4003-ae83-d1670aefc207 +} + +body:json { + { + "resourceType": "Specimen", + "id": "bab0eaec-1ec5-4598-b660-90bb38a1030d", + "meta": { + "profile": [ + "https://fhir.hl7.org.uk/StructureDefinition/UKCore-Specimen" + ] + }, + "identifier": [ + { + "system": "http://B82033-pickeringmedicalpractice.com/specimen", + "value": "SPC-REQ-20220129-000362" + } + ], + "status": "available", + "type": { + "coding": [ + { + "system": "http://snomed.info/sct", + "code": "122555007", + "display": "Venous blood specimen" + } + ] + }, + "subject": { + "reference": "urn:uuid:45d437b5-52b9-42a6-aafd-2bbe967f00d8", + "display": "WELSH, Joel", + "identifier": { + "system": "https://fhir.nhs.uk/Id/nhs-number", + "value": "9727710638" + } + }, + "collection": { + "collectedDateTime": "2022-01-29T10:18:00+00:00" + } + } +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Specimen/Retrieve_Specimen.bru b/bruno/PDM/Specimen/Retrieve_Specimen.bru new file mode 100644 index 0000000..cd7e02f --- /dev/null +++ b/bruno/PDM/Specimen/Retrieve_Specimen.bru @@ -0,0 +1,20 @@ +meta { + name: Retrieve Specimen + type: http + seq: 1 +} + +get { + url: https://int.api.service.nhs.uk/patient-data-manager/FHIR/R4/Specimen/6a0c6a4d-9941-35cf-b83d-76fa4b880a85 + body: none + auth: inherit +} + +headers { + X-Request-ID: 3f99b84f-361c-4ec7-a7b4-5104ed70afd5 +} + +settings { + encodeUrl: true + timeout: 0 +} diff --git a/bruno/PDM/Specimen/folder.bru b/bruno/PDM/Specimen/folder.bru new file mode 100644 index 0000000..02d6445 --- /dev/null +++ b/bruno/PDM/Specimen/folder.bru @@ -0,0 +1,8 @@ +meta { + name: Specimen + seq: 4 +} + +auth { + mode: inherit +} diff --git a/bruno/PDM/bruno.json b/bruno/PDM/bruno.json new file mode 100644 index 0000000..bf06df1 --- /dev/null +++ b/bruno/PDM/bruno.json @@ -0,0 +1,15 @@ +{ + "version": "1", + "name": "PDM", + "type": "collection", + "ignore": [ + "node_modules", + ".git" + ], + "scripts": { + "moduleWhiteList": ["jsonwebtoken", "fs", "crypto"], + "filesystemAccess": { + "allow": true + } + } +} diff --git a/bruno/PDM/collection.bru b/bruno/PDM/collection.bru new file mode 100644 index 0000000..3458806 --- /dev/null +++ b/bruno/PDM/collection.bru @@ -0,0 +1,7 @@ +auth { + mode: bearer +} + +auth:bearer { + token: {{auth_token}} +} diff --git a/bruno/PDM/environments/PDM.bru b/bruno/PDM/environments/PDM.bru new file mode 100644 index 0000000..9048c2a --- /dev/null +++ b/bruno/PDM/environments/PDM.bru @@ -0,0 +1,5 @@ +vars:secret [ + PRIVATE_KEY_PATH, + JWT_SECRET, + auth_token +] diff --git a/bruno/PDM/package-lock.json b/bruno/PDM/package-lock.json new file mode 100644 index 0000000..45ecd83 --- /dev/null +++ b/bruno/PDM/package-lock.json @@ -0,0 +1,154 @@ +{ + "name": "pdm", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pdm", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "jsonwebtoken": "^9.0.3" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", + "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + } + } +} diff --git a/bruno/PDM/package.json b/bruno/PDM/package.json new file mode 100644 index 0000000..6f38dac --- /dev/null +++ b/bruno/PDM/package.json @@ -0,0 +1,15 @@ +{ + "name": "pdm", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "commonjs", + "dependencies": { + "jsonwebtoken": "^9.0.3" + } +} diff --git a/docs/developer-guides/Bruno.md b/docs/developer-guides/Bruno.md new file mode 100644 index 0000000..27ece8b --- /dev/null +++ b/docs/developer-guides/Bruno.md @@ -0,0 +1,27 @@ +# Developer Guide: Bruno + +## Installation + +### Windows + +On windows you can download the app from the [Bruno website](https://www.usebruno.com/downloads) + +### Mac + +On mac you can either download from the Bruno Website or you can install the app using Homebrew using the command `brew install bruno` + +## Usage + +Using the Bruno UI, Open the collection you want to interact with from the repository. + +NOTE - if you have cloned your repository in wsl, you can type `\\wsl.localhost\Ubuntu\home\` into the address bar to search your wsl directory + +Select the Bruno environment you want to use for the collection, there may be multiple environments for a collection, this will be defined as part of the code in the collection. + +![environment selection](assets/bruno_guide/environment.png) + +Some of the environment variables will be hidden and not committed to the repository, for these values you will need to populate them yourself. + +Some collections may have custom scripts to run before/after requests, if these script require external dependencies then you will need to install these using `npm install` in the directory of the collection. For requests using external libraries or using the file system you will need to make sure Bruno is running in developer mode. + +![sandbox selection](assets/bruno_guide/js_sandbox_mode.png) diff --git a/docs/developer-guides/assets/bruno_guide/environment.png b/docs/developer-guides/assets/bruno_guide/environment.png new file mode 100644 index 0000000..44185a2 Binary files /dev/null and b/docs/developer-guides/assets/bruno_guide/environment.png differ diff --git a/docs/developer-guides/assets/bruno_guide/js_sandbox_mode.png b/docs/developer-guides/assets/bruno_guide/js_sandbox_mode.png new file mode 100644 index 0000000..1657ae2 Binary files /dev/null and b/docs/developer-guides/assets/bruno_guide/js_sandbox_mode.png differ diff --git a/scripts/config/vale/styles/config/vocabularies/words/accept.txt b/scripts/config/vale/styles/config/vocabularies/words/accept.txt index 8472c0b..e761c42 100644 --- a/scripts/config/vale/styles/config/vocabularies/words/accept.txt +++ b/scripts/config/vale/styles/config/vocabularies/words/accept.txt @@ -36,3 +36,4 @@ Trufflehog VMs [Vv]scode sublicense +wsl