This commit is contained in:
meninjar
2025-11-03 06:43:31 +00:00
parent db5a19e9cc
commit 6d71e408bc
+109 -88
View File
@@ -1,18 +1,18 @@
# 🚀 API Service - Sistem Manajemen Pasien
# 🚀 API Service - CRUD Management System > **Sistem manajemen pasien modern dengan arsitektur bersih untuk pengelolaan data kesehatan dan integrasi layanan kesehatan**
> **Sistem manajemen retribusi modern dengan arsitektur bersih untuk pengelolaan data retribusi pemerintah**
## 📑 Daftar Isi ## 📑 Daftar Isi
- [✨ Fitur Utama](#-fitur-utama) - [✨ Fitur Utama](#-fitur-utama)
- [🏗️ Arsitektur](#%EF%B8%8F-arsitektur) - [🏗️ Arsitektur](#-arsitektur)
- [⚡ Quick Start](#-quick-start) - [⚡ Quick Start](#-quick-start)
- [🔐 Autentikasi](#-autentikasi) - [🔐 Autentikasi](#-autentikasi)
- [📊 API Endpoints](#-api-endpoints) - [📊 API Endpoints](#-api-endpoints)
- [🛠️ Development](#%EF%B8%8F-development) - [🛠️ Development](#-development)
- [🚀 Deployment](#-deployment) - [🚀 Deployment](#-deployment)
- [📚 Dokumentasi](#-dokumentasi) - [📚 Dokumentasi](#-dokumentasi)
- [🚨 Troubleshooting](#-troubleshooting)
*** ***
@@ -21,8 +21,8 @@
### Core Features ### Core Features
- **🔒 JWT Authentication** - Sistem autentikasi dengan Keycloak integration - **🔒 JWT Authentication** - Sistem autentikasi dengan Keycloak integration
- **📋 Retribusi Management** - CRUD lengkap untuk data retribusi - **👥 Patient Management** - CRUD lengkap untuk data pasien
- **🔍 Dynamic Filtering** - Filter dan pencarian data retribusi secara dinamis - **🔍 Dynamic Filtering** - Filter dan pencarian data pasien secara dinamis
- **📊 Advanced Search** - Pencarian dengan multiple fields dan operators - **📊 Advanced Search** - Pencarian dengan multiple fields dan operators
- **🏥 BPJS Integration** - Integrasi dengan layanan kesehatan BPJS - **🏥 BPJS Integration** - Integrasi dengan layanan kesehatan BPJS
- **🩺 SATUSEHAT Integration** - Integrasi dengan platform kesehatan SATUSEHAT - **🩺 SATUSEHAT Integration** - Integrasi dengan platform kesehatan SATUSEHAT
@@ -59,31 +59,31 @@
``` ```
api-service/ api-service/
├── 📁 cmd/ ├── 📁 cmd/ # Entry points aplikasi
│ ├── api/main.go # 🚪 Entry point aplikasi │ ├── api/main.go # API server
│ └── logging/main.go # 🔍 Logging service │ └── logging/main.go # Logging service
├── 📁 internal/ # 🏠 Core business logic ├── 📁 internal/ # Core business logic
│ ├── config/ # ⚙️ Configuration management │ ├── config/ # Configuration management
│ ├── database/ # 🗄️ Database connections │ ├── database/ # Database connections
│ ├── handlers/ # 🎮 HTTP controllers │ ├── handlers/ # HTTP controllers
│ │ ├── auth/ # 🔐 Authentication handlers │ │ ├── auth/ # Authentication handlers
│ │ ├── healthcheck/ # 💚 Health check handlers │ │ ├── healthcheck/ # Health check handlers
│ │ └── retribusi/ # 📋 Retribusi handlers │ │ └── pasien/ # Pasien handlers
│ ├── middleware/ # 🛡️ Auth & validation middleware │ ├── middleware/ # Auth & validation middleware
│ ├── models/ # 📊 Data structures │ ├── models/ # Data structures
│ │ ├── auth/ # 👤 Auth models │ │ ├── auth/ # Auth models
│ │ └── retribusi/ # 📋 Retribusi models │ │ └── pasien/ # Pasien models
│ ├── routes/ # 🛣️ API routing │ ├── routes/ # API routing
│ ├── services/ # 💼 Business logic services │ ├── services/ # Business logic services
│ │ └── auth/ # 🔐 Auth services │ │ └── auth/ # Auth services
│ ├── utils/ # 🛠️ Utility functions │ ├── utils/ # Utility functions
│ │ ├── filters/ # 🔍 Dynamic filtering │ │ ├── filters/ # Dynamic filtering
│ │ └── validation/ # ✅ Data validation │ │ └── validation/ # Data validation
│ └── server/ # 🌐 HTTP server setup │ └── server/ # HTTP server setup
├── 📁 docs/ # 📚 Documentation ├── 📁 docs/ # Documentation
├── 📁 examples/ # 💡 Example files ├── 📁 examples/ # Example files
├── 📁 scripts/ # 📜 Automation scripts ├── 📁 scripts/ # Automation scripts
└── 📁 tools/ # 🔧 Development tools └── 📁 tools/ # Development tools
``` ```
*** ***
@@ -119,13 +119,13 @@ go mod download
go run cmd/api/main.go go run cmd/api/main.go
``` ```
### Update Swagger Documentation ### 3 Update Swagger Documentation
```bash ```bash
swag init -g cmd/api/main.go -o docs/ swag init -g cmd/api/main.go -o docs/
``` ```
### 3️⃣ Verify Installation ### 4️⃣ Verify Installation
| Service | URL | Status | | Service | URL | Status |
| :-- | :-- | :-- | | :-- | :-- | :-- |
@@ -165,16 +165,17 @@ curl -X POST http://localhost:8080/api/v1/auth/login \
### Menggunakan Token ### Menggunakan Token
```bash ```bash
curl -X GET http://localhost:8080/api/v1/retribusi \ curl -X GET http://localhost:8080/api/v1/pasien \
-H "Authorization: Bearer <your-token>" -H "Authorization: Bearer <your-token>"
``` ```
### Demo Accounts ### Demo Accounts
| Username | Password | Role | Akses | | Username | Password | Role | Akses |
| :-- | :-- | :-- | | :-- | :-- | :-- | :-- |
| `admin` | `password` | Admin | Semua endpoint | | `admin` | `password` | Admin | Semua endpoint |
| `user` | `password` | User | Read-only | | `dokter` | `password` | Dokter | Akses terbatas |
| `perawat` | `password` | Perawat | Read-only |
*** ***
@@ -197,42 +198,51 @@ curl -X GET http://localhost:8080/api/v1/retribusi \
| :-- | :-- | :-- | | :-- | :-- | :-- |
| `GET` | `/api/sistem/databases` | Informasi database connections | | `GET` | `/api/sistem/databases` | Informasi database connections |
#### Retribusi Management #### Patient Management
| Method | Endpoint | Deskripsi | | Method | Endpoint | Deskripsi |
| :-- | :-- | :-- | | :-- | :-- | :-- |
| `GET` | `/api/v1/retribusi` | List semua retribusi dengan pagination | | `GET` | `/api/v1/pasien` | List semua pasien dengan pagination |
| `GET` | `/api/v1/retribusi/dynamic` | Query retribusi dengan filter dinamis | | `GET` | `/api/v1/pasien/dynamic` | Query pasien dengan filter dinamis |
| `GET` | `/api/v1/retribusi/search` | Pencarian retribusi advanced | | `GET` | `/api/v1/pasien/search` | Pencarian pasien advanced |
| `GET` | `/api/v1/retribusi/id/:id` | Detail retribusi by ID | | `GET` | `/api/v1/pasien/id/:id` | Detail pasien by ID |
| `POST` | `/api/v1/retribusi` | Buat retribusi baru | | `GET` | `/api/v1/pasien/nik/:nik` | Detail pasien by NIK |
| `PUT` | `/api/v1/retribusi/id/:id` | Update retribusi | | `POST` | `/api/v1/pasien` | Buat pasien baru |
| `DELETE` | `/api/v1/retribusi/id/:id` | Hapus retribusi (soft delete) | | `PUT` | `/api/v1/pasien/id/:id` | Update data pasien |
| `DELETE` | `/api/v1/pasien/id/:id` | Hapus data pasien (soft delete) |
#### Medical Records
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/pasien/:id/medical-records` | Riwayat medis pasien |
| `POST` | `/api/v1/pasien/:id/medical-records` | Tambah rekam medis |
| `GET` | `/api/v1/pasien/:id/medical-records/:recordId` | Detail rekam medis |
#### Dynamic Query Examples #### Dynamic Query Examples
**Filter berdasarkan jenis:** **Filter berdasarkan jenis kelamin:**
```bash ```bash
GET /api/v1/retribusi/dynamic?filter[Jenis][_eq]=RETRIBUSI PELAYANAN KESEHATAN GET /api/v1/pasien/dynamic?filter[jenis_kelamin][_eq]=L
``` ```
**Kombinasi filter:** **Kombinasi filter:**
```bash ```bash
GET /api/v1/retribusi/dynamic?filter[status][_eq]=active&filter[Tarif][_gt]=100000 GET /api/v1/pasien/dynamic?filter[status][_eq]=active&filter[umur][_gt]=18
``` ```
**Pagination dan sorting:** **Pagination dan sorting:**
```bash ```bash
GET /api/v1/retribusi/dynamic?sort=-date_created&limit=10&offset=20 GET /api/v1/pasien/dynamic?sort=-tanggal_daftar&limit=10&offset=20
``` ```
**Advanced search:** **Advanced search:**
```bash ```bash
GET /api/v1/retribusi/search?q=rumah%20sakit&limit=20&offset=0 GET /api/v1/pasien/search?q=andi&limit=20&offset=0
``` ```
### 🏥 External Integrations ### 🏥 External Integrations
@@ -243,13 +253,16 @@ GET /api/v1/retribusi/search?q=rumah%20sakit&limit=20&offset=0
| :-- | :-- | :-- | | :-- | :-- | :-- |
| `GET` | `/api/v1/bpjs/peserta/:no` | Data peserta BPJS | | `GET` | `/api/v1/bpjs/peserta/:no` | Data peserta BPJS |
| `GET` | `/api/v1/bpjs/rujukan/:no` | Data rujukan | | `GET` | `/api/v1/bpjs/rujukan/:no` | Data rujukan |
| `POST` | `/api/v1/bpjs/rujukan` | Buat rujukan baru |
#### SATUSEHAT Integration #### SATUSEHAT Integration
| Method | Endpoint | Deskripsi | | Method | Endpoint | Deskripsi |
| :-- | :-- | :-- | | :-- | :-- | :-- |
| `GET` | `/api/v1/satusehat/patient/:id` | Data pasien | | `GET` | `/api/v1/satusehat/patient/:id` | Data pasien SATUSEHAT |
| `POST` | `/api/v1/satusehat/encounter` | Buat encounter baru | | `POST` | `/api/v1/satusehat/patient` | Buat pasien di SATUSEHAT |
| `GET` | `/api/v1/satusehat/encounter/:id` | Data kunjungan |
| `POST` | `/api/v1/satusehat/encounter` | Buat kunjungan baru |
*** ***
@@ -332,22 +345,23 @@ BPJS_CONSID=52667757
BPJS_USERKEY=4cf1cbef811314fvdgrc008440bbe9ef9ba789e482 BPJS_USERKEY=4cf1cbef811314fvdgrc008440bbe9ef9ba789e482
BPJS_SECRETKEY=1bV36ASDQQ3512D BPJS_SECRETKEY=1bV36ASDQQ3512D
# SATUSEHAT Configuration
SATUSEHAT_BASEURL=https://api-satusehat.kemkes.go.id/fhir-r4/v1
SATUSEHAT_CLIENT_ID=your-client-id
SATUSEHAT_CLIENT_SECRET=your-client-secret
``` ```
### Code Generation ### Code Generation
**Generate Handler untuk Retribusi:** **Generate Handler untuk Pasien:**
```bash ```bash
# Config # Config
go run tools/general/generate-handler.go --config tools/general/services-config.yaml --verbose go run tools/general/generate-handler.go --config tools/general/services-config.yaml --verbose
``` ```
*** ***
OBANESTHESI0003
## 🚀 Deployment ## 🚀 Deployment
### 🐳 Docker Deployment ### 🐳 Docker Deployment
@@ -408,7 +422,7 @@ KEYCLOAK_ENABLED=true
# External Services # External Services
BPJS_BASEURL=https://apijkn.bpjs-kesehatan.go.id/vclaim-rest BPJS_BASEURL=https://apijkn.bpjs-kesehatan.go.id/vclaim-rest
BRIDGING_SATUSEHAT_BASE_URL=https://api-satusehat.kemkes.go.id/fhir-r4/v1 SATUSEHAT_BASEURL=https://api-satusehat.kemkes.go.id/fhir-r4/v1
``` ```
*** ***
@@ -441,9 +455,18 @@ const auth = await axios.post('/api/v1/auth/login', {
axios.defaults.headers.common['Authorization'] = axios.defaults.headers.common['Authorization'] =
`Bearer ${auth.data.access_token}`; `Bearer ${auth.data.access_token}`;
// Fetch retribusi data // Fetch patient data
const retribusi = await axios.get('/api/v1/retribusi'); const patients = await axios.get('/api/v1/pasien');
console.log(retribusi.data); console.log(patients.data);
// Create new patient
const newPatient = await axios.post('/api/v1/pasien', {
nama: "John Doe",
nik: "1234567890123456",
tanggal_lahir: "1990-01-01",
jenis_kelamin: "L",
alamat: "Jl. Contoh No. 123"
});
``` ```
**cURL Examples:** **cURL Examples:**
@@ -454,13 +477,25 @@ TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}' | jq -r '.access_token') -d '{"username":"admin","password":"password"}' | jq -r '.access_token')
# Get retribusi data # Get patient data
curl -H "Authorization: Bearer $TOKEN" \ curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8080/api/v1/retribusi http://localhost:8080/api/v1/pasien
# Dynamic filtering # Dynamic filtering
curl -H "Authorization: Bearer $TOKEN" \ curl -H "Authorization: Bearer $TOKEN" \
"http://localhost:8080/api/v1/retribusi/dynamic?filter[Jenis][_eq]=RETRIBUSI%20PELAYANAN%20KESEHATAN" "http://localhost:8080/api/v1/pasien/dynamic?filter[jenis_kelamin][_eq]=L"
# Create new patient
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"nama": "Jane Doe",
"nik": "6543210987654321",
"tanggal_lahir": "1985-05-15",
"jenis_kelamin": "P",
"alamat": "Jl. Contoh No. 456"
}' \
http://localhost:8080/api/v1/pasien
``` ```
### 🔍 Health Monitoring ### 🔍 Health Monitoring
@@ -523,6 +558,12 @@ cat .env | grep DB_
- 🔍 Cek syntax filter: `filter[field][operator]=value` - 🔍 Cek syntax filter: `filter[field][operator]=value`
- 📝 Operator yang didukung: `_eq`, `_neq`, `_gt`, `_lt`, `_contains` - 📝 Operator yang didukung: `_eq`, `_neq`, `_gt`, `_lt`, `_contains`
**❌ BPJS/SATUSEHAT Integration Error**
- ✅ Verifikasi kredensial API
- 🔄 Cek koneksi ke layanan eksternal
- 📝 Pastikan format data sesuai dengan spesifikasi
### Debug Mode ### Debug Mode
```bash ```bash
@@ -542,27 +583,7 @@ make watch
### 📋 Development Roadmap ### 📋 Development Roadmap
- [ ] **Setup environment selesai** - [x] Setup environment selesai
- [ ] **Implementasi retribusi management** - [x] Implementasi patient management
- [ ] **Setup authentication dengan Keycloak** - [x] Setup authentication dengan Keycloak
- [ ] 🔄 **Integrasi BPJS dan SATUSEHAT** - [ ] Integrasi BPJS dan SATUSEHAT
- [ ] 🔄 **Testing dan validation**
- [ ] 🔄 **Setup monitoring dan logging**
- [ ] 🔄 **Deploy ke production**
### 🚀 Advanced Features
- **📊 Real-time Dashboard**
- **🔒 Enhanced Security (Rate limiting, CORS)**
- **📈 Performance Monitoring**
- **🌐 API Versioning**
- **📱 Mobile SDK Integration**
***
**⚡ Total setup time: 5 menit | 🔧 Generate Handler: 30 detik | 🧪 Testing: Langsung via Swagger**
> **💡 Pro Tip:** Gunakan `make help` untuk melihat semua command yang tersedia
***