diff --git a/README.md b/README.md index 402052a..d0d877d 100644 --- a/README.md +++ b/README.md @@ -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 " ``` ### 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 \ No newline at end of file