npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@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)