@kenetto/user-service
v1.1.1
Published
User Service
Downloads
4
Readme
UserService
Contains the NodeJS service
Running the app
Start by running npm start
From now on the app is running at <protocol>
://<hostname>
:<port>
/
Patient's identification
The patient's health number is used for their identification throughout the service. The service supports health numbers used by different countries (e.g. SNS number for Portugal).
Information to take into account
The route <protocol>
://<hostname>
:<port>
/users/<id>
(where <id>
is the patient's public ID) accepts the following requests methods/verbs: GET, PUT and DELETE. Unless it's a PUT request, for any request made with an ID that doesn't belong to any known user the route responds with the status code 404. If the route receives a request method other than any of these it responds with the status code 405 Method Not Allowed and sets the Allow response header field with the supported methods.
Available Operations for /users/<id>
route
GET
Depending if the GET request is sent with the full parameter, the response will return correspondently:
- All the patient's information: personal information, documents, contacts, addresses and filiation. The response's body will have the following form:
[
{
"userID": <patient_id>,
"title": "<patient_title>",
"birthDate": "<patient_birth_date>",
"givenNames": "<patient_given_names>",
"familyNames": "<patient_family_names>",
"maritalStatus": "<patient_marital_status>",
"gender": "<patient_gender>",
"nationality": "<patient_nationality>",
"prescriptionCountry": "<patient_prescriptionCountry>",
"dead": <patient_dead_status>,
"documents": [
{
"type": "<document_type>",
"value": <document_value>,
"expirationDate": "<document_expiration_date>"
},
...
],
"links": {
"contacts": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/contacts",
"addresses": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/addresses",
"filiation": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/filiation"
}
},
{
"<contact_type>": [
{
"value": "<contact_value>",
"contactID": "<contact_ID>"
},
...
]
},
{
"addresses": [
{
"use": "<address_use>",
"type": "<address_type>",
"street": "<address_street>",
"doorNumber": <address_door_number>,
"postalCode": "<address_postal_code>",
"city": "<address_city>",
"country": "<address_country>"
"addressID": <address_ID>
},
...
]
},
{
"filiation": [
{
"relation": "<filiation_relation>",
"name": "<filiation_name>",
"filiatedID": <filiatedID>
},
...
]
}
]
- The patient's personal information, including their non-identifying information and documents.
For the patient's contacts, addresses and filiation the response's body will include a URI for each one which can later be used to make a request:
<protocol>
://<hostname>
:<port>
/users/<id>
/{contacts, addresses, filiation}. The response body will return the following information:
{
"userID": <patient_id>,
"title": "<patient_title>",
"birthDate": "<patient_birth_date>",
"givenNames": "<patient_given_names>",
"familyNames": "<patient_family_names>",
"maritalStatus": "<patient_marital_status>",
"gender": "<patient_gender>",
"nationality": "<patient_nationality>",
"prescriptionCountry": "<patient_prescriptionCountry>",
"dead": <patient_dead_status>,
"documents": [
{
"type": "<document_type>",
"value": <document_value>,
"expirationDate": "<document_expiration_date>"
},
...
],
"links": {
"contacts": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/contacts",
"addresses": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/addresses",
"filiation": "`<protocol>`://`<hostname>`:`<port>`/users/`<id>`/filiation"
}
}
PUT
When making a PUT request to the above route the request body type (Content-Type) must be sent as application/json. The request body must use the following syntax:
{
"title": "<patient_title>",
"birthDate": "<patient_birth_date>",
"givenNames": "<patient_given_names>",
"familyNames": "<patient_family_names>",
"maritalStatus": "<patient_marital_status>",
"gender": "<patient_gender>",
"nationality": "<patient_nationality>",
"prescriptionCountry": "<patient_prescriptionCountry>",
"dead": <patient_dead_status>,
"documents": [
{
"type": "<document_type>",
"value": <document_value>,
"expirationDate": "<document_expiration_date>"
},
...
],
"filiation": [
{
"relation": "<filiation_relation>",
"name": "<filiation_name>",
"filiatedID": <filiatedID>
},
...
],
"contact": {
"type": "<contact_type>",
"value": "<contact_value>"
},
"address": {
"use": "<address_use>",
"type": "<address_type>",
"street": "<address_street>",
"doorNumber": <address_door_number>,
"postalCode": "<address_postal_code>",
"city": "<address_city>",
"country": "<address_country>"
}
}
Note: the service follows the ISO 3166-1 alpha-3 standard for representing countries codes. That means the patient's nationality (<patient_nationality>
), an address country field (<address_country>
) and the country where the patient is registered to receive prescriptions (<prescriptionCountry>
) expect a value following this standard.
If the request type isn't correct the appropriate status code is set. Depending if an user with the provided ID already exists the received patient's information is either created/persisted in the database or the route returns an error. In both scenarios the appropriate status code is set in the response.
DELETE
For a DELETE request the route attempts to delete the file holding the received user's ID information (without regarding the separation between personal and medical data).
Available Operations for /users/<id>
/contacts route
GET
Making a GET request to this route will return all the patient's contacts in the following form:
{
"userID": <id>,
"<contact_type>": [
"<contact_value>",
...
],
...
}
POST
One can make a POST request to this route in order to add a new contact to the patient's contacts list. To do so the request body has to have the following form:
[
{
"type": "<contact_type>",
"value": "<contact_value>"
},
...
]
DELETE
(in development)
Available Operations for /users/<id>
/addresses route
GET
A GET request to this route will return addresses that are known to belong to the patient. The returned data will have the following form:
{
"userID": <id>,
"addresses": [
{
"use": "<address_use>",
"type": "<address_type>",
"street": "<address_street>",
"doorNumber": <address_doorNumber>,
"city": "<address_city>",
"postalCode": "<address_postalCode>",
"country": "<address_country>",
"addressID": <addressID>
},
...
]
}
POST
To add a new address to a patient's addresses list, one has to send a POST request with the following body
[
{
"use": "<address_use>",
"type": "<address_type>",
"street": "<address_street>",
"doorNumber": <address_doorNumber>,
"city": "<address_city>",
"postalCode": "<address_postalCode>",
"country": "<address_country>"
},
...
]
DELETE
When making a request to the /users/<id>
/addresses/<addressID>
route it will delete the addres with the specified <addressID>
from the patient's addresses list.
The deleted address information is then returned.
Available Operations for /users/<id>
/filiation route
GET
When receiving a GET request this route will return all patient's filiaiton in the following syntax:
{
"userID": <id>,
"filiation": [
{
"relation": "<filiation_relation>",
"name": "<filiation_name>",
"filiatedID": <filiation_filiatedID>
},
...
]
}
POST
[
{
"relation": "<filiation_relation>",
"name": "<filiation_name>",
"filiatedID": <filiation_filiatedID>
},
...
]
DELETE
(in development)