Skip to content

An API that will take control over the healthcare institution registration as well as the exams ingest.

License

Notifications You must be signed in to change notification settings

Sorackb/HealthcareInstitution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HealthcareInstitution

Build Status Sonarcloud Status SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities Dependabot

An API that will take control over the healthcare institution registration as well as the exams ingest.

Requirements

  • Java SE Development Kit 8 or higher;
  • Maven 2.0.9 or higher;
  • MySQL 5.0 or higher (The configuration of the connection can be done by editing the \main\resources\application.properties file or with the DATASOURCE_HOST, DATASOURCE_SCHEMA, DATASOURCE_USERNAME and DATASOURCE_PASSWORD environment variables).

Running

mvn spring-boot:run

API documentation

The API description and try-out methods can be viewed in the following URL:

/swagger-ui.html

healthcareinstitutions

An API that will take control over the healthcare institution registration.

Create a Healthcare Institution

Creates a single Healthcare Institution. The token returned needs to be used as Beared Authentication Header for exams API.

  • URL

    /healthcareinstitutions/

  • Method:

    POST

  • Data Params

    Required:

    Name=[alphanumeric]
    CNPJ=[alphanumeric]

  • Success Response:

    • Code: 200
      Content: { "Name": "lucasbernardo.org", "CNPJ": "16191374000171", "token": "XXXXXX.XXXXXXXXXXXXX" }
  • Error Response:

    • Code: 500 INTERNAL SERVER ERROR
      Content: { "cnpj": "Duplicate entry '16191374000171' for key 'CNPJ'" }

    OR

    • Code: 400 BAD REQUEST
      Content: { "cnpj": "CNPJ is mandatory." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "cnpj": "Invalid CNPJ." }
  • Sample Call:

    $.ajax({
      url: '/exams/',
      method: 'POST',
      timeout: 0,
      dataType: 'json',
      data: JSON.stringify({ Name: 'lucasbernardo.org', CNPJ: '16.191.374/0001-71' })
    }).done(function (response) {
      console.log(response);
    });

exams

An API that will take control over the exam ingest. The Beared Authentication Header is required and can be obtain creating a healthcare institution.


Create a Exam

Creates a single Exam. This resource charges 1 pixeon.

  • URL

    /exams/

  • Method:

    POST

  • Data Params

    Required:

    PatientName=[alphanumeric]
    PatientAge=[integer]
    PatientAge=[enum(M or F)]
    PhysicianName=[alphanumeric]
    PhysicianCRM=[alphanumeric]
    ProcedureName=[alphanumeric]

  • Success Response:

    • Code: 200
      Content:
    {
      "id": 6,
      "healthcareInstitution": {
        "Name": "lucasbernardo.org",
        "CNPJ": "16191374000171"
      },
      "PatientName": "John Doe",
      "PatientAge": 55,
      "PatientGender": "M",
      "PhysicianName": "Taylor Joe",
      "PhysicianCRM": "45465223",
      "ProcedureName": "MRI"
    }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { "error": "token \"XXXXXX.XXXXXXXXXXXXX\" not found." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { "error": "The resource is secured and no token was informed." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientName": "PatientName is mandatory." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientGender": "PatientGender must be \"M\" or \"F\"." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientAge": "PatientAge should be a positive integer." }

    OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: { "HealthcareInstitution": "Out of budget." }
  • Sample Call:

    $.ajax({
      url: '/exams/',
      method: 'POST',
      timeout: 0,
      dataType: 'json',
      "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer XXXXXX.XXXXXXXXXXXXX"
      },
      data: JSON.stringify({
        PatientName: 'John Doe',
        PatientAge: 55,
        PatientGender: 'M',
        PhysicianName: 'Taylor Joe',
        PhysicianCRM: '45465223',
        ProcedureName: 'MRI'
      })
    }).done(function (response) {
      console.log(response);
    });

Update an exam

Update data of an existent Exam.

  • URL

    /exams/:id/

  • Method:

    PUT

  • URL Params

    Required:

    id=[integer]

  • Data Params

    Required:

    PatientName=[alphanumeric]
    PatientAge=[integer]
    PatientAge=[enum(M or F)]
    PhysicianName=[alphanumeric]
    PhysicianCRM=[alphanumeric]
    ProcedureName=[alphanumeric]

  • Success Response:

    • Code: 200
      Content:
    {
      "id": 6,
      "healthcareInstitution": {
        "id": 1,
        "Name": "lucasbernardo.org",
        "CNPJ": "16191374000171"
      },
      "PatientName": "John Doe",
      "PatientAge": 55,
      "PatientGender": "M",
      "PhysicianName": "Taylor Joe",
      "PhysicianCRM": "45465223",
      "ProcedureName": "MRI"
    }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { "error": "token \"XXXXXX.XXXXXXXXXXXXX\" not found." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { "error": "The resource is secured and no token was informed." }

    OR

    • Code: 404 NOT FOUND
      Content: { "Exam": "id \"2\" not found." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientName": "PatientName is mandatory." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientGender": "PatientGender must be \"M\" or \"F\"." }

    OR

    • Code: 400 BAD REQUEST
      Content: { "patientAge": "PatientAge should be a positive integer." }
  • Sample Call:

    $.ajax({
      url: '/exams/6',
      method: 'PUT',
      timeout: 0,
      dataType: 'json',
      "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer XXXXXX.XXXXXXXXXXXXX"
      },
      data: JSON.stringify({
        PatientName: 'John Doe',
        PatientAge: 55,
        PatientGender: 'M',
        PhysicianName: 'Taylor Joe',
        PhysicianCRM: '45465223',
        ProcedureName: 'MRI'
      })
    }).done(function (response) {
      console.log(response);
    });

Delete an exam

Delete an existent Exam.

  • URL

    /exams/:id/

  • Method:

    DELETE

  • URL Params

    Required:

    id=[integer]

  • Success Response:

    • Code: 200
      Content: { "deleted": true }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { "error": "token \"XXXXXX.XXXXXXXXXXXXX\" not found." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { "error": "The resource is secured and no token was informed." }

    OR

    • Code: 404 NOT FOUND
      Content: { "Exam": "id \"2\" not found." }
  • Sample Call:

    $.ajax({
      url: '/exams/6',
      method: 'DELETE',
      timeout: 0,
      "headers": {
        "Authorization": "Bearer XXXXXX.XXXXXXXXXXXXX"
      }
    }).done(function (response) {
      console.log(response);
    });

Retrieve an exam

Retrieve a previously created Exam. Charges 1 pixeon in the first call of every exam.

  • URL

    /exams/:id/

  • Method:

    GET

  • URL Params

    Required:

    id=[integer]

  • Success Response:

    • Code: 200
      Content:
    {
      "id": 6,
      "healthcareInstitution": {
        "id": 1,
        "Name": "lucasbernardo.org",
        "CNPJ": "16191374000171"
      },
      "PatientName": "John Doe",
      "PatientAge": 55,
      "PatientGender": "M",
      "PhysicianName": "Taylor Joe",
      "PhysicianCRM": "45465223",
      "ProcedureName": "MRI"
    }
  • Error Response:

    • Code: 401 UNAUTHORIZED
      Content: { "error": "token \"XXXXXX.XXXXXXXXXXXXX\" not found." }

    OR

    • Code: 401 UNAUTHORIZED
      Content: { "error": "The resource is secured and no token was informed." }

    OR

    • Code: 404 NOT FOUND
      Content: { "Exam": "id \"2\" not found." }

    OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: { "HealthcareInstitution": "Out of budget." }
  • Sample Call:

    $.ajax({
      url: '/exams/6',
      method: 'GET',
      "headers": {
        "Authorization": "Bearer XXXXXX.XXXXXXXXXXXXX"
      },
      timeout: 0
    }).done(function (response) {
      console.log(response);
    });

About

An API that will take control over the healthcare institution registration as well as the exams ingest.

Resources

License

Stars

Watchers

Forks

Packages

No packages published