Skip to main content

POST /cid/refresh-local

Loads CID (International Classification of Diseases) codes from a locally saved HTML file and updates the database.

Query Parameters

path
string
required
Absolute file system path to the HTML file containing CID codes (e.g., /path/to/cid-data.html)

Response

message
string
Success message with the total number of CID codes processed from the local file

Example Request

cURL
curl -X POST "http://localhost:8080/cid/refresh-local?path=/app/data/cid-codes.html"
JavaScript
const filePath = '/app/data/cid-codes.html';
const response = await fetch(`http://localhost:8080/cid/refresh-local?path=${encodeURIComponent(filePath)}`, {
  method: 'POST'
});
const result = await response.json();
console.log(result);

Example Response

200 OK
"CIDs atualizados a partir do arquivo local. Total processado: 15234"

Implementation Details

From CidController.java:42-46:
@PostMapping("/refresh-local")
public ResponseEntity<String> refreshLocal(@RequestParam("path") String path) {
    int count = cidService.refreshFromLocal(Path.of(path));
    return ResponseEntity.ok("CIDs atualizados a partir do arquivo local. Total processado: " + count);
}
This endpoint:
  1. Reads the HTML file from the specified path
  2. Parses the CID code data structure
  3. Updates or inserts codes into the database
  4. Returns the total count of processed codes
Security Considerations:
  • This endpoint requires access to the server’s file system
  • Ensure the path is within an allowed directory to prevent path traversal attacks
  • Validate file permissions before deployment
  • Consider restricting this endpoint to admin users only

Use Cases

  • Offline database initialization when internet access is limited
  • Testing with custom CID datasets
  • Importing CID codes from previously downloaded DATASUS files
  • Development environments without external network access

Error Responses

Status CodeDescription
200CID codes successfully loaded from local file
400Invalid path or path parameter missing
404File not found at specified path
500Error reading or parsing the file
For downloading CID codes directly from DATASUS servers, use POST /cid/refresh instead.
The HTML file format must match the expected DATASUS structure for proper parsing.

Build docs developers (and LLMs) love