Perbaikan Patient CRUD
Some checks failed
Go-test / build (push) Has been cancelled

This commit is contained in:
2025-12-01 11:52:30 +07:00
parent f10689c606
commit 5515e76320
6 changed files with 1661 additions and 101 deletions

View File

@@ -387,6 +387,43 @@ const docTemplate = `{
}
}
},
"/api/v1/patients/stats": {
"get": {
"description": "Returns comprehensive statistics about patient data",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Get patient statistics",
"parameters": [
{
"type": "string",
"description": "Filter statistics by status",
"name": "status",
"in": "query"
}
],
"responses": {
"200": {
"description": "Statistics data",
"schema": {
"$ref": "#/definitions/api-service_internal_models.AggregateData"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
}
},
"/api/v1/retribusi/{id}": {
"get": {
"description": "Returns a single retribusi by ID",
@@ -1094,6 +1131,281 @@ const docTemplate = `{
}
}
}
},
"/patient": {
"post": {
"description": "Creates a new patient record",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Create patient",
"parameters": [
{
"description": "Patient creation request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientCreateRequest"
}
}
],
"responses": {
"201": {
"description": "Patient created successfully",
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientCreateResponse"
}
},
"400": {
"description": "Bad request or validation error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
}
},
"/patient/detail": {
"post": {
"description": "Retrieves a patient record by ID using POST request",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Get patient by ID using POST request",
"parameters": [
{
"description": "Patient post request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientPostRequest"
}
}
],
"responses": {
"200": {
"description": "Patient details retrieved successfully",
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientCreateResponse"
}
},
"400": {
"description": "Bad request or validation error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"404": {
"description": "Patient not found",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
}
},
"/patient/listpatient": {
"get": {
"description": "Returns a paginated list of patients with optional summary statistics",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Get patient with pagination and optional aggregation",
"parameters": [
{
"type": "integer",
"default": 10,
"description": "Limit (max 100)",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"default": 0,
"description": "Offset",
"name": "offset",
"in": "query"
},
{
"type": "boolean",
"default": false,
"description": "Include aggregation summary",
"name": "include_summary",
"in": "query"
},
{
"type": "string",
"description": "Filter by status",
"name": "status",
"in": "query"
},
{
"type": "string",
"description": "Search in multiple fields",
"name": "search",
"in": "query"
}
],
"responses": {
"200": {
"description": "Success response",
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientGetResponse"
}
},
"400": {
"description": "Bad request",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
}
},
"/patient/{id}": {
"put": {
"description": "Updates an existing patient record",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Update patient",
"parameters": [
{
"type": "integer",
"description": "Patient ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Patient update request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientUpdateRequest"
}
}
],
"responses": {
"200": {
"description": "Patient updated successfully",
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientUpdateResponse"
}
},
"400": {
"description": "Bad request or validation error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"404": {
"description": "Patient not found",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
},
"delete": {
"description": "Soft deletes a patient by setting status to 'deleted'",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Patient"
],
"summary": "Delete patient",
"parameters": [
{
"type": "integer",
"description": "Patient ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Patient deleted successfully",
"schema": {
"$ref": "#/definitions/api-service_internal_models_patient.PatientDeleteResponse"
}
},
"400": {
"description": "Invalid ID format",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"404": {
"description": "Patient not found",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
},
"500": {
"description": "Internal server error",
"schema": {
"$ref": "#/definitions/api-service_internal_models.ErrorResponse"
}
}
}
}
}
},
"definitions": {
@@ -1295,16 +1607,10 @@ const docTemplate = `{
"type": "object",
"properties": {
"active": {
"type": "boolean",
"enum": [
true,
false
]
"type": "boolean"
},
"ds_sd_location": {
"type": "string",
"maxLength": 255,
"minLength": 1
"type": "string"
},
"fk_ref_healthcare_type_id": {
"type": "integer",
@@ -1315,8 +1621,7 @@ const docTemplate = `{
"minimum": 1
},
"fk_sd_location_id": {
"type": "string",
"minLength": 1
"type": "string"
},
"icon": {
"type": "string",
@@ -1384,16 +1689,11 @@ const docTemplate = `{
],
"properties": {
"active": {
"type": "boolean",
"enum": [
true,
false
]
"type": "boolean"
},
"ds_sd_location": {
"type": "string",
"maxLength": 255,
"minLength": 1
"maxLength": 255
},
"fk_ref_healthcare_type_id": {
"type": "integer",
@@ -1404,8 +1704,7 @@ const docTemplate = `{
"minimum": 1
},
"fk_sd_location_id": {
"type": "string",
"minLength": 1
"type": "string"
},
"icon": {
"type": "string",
@@ -1439,6 +1738,261 @@ const docTemplate = `{
}
}
},
"api-service_internal_models_patient.Patient": {
"type": "object",
"properties": {
"active": {
"$ref": "#/definitions/sql.NullBool"
},
"address": {
"$ref": "#/definitions/sql.NullString"
},
"birth_date": {
"type": "string"
},
"ds_sd_kabupaten_kota": {
"$ref": "#/definitions/sql.NullString"
},
"ds_sd_kecamatan": {
"$ref": "#/definitions/sql.NullString"
},
"ds_sd_kelurahan": {
"$ref": "#/definitions/sql.NullString"
},
"ds_sd_provinsi": {
"$ref": "#/definitions/sql.NullString"
},
"fk_sd_kabupaten_kota_id": {
"$ref": "#/definitions/api-service_internal_models.NullableInt32"
},
"fk_sd_kecamatan_id": {
"$ref": "#/definitions/api-service_internal_models.NullableInt32"
},
"fk_sd_kelurahan_id": {
"$ref": "#/definitions/api-service_internal_models.NullableInt32"
},
"fk_sd_provinsi_id": {
"$ref": "#/definitions/api-service_internal_models.NullableInt32"
},
"gender": {
"$ref": "#/definitions/sql.NullString"
},
"id": {
"type": "integer"
},
"medical_record_number": {
"$ref": "#/definitions/sql.NullString"
},
"name": {
"$ref": "#/definitions/sql.NullString"
},
"phone_number": {
"$ref": "#/definitions/sql.NullString"
}
}
},
"api-service_internal_models_patient.PatientCreateRequest": {
"type": "object",
"properties": {
"active": {
"type": "boolean"
},
"address": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"birth_date": {
"type": "string"
},
"ds_sd_kabupaten_kota": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"ds_sd_kecamatan": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"ds_sd_kelurahan": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"ds_sd_provinsi": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"fk_sd_kabupaten_kota_id": {
"type": "integer"
},
"fk_sd_kecamatan_id": {
"type": "integer"
},
"fk_sd_kelurahan_id": {
"type": "integer"
},
"fk_sd_provinsi_id": {
"type": "integer"
},
"gender": {
"type": "string",
"maxLength": 1
},
"medical_record_number": {
"type": "string",
"maxLength": 20,
"minLength": 1
},
"name": {
"type": "string",
"maxLength": 100,
"minLength": 1
},
"phone_number": {
"type": "string",
"maxLength": 20,
"minLength": 1
}
}
},
"api-service_internal_models_patient.PatientCreateResponse": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/api-service_internal_models_patient.Patient"
},
"message": {
"type": "string"
}
}
},
"api-service_internal_models_patient.PatientDeleteResponse": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"api-service_internal_models_patient.PatientGetResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/api-service_internal_models_patient.Patient"
}
},
"message": {
"type": "string"
},
"meta": {
"$ref": "#/definitions/api-service_internal_models.MetaResponse"
},
"summary": {
"$ref": "#/definitions/api-service_internal_models.AggregateData"
}
}
},
"api-service_internal_models_patient.PatientPostRequest": {
"type": "object",
"required": [
"id"
],
"properties": {
"id": {
"type": "integer",
"minimum": 1
}
}
},
"api-service_internal_models_patient.PatientUpdateRequest": {
"type": "object",
"required": [
"id"
],
"properties": {
"active": {
"type": "boolean"
},
"address": {
"type": "string",
"maxLength": 255,
"minLength": 1
},
"birth_date": {
"type": "string"
},
"ds_sd_kabupaten_kota": {
"type": "string",
"maxLength": 255
},
"ds_sd_kecamatan": {
"type": "string",
"maxLength": 255
},
"ds_sd_kelurahan": {
"type": "string",
"maxLength": 255
},
"ds_sd_provinsi": {
"type": "string",
"maxLength": 255
},
"fk_sd_kabupaten_kota_id": {
"type": "integer"
},
"fk_sd_kecamatan_id": {
"type": "integer"
},
"fk_sd_kelurahan_id": {
"type": "integer"
},
"fk_sd_provinsi_id": {
"type": "integer"
},
"gender": {
"type": "string",
"maxLength": 1
},
"id": {
"type": "integer",
"minimum": 1
},
"medical_record_number": {
"type": "string",
"maxLength": 20,
"minLength": 1
},
"name": {
"type": "string",
"maxLength": 100,
"minLength": 1
},
"phone_number": {
"type": "string",
"maxLength": 20,
"minLength": 1
}
}
},
"api-service_internal_models_patient.PatientUpdateResponse": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/api-service_internal_models_patient.Patient"
},
"message": {
"type": "string"
}
}
},
"api-service_internal_models_retribusi.Retribusi": {
"type": "object",
"properties": {