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 retribusi modern dengan arsitektur bersih untuk pengelolaan data retribusi pemerintah**
> **Sistem manajemen pasien modern dengan arsitektur bersih untuk pengelolaan data kesehatan dan integrasi layanan kesehatan**
## 📑 Daftar Isi
- [✨ Fitur Utama](#-fitur-utama)
- [🏗️ Arsitektur](#%EF%B8%8F-arsitektur)
- [🏗️ Arsitektur](#-arsitektur)
- [⚡ Quick Start](#-quick-start)
- [🔐 Autentikasi](#-autentikasi)
- [📊 API Endpoints](#-api-endpoints)
- [🛠️ Development](#%EF%B8%8F-development)
- [🛠️ Development](#-development)
- [🚀 Deployment](#-deployment)
- [📚 Dokumentasi](#-dokumentasi)
- [🚨 Troubleshooting](#-troubleshooting)
***
@@ -21,8 +21,8 @@
### Core Features
- **🔒 JWT Authentication** - Sistem autentikasi dengan Keycloak integration
- **📋 Retribusi Management** - CRUD lengkap untuk data retribusi
- **🔍 Dynamic Filtering** - Filter dan pencarian data retribusi secara dinamis
- **👥 Patient Management** - CRUD lengkap untuk data pasien
- **🔍 Dynamic Filtering** - Filter dan pencarian data pasien secara dinamis
- **📊 Advanced Search** - Pencarian dengan multiple fields dan operators
- **🏥 BPJS Integration** - Integrasi dengan layanan kesehatan BPJS
- **🩺 SATUSEHAT Integration** - Integrasi dengan platform kesehatan SATUSEHAT
@@ -59,31 +59,31 @@
```
api-service/
├── 📁 cmd/
│ ├── api/main.go # 🚪 Entry point aplikasi
│ └── logging/main.go # 🔍 Logging service
├── 📁 internal/ # 🏠 Core business logic
│ ├── config/ # ⚙️ Configuration management
│ ├── database/ # 🗄️ Database connections
│ ├── handlers/ # 🎮 HTTP controllers
│ │ ├── auth/ # 🔐 Authentication handlers
│ │ ├── healthcheck/ # 💚 Health check handlers
│ │ └── retribusi/ # 📋 Retribusi handlers
│ ├── middleware/ # 🛡️ Auth & validation middleware
│ ├── models/ # 📊 Data structures
│ │ ├── auth/ # 👤 Auth models
│ │ └── retribusi/ # 📋 Retribusi models
│ ├── routes/ # 🛣️ API routing
│ ├── services/ # 💼 Business logic services
│ │ └── auth/ # 🔐 Auth services
│ ├── utils/ # 🛠️ Utility functions
│ │ ├── filters/ # 🔍 Dynamic filtering
│ │ └── validation/ # ✅ Data validation
│ └── server/ # 🌐 HTTP server setup
├── 📁 docs/ # 📚 Documentation
├── 📁 examples/ # 💡 Example files
├── 📁 scripts/ # 📜 Automation scripts
└── 📁 tools/ # 🔧 Development tools
├── 📁 cmd/ # Entry points aplikasi
│ ├── api/main.go # API server
│ └── logging/main.go # Logging service
├── 📁 internal/ # Core business logic
│ ├── config/ # Configuration management
│ ├── database/ # Database connections
│ ├── handlers/ # HTTP controllers
│ │ ├── auth/ # Authentication handlers
│ │ ├── healthcheck/ # Health check handlers
│ │ └── pasien/ # Pasien handlers
│ ├── middleware/ # Auth & validation middleware
│ ├── models/ # Data structures
│ │ ├── auth/ # Auth models
│ │ └── pasien/ # Pasien models
│ ├── routes/ # API routing
│ ├── services/ # Business logic services
│ │ └── auth/ # Auth services
│ ├── utils/ # Utility functions
│ │ ├── filters/ # Dynamic filtering
│ │ └── validation/ # Data validation
│ └── server/ # HTTP server setup
├── 📁 docs/ # Documentation
├── 📁 examples/ # Example files
├── 📁 scripts/ # Automation scripts
└── 📁 tools/ # Development tools
```
***
@@ -119,13 +119,13 @@ go mod download
go run cmd/api/main.go
```
### Update Swagger Documentation
### 3 Update Swagger Documentation
```bash
swag init -g cmd/api/main.go -o docs/
```
### 3️⃣ Verify Installation
### 4️⃣ Verify Installation
| Service | URL | Status |
| :-- | :-- | :-- |
@@ -165,16 +165,17 @@ curl -X POST http://localhost:8080/api/v1/auth/login \
### Menggunakan Token
```bash
curl -X GET http://localhost:8080/api/v1/retribusi \
curl -X GET http://localhost:8080/api/v1/pasien \
-H "Authorization: Bearer <your-token>"
```
### Demo Accounts
| Username | Password | Role | Akses |
| :-- | :-- | :-- |
| :-- | :-- | :-- | :-- |
| `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 |
#### Retribusi Management
#### Patient Management
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/retribusi` | List semua retribusi dengan pagination |
| `GET` | `/api/v1/retribusi/dynamic` | Query retribusi dengan filter dinamis |
| `GET` | `/api/v1/retribusi/search` | Pencarian retribusi advanced |
| `GET` | `/api/v1/retribusi/id/:id` | Detail retribusi by ID |
| `POST` | `/api/v1/retribusi` | Buat retribusi baru |
| `PUT` | `/api/v1/retribusi/id/:id` | Update retribusi |
| `DELETE` | `/api/v1/retribusi/id/:id` | Hapus retribusi (soft delete) |
| `GET` | `/api/v1/pasien` | List semua pasien dengan pagination |
| `GET` | `/api/v1/pasien/dynamic` | Query pasien dengan filter dinamis |
| `GET` | `/api/v1/pasien/search` | Pencarian pasien advanced |
| `GET` | `/api/v1/pasien/id/:id` | Detail pasien by ID |
| `GET` | `/api/v1/pasien/nik/:nik` | Detail pasien by NIK |
| `POST` | `/api/v1/pasien` | Buat pasien baru |
| `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
**Filter berdasarkan jenis:**
**Filter berdasarkan jenis kelamin:**
```bash
GET /api/v1/retribusi/dynamic?filter[Jenis][_eq]=RETRIBUSI PELAYANAN KESEHATAN
GET /api/v1/pasien/dynamic?filter[jenis_kelamin][_eq]=L
```
**Kombinasi filter:**
```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:**
```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:**
```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
@@ -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/rujukan/:no` | Data rujukan |
| `POST` | `/api/v1/bpjs/rujukan` | Buat rujukan baru |
#### SATUSEHAT Integration
| Method | Endpoint | Deskripsi |
| :-- | :-- | :-- |
| `GET` | `/api/v1/satusehat/patient/:id` | Data pasien |
| `POST` | `/api/v1/satusehat/encounter` | Buat encounter baru |
| `GET` | `/api/v1/satusehat/patient/:id` | Data pasien SATUSEHAT |
| `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_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
**Generate Handler untuk Retribusi:**
**Generate Handler untuk Pasien:**
```bash
# Config
go run tools/general/generate-handler.go --config tools/general/services-config.yaml --verbose
```
***
OBANESTHESI0003
## 🚀 Deployment
### 🐳 Docker Deployment
@@ -408,7 +422,7 @@ KEYCLOAK_ENABLED=true
# External Services
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'] =
`Bearer ${auth.data.access_token}`;
// Fetch retribusi data
const retribusi = await axios.get('/api/v1/retribusi');
console.log(retribusi.data);
// Fetch patient data
const patients = await axios.get('/api/v1/pasien');
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:**
@@ -454,13 +477,25 @@ TOKEN=$(curl -s -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"password"}' | jq -r '.access_token')
# Get retribusi data
# Get patient data
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8080/api/v1/retribusi
http://localhost:8080/api/v1/pasien
# Dynamic filtering
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
@@ -523,6 +558,12 @@ cat .env | grep DB_
- 🔍 Cek syntax filter: `filter[field][operator]=value`
- 📝 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
```bash
@@ -542,27 +583,7 @@ make watch
### 📋 Development Roadmap
- [ ] **Setup environment selesai**
- [ ] **Implementasi retribusi management**
- [ ] **Setup authentication dengan Keycloak**
- [ ] 🔄 **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
***
- [x] Setup environment selesai
- [x] Implementasi patient management
- [x] Setup authentication dengan Keycloak
- [ ] Integrasi BPJS dan SATUSEHAT