diff --git a/features/addSinglePatient.feature b/features/addSinglePatient.feature
index b4fadcb4..a3debad0 100644
--- a/features/addSinglePatient.feature
+++ b/features/addSinglePatient.feature
@@ -20,7 +20,7 @@ Scenario: Add a new single Patient
},
{
"system": "http://health.go.ug/cr/nationalid",
- "value": "228374855"
+ "value": "228374844"
},
{
"system": "http://system1.org",
diff --git a/features/breakMatch.feature b/features/breakMatch.feature
index 9fa7913f..b7096041 100644
--- a/features/breakMatch.feature
+++ b/features/breakMatch.feature
@@ -4,7 +4,7 @@ Feature: Breaking Match
Scenario: Breaking a match
Given Patient IDs
"""
- ["Patient/6f017270-a089-4b23-a667-3f8508412ca0"]
+ ["Patient/ba3d2c47-f0ec-4f62-8677-c45786e37b90"]
"""
When The POS sends Patient IDS
Then The server responds with status code 200
diff --git a/features/getPatient.feature b/features/getPatient.feature
index d518689a..ac1a1e75 100644
--- a/features/getPatient.feature
+++ b/features/getPatient.feature
@@ -2,68 +2,10 @@ Feature: Retrieve Patient
Scenario: Get an existing patient
- Given Patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e exists on the server
+ Given Patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f exists on the server
"""
- {
- "resourceType": "Patient",
- "id": "76e82de7-26d5-4aa8-9e1c-b549a4184b7e",
- "meta": {
- "versionId": "2",
- "lastUpdated": "2020-10-20T19:29:50.653+03:00",
- "source": "#im8dM78mO3fZdeGp",
- "tag": [
- {
- "system": "http://openclientregistry.org/fhir/clientid",
- "code": "openmrs",
- "display": "OpenMRS"
- }
- ]
- },
- "text": {
- "status": "generated",
- "div": "
Identifier | rec-2009-org |
Date of birth | 28 October 1976 |
"
- },
- "identifier": [
- {
- "system": "http://clientregistry.org/openmrs",
- "value": "rec-2009-org"
- },
- {
- "system": "http://clientregistry.org/nationalid",
- "value": "CF68167355NUZY"
- },
- {
- "system": "http://clientregistry.org/artnumber",
- "value": "KUB-176148"
- }
- ],
- "name": [
- {
- "use": "official",
- "family": "lusike",
- "given": [
- "zuwena"
- ]
- }
- ],
- "telecom": [
- {
- "system": "phone",
- "value": "772 614594"
- }
- ],
- "gender": "female",
- "birthDate": "1976-10-28",
- "link": [
- {
- "other": {
- "reference": "Patient/73d17735-4835-474b-bebb-4f1d23c5e6d5"
- },
- "type": "refer"
- }
- ]
- }
+ d55e15fd-d7a6-42b8-89cc-560e3578ef7f
"""
- When A system requests patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e
- Then Patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e is returned
+ When A system requests patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f
+ Then Patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f is returned
diff --git a/features/getPatientPotentialMatches.feature b/features/getPatientPotentialMatches.feature
index 7e7eb726..c97fe8de 100644
--- a/features/getPatientPotentialMatches.feature
+++ b/features/getPatientPotentialMatches.feature
@@ -4,7 +4,7 @@ Feature: Get Patient Potential Matches
Scenario: Get patient match
Given Patient ID
"""
- 433ebeb6-1d89-4b64-97e6-a985675ca571
+ 04cdafc2-cc7b-435e-bd5b-0ee12a2367b7
"""
When The POS sends patient ID
Then Potential matches are returned
diff --git a/features/unBreakMatch.feature b/features/unBreakMatch.feature
index c972281a..cd6cdae3 100644
--- a/features/unBreakMatch.feature
+++ b/features/unBreakMatch.feature
@@ -5,11 +5,8 @@ Scenario: UnBreaking a match
Given Patient IDs
"""
[{
- "id2": "Patient/6f017270-a089-4b23-a667-3f8508412ca0",
- "id1": "Patient/bc58707b-62f1-498a-8fb3-568cd5b69db2"
- }, {
- "id2": "Patient/6f017270-a089-4b23-a667-3f8508412ca0",
- "id1": "Patient/d55e15fd-d7a6-42b8-89cc-560e3578ef7f"
+ "id2": "Patient/c14361b1-481f-4cdb-87c7-018e0e107a55",
+ "id1": "Patient/cfa54360-ab37-4ded-8309-4c136ca40e33"
}]
"""
When The POS sends Patient IDS
diff --git a/server/__tests__/e2e/fhirresources/patientsBundle.json b/server/__tests__/e2e/fhirresources/patientsBundle.json
index 1997d323..dffcf0f5 100644
--- a/server/__tests__/e2e/fhirresources/patientsBundle.json
+++ b/server/__tests__/e2e/fhirresources/patientsBundle.json
@@ -14,7 +14,22 @@
},
"request": {
"method": "PUT",
- "url": "Patient/9dd75a6a-2408-43d0-a577-d38292f4a73f"
+ "url": "Patient/fe697ff3-62c5-4aa3-8747-ccb15a2ee9c3"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ }
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4"
}
}, {
"resource": {
@@ -159,6 +174,116 @@
"method": "PUT",
"url": "Patient/fe697ff3-62c5-4aa3-8747-ccb15a2ee9c3"
}
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "ba3d2c47-f0ec-4f62-8677-c45786e37b90",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient6"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374866"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12346",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Omari",
+ "given": [
+ "Suleyman"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 763295"
+ }],
+ "gender": "male",
+ "birthDate": "1972-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/ba3d2c47-f0ec-4f62-8677-c45786e37b90"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "8c829026-58a0-4dd9-a2a1-49e40a49a9ef",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient7"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374866"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12346",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Omar",
+ "given": [
+ "Suleyman"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 765995"
+ }],
+ "gender": "male",
+ "birthDate": "1972-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/8c829026-58a0-4dd9-a2a1-49e40a49a9ef"
+ }
}, {
"resource": {
"resourceType": "Patient",
@@ -180,5 +305,411 @@
"method": "PUT",
"url": "Patient/9dd75a6a-2408-43d0-a577-d38292f4a73f"
}
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ },
+ "link": [{
+ "other": {
+ "reference": "Patient/ba3d2c47-f0ec-4f62-8677-c45786e37b90"
+ },
+ "type": "seealso"
+ }, {
+ "other": {
+ "reference": "Patient/8c829026-58a0-4dd9-a2a1-49e40a49a9ef"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/d3173ed3-2f19-4d22-b1a7-f3ed0a987fe4"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "c5f4b57a-cc8f-41b2-ba62-5ff1c3f5b966",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ }
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/c5f4b57a-cc8f-41b2-ba62-5ff1c3f5b966"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "9ad3c074-0b21-4c9a-904e-f43eae54dd37",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ }
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/9ad3c074-0b21-4c9a-904e-f43eae54dd37"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "c14361b1-481f-4cdb-87c7-018e0e107a55",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "extension": [
+ {
+ "url": "http://clientregistry.org/brokenMatch",
+ "valueReference": {
+ "reference": "Patient/cfa54360-ab37-4ded-8309-4c136ca40e33"
+ }
+ }
+ ],
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient8"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374888"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12388",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Kisanga",
+ "given": [
+ "Kija"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 588608"
+ }],
+ "gender": "male",
+ "birthDate": "1972-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/c5f4b57a-cc8f-41b2-ba62-5ff1c3f5b966"
+ },
+ "type": "refer"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/c14361b1-481f-4cdb-87c7-018e0e107a55"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "cfa54360-ab37-4ded-8309-4c136ca40e33",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "extension": [
+ {
+ "url": "http://clientregistry.org/brokenMatch",
+ "valueReference": {
+ "reference": "Patient/c14361b1-481f-4cdb-87c7-018e0e107a55"
+ }
+ }
+ ],
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient9"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374888"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12388",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Kisaanga",
+ "given": [
+ "Kija"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 588608"
+ }],
+ "gender": "male",
+ "birthDate": "1972-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/9ad3c074-0b21-4c9a-904e-f43eae54dd37"
+ },
+ "type": "refer"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/cfa54360-ab37-4ded-8309-4c136ca40e33"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "c5f4b57a-cc8f-41b2-ba62-5ff1c3f5b966",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ },
+ "link": [{
+ "other": {
+ "reference": "Patient/c14361b1-481f-4cdb-87c7-018e0e107a55"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/c5f4b57a-cc8f-41b2-ba62-5ff1c3f5b966"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "9ad3c074-0b21-4c9a-904e-f43eae54dd37",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ },
+ "link": [{
+ "other": {
+ "reference": "Patient/cfa54360-ab37-4ded-8309-4c136ca40e33"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/9ad3c074-0b21-4c9a-904e-f43eae54dd37"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "74bf4455-20e3-4acc-9fe1-888898ceb815",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ }
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/74bf4455-20e3-4acc-9fe1-888898ceb815"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "0db56938-46b5-4d8f-83e5-d3d4b96248db",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ }
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/0db56938-46b5-4d8f-83e5-d3d4b96248db"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "04cdafc2-cc7b-435e-bd5b-0ee12a2367b7",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient10"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374810"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12310",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Masunga",
+ "given": [
+ "Mahengenya"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 111177"
+ }],
+ "gender": "male",
+ "birthDate": "1980-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/74bf4455-20e3-4acc-9fe1-888898ceb815"
+ },
+ "type": "refer"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/04cdafc2-cc7b-435e-bd5b-0ee12a2367b7"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "c5c94f59-3c8c-4636-b747-235fbe55f80a",
+ "meta": {
+ "tag": [{
+ "system": "http://openclientregistry.org/fhir/clientid",
+ "code": "openmrs",
+ "display": "OpenMRS"
+ }]
+ },
+ "identifier": [{
+ "system": "http://clientregistry.org/openmrs",
+ "value": "patient11"
+ },
+ {
+ "system": "http://health.go.ug/cr/nationalid",
+ "value": "228374810"
+ },
+ {
+ "system": "http://system1.org",
+ "value": "12310",
+ "period": {
+ "start": "2001-05-07"
+ },
+ "assigner": {
+ "display": "test Org"
+ }
+ }
+ ],
+ "active": true,
+ "name": [{
+ "use": "official",
+ "family": "Masunga",
+ "given": [
+ "Mahengenya"
+ ]
+ }],
+ "telecom": [{
+ "system": "phone",
+ "value": "0678 11177"
+ }],
+ "gender": "male",
+ "birthDate": "1980-01-08",
+ "link": [{
+ "other": {
+ "reference": "Patient/0db56938-46b5-4d8f-83e5-d3d4b96248db"
+ },
+ "type": "refer"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/c5c94f59-3c8c-4636-b747-235fbe55f80a"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "74bf4455-20e3-4acc-9fe1-888898ceb815",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ },
+ "link": [{
+ "other": {
+ "reference": "Patient/04cdafc2-cc7b-435e-bd5b-0ee12a2367b7"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/74bf4455-20e3-4acc-9fe1-888898ceb815"
+ }
+ }, {
+ "resource": {
+ "resourceType": "Patient",
+ "id": "0db56938-46b5-4d8f-83e5-d3d4b96248db",
+ "meta": {
+ "tag": [{
+ "code": "5c827da5-4858-4f3d-a50c-62ece001efea",
+ "display": "Golden Record"
+ }]
+ },
+ "link": [{
+ "other": {
+ "reference": "Patient/c5c94f59-3c8c-4636-b747-235fbe55f80a"
+ },
+ "type": "seealso"
+ }]
+ },
+ "request": {
+ "method": "PUT",
+ "url": "Patient/0db56938-46b5-4d8f-83e5-d3d4b96248db"
+ }
}]
}
\ No newline at end of file
diff --git a/server/__tests__/e2e/get-patient-potential-matches.steps.js b/server/__tests__/e2e/get-patient-potential-matches.steps.js
index 7f34372d..133dd8aa 100644
--- a/server/__tests__/e2e/get-patient-potential-matches.steps.js
+++ b/server/__tests__/e2e/get-patient-potential-matches.steps.js
@@ -19,68 +19,32 @@ const options = {
};
let response;
let potentialMatches = [{
- "id": "433ebeb6-1d89-4b64-97e6-a985675ca571",
+ "id": "04cdafc2-cc7b-435e-bd5b-0ee12a2367b7",
"gender": "male",
- "given": "Emanuel",
- "family": "Joshua",
- "birthDate": "1972-01-08",
- "phone": "0678 56160",
- "uid": "fe697ff3-62c5-4aa3-8747-ccb15a2ee9c3",
- "ouid": "fe697ff3-62c5-4aa3-8747-ccb15a2ee9c3",
- "source_id": "patient5",
+ "given": "Mahengenya",
+ "family": "Masunga",
+ "birthDate": "1980-01-08",
+ "phone": "0678 111177",
+ "uid": "74bf4455-20e3-4acc-9fe1-888898ceb815",
+ "ouid": "74bf4455-20e3-4acc-9fe1-888898ceb815",
+ "source_id": "patient10",
"source": "OpenMRS",
"scores": {
- "patient2": 2,
- "patient4": 2,
- "patient1": 2
+ "patient11": 2
}
}, {
- "id": "d55e15fd-d7a6-42b8-89cc-560e3578ef7f",
+ "id": "c5c94f59-3c8c-4636-b747-235fbe55f80a",
"gender": "male",
- "given": "Emanuel",
- "family": "Joshua",
- "birthDate": "1972-01-08",
- "phone": "0678 561608",
- "uid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "ouid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "source_id": "patient2",
+ "given": "Mahengenya",
+ "family": "Masunga",
+ "birthDate": "1980-01-08",
+ "phone": "0678 11177",
+ "uid": "0db56938-46b5-4d8f-83e5-d3d4b96248db",
+ "ouid": "0db56938-46b5-4d8f-83e5-d3d4b96248db",
+ "source_id": "patient11",
"source": "OpenMRS",
"scores": {
- "patient4": 3,
- "patient1": 3,
- "patient5": 2
- }
-}, {
- "id": "6f017270-a089-4b23-a667-3f8508412ca0",
- "gender": "male",
- "given": "Emanueel",
- "family": "Joshua",
- "birthDate": "1972-01-08",
- "phone": "0678 561608",
- "uid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "ouid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "source_id": "patient4",
- "source": "OpenMRS",
- "scores": {
- "patient2": 3,
- "patient1": 3,
- "patient5": 2
- }
-}, {
- "id": "3fe45cb4-1a1b-4e3b-a064-0a83df6164f2",
- "gender": "male",
- "given": "Emmanuel",
- "family": "Joshua",
- "birthDate": "1972-01-08",
- "phone": "0678 561608",
- "uid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "ouid": "9dd75a6a-2408-43d0-a577-d38292f4a73f",
- "source_id": "patient1",
- "source": "OpenMRS",
- "scores": {
- "patient2": 3,
- "patient4": 3,
- "patient5": 2
+ "patient10": 2
}
}];
defineFeature( feature, test => {
diff --git a/server/__tests__/e2e/get-patient.steps.js b/server/__tests__/e2e/get-patient.steps.js
index b23da714..d9bfd8c4 100644
--- a/server/__tests__/e2e/get-patient.steps.js
+++ b/server/__tests__/e2e/get-patient.steps.js
@@ -21,20 +21,20 @@ const feature = loadFeature("../features/getPatient.feature");
defineFeature( feature, test => {
test("Get an existing patient", ({ given, when, then }) => {
- let patient;
+ let patientID;
let response;
- given("Patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e exists on the server", existingPatient => {
- patient = JSON.parse(existingPatient);
+ given("Patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f exists on the server", id => {
+ patientID = id;
} );
- when("A system requests patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e", async() => {
- let url = URI(baseURL).segment('Patient').segment('76e82de7-26d5-4aa8-9e1c-b549a4184b7e').toString();
+ when("A system requests patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f", async() => {
+ let url = URI(baseURL).segment('Patient').segment('d55e15fd-d7a6-42b8-89cc-560e3578ef7f').toString();
options.method = 'GET';
options.url = url;
let resp = await axios(options);
response = resp;
} );
- then("Patient 76e82de7-26d5-4aa8-9e1c-b549a4184b7e is returned", () => {
- expect(response.data).toEqual(patient);
+ then("Patient d55e15fd-d7a6-42b8-89cc-560e3578ef7f is returned", () => {
+ expect(response.data.id).toEqual(patientID);
} );
} );
} );
diff --git a/server/__tests__/e2e/resetTestData.js b/server/__tests__/e2e/resetTestData.js
new file mode 100644
index 00000000..dc402da8
--- /dev/null
+++ b/server/__tests__/e2e/resetTestData.js
@@ -0,0 +1,31 @@
+const axios = require("axios");
+const URI = require('urijs');
+const config = require('../../lib/config');
+const logger = require('../../lib/winston');
+const patientsBundle = require('./fhirresources/patientsBundle.json');
+
+logger.info("Adding default patients data used for running tests");
+const options = {
+ url: URI(config.get('fhirServer:baseURL')).toString(),
+ method: "POST",
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ withCredentials: true,
+ auth: {
+ username: config.get('fhirServer:username'),
+ password: config.get('fhirServer:password'),
+ },
+ data: patientsBundle,
+};
+
+axios(options).then((resp) => {
+ if (resp.status < 200 || resp.status > 299) {
+ logger.error(JSON.stringify(resp, 0, 2));
+ } else {
+ logger.info('Default patients data added successfully');
+ }
+}).catch((err) => {
+ logger.error(err);
+ logger.error('Default patients data were not added, some tests may fail');
+});
\ No newline at end of file
diff --git a/server/jest.config.js b/server/jest.config.js
index 81fbc700..3e6bd0c9 100644
--- a/server/jest.config.js
+++ b/server/jest.config.js
@@ -148,7 +148,9 @@ module.exports = {
// "/node_modules/"
// ],
testPathIgnorePatterns: [
- "resources/"
+ "resources/",
+ "__tests__/e2e/add-invalid-patient.js",
+ "__tests__/e2e/resetTestData.js"
],
// The regexp pattern or array of patterns that Jest uses to detect test files
diff --git a/server/package.json b/server/package.json
index b0b0192a..1694a7b6 100644
--- a/server/package.json
+++ b/server/package.json
@@ -7,7 +7,7 @@
"start": "env NODE_ENV=production node lib/app.js",
"dev": "env NODE_ENV=development node lib/app.js",
"test": "env NODE_ENV=test jest --testPathIgnorePatterns=__tests__/e2e",
- "e2e": "env NODE_ENV=test jest --testPathPattern=__tests__/e2e"
+ "e2e": "env NODE_ENV=test node __tests__/e2e/resetTestData.js && jest --detectOpenHandles --testPathPattern=__tests__/e2e"
},
"keywords": [
"client registry",