Files
satusehat-worker/docs/Devlog.md
T
2026-07-29 06:38:42 +00:00

177 lines
8.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 📅 Development Log (Catatan Status Integrasi)
**Project:** GoPrint Service General (`worker-satusehat`)
**Update Terakhir:** 2026-05-13
Dokumen ini melacak **status nyata** tiap modul/worker terhadap kode di branch `main`. Status diverifikasi dengan membaca file sumber, bukan sekadar tujuan; tanggal kolom *Last Touch* mengacu pada commit Git terkait.
---
## Legenda Status
-**Production / Aktif** — kode lengkap dan ter-wire di runtime.
- 🟢 **Ready to Activate** — implementasi lengkap, tinggal di-*uncomment* di `worker.go` / `main.go`.
- 🟡 **WIP / Parsial** — kerangka ada tapi logika belum diisi.
-**Backlog** — belum disentuh.
-**Bermasalah / Bug Diketahui** — perlu perbaikan sebelum dipakai.
---
## 1. Fondasi Infrastruktur
| Modul | Lokasi | Status | Catatan |
| :--- | :--- | :--- | :--- |
| Database Manager (multi-DB + CQRS) | `internal/infrastructure/database/` | ✅ | Postgres/MySQL/MSSQL/SQLite/Mongo; auto-tune connection pool |
| Cache Manager (Factory: Redis / NoOp) | `internal/infrastructure/cache/` | ✅ | Cache-aside; SHA-256 key hashing untuk permission |
| Config Loader (Viper + env overlay) | `internal/infrastructure/config/` | ✅ | YAML + ENV (`DATABASES_POSTGRES_HOST` dsb) |
| HTTP Server (Gin + ServiceRegistry) | `internal/infrastructure/transport/http/servers/` | ✅ | Port 8080, Swagger UI aktif |
| gRPC Server | `internal/infrastructure/transport/grpc/servers/` | 🟡 | Server berjalan, namun **`PermissionHandler` masih dikomentari** di [main.go:198-200](cmd/api/main.go#L198-L200) |
| MinIO Object Storage | `internal/interfaces/minio/` | ✅ | `minio.Connect()` dipanggil saat startup |
| Logger (Logrus + WIB hook) | `pkg/logger/logger.go` | ✅ | JSON, daily rotation, caller info |
| Error Package | `pkg/errors/` | ✅ | AppError + HTTP/gRPC mapping + i18n + middleware recovery |
| Query Builder | `pkg/utils/query/` | ✅ | Whitelist kolom, multi-dialect, ada unit test |
| Prometheus Metrics | (import only) | 🟡 | Library terpasang, endpoint `/metrics` belum di-wire ke routes |
---
## 2. Bridging Eksternal
### 2.1 SatuSehat Client
| Item | Status | Catatan |
| :--- | :--- | :--- |
| OAuth2 Client-Credentials + cache token | ✅ | `internal/interfaces/satusehat/client.go` |
| Auto-retry pada 401 (refresh + repeat) | ✅ | Mutex aman concurrent |
| `FHIRPayload` builder (fluent) | ✅ | `types.go` |
| `DoRequest` (FHIR R4) / `DoKFA` / `DoConsent` | ✅ | Tiga endpoint dengan base URL berbeda |
| Inisialisasi di `main.go` | ❌ | **Bug**: di-pass sebagai `nil` ke `worker.NewManager` di [main.go:235](cmd/api/main.go#L235) |
### 2.2 BPJS Client
| Layanan | Status | Catatan |
| :--- | :--- | :--- |
| Factory (`NewBPJSFactory`) | ✅ | `internal/interfaces/bpjs/factory.go` |
| VClaim / AntreanRS / AntreanFKTP / Aplicare / Apotek / PCare / ICare / ERekamMedis | ✅ | 8 service siap pakai |
| HMAC Signature (`SetHeader`) | ✅ | X-cons-id, X-timestamp, X-signature otomatis |
| Dekripsi AES-256-CBC + PKCS7 unpad | ✅ | `crypto.go` |
| Decompression cascade (LZString → Gzip → JSON) | ✅ | `decompression.go` |
| Integrasi sebagai worker / consumer aktif | ⚪ | Belum ada use case yang menggunakan; SDK saja |
---
## 3. Master Data
| Modul | Status | Catatan |
| :--- | :--- | :--- |
| **KFA Master Puller (Worker)** | ✅ | **SATU-SATUNYA worker yang aktif** di runtime; rate-limit handler komplit; UPSERT 3 tabel (product, ingredient, packaging) |
| KFA Repository (UPSERT Bundle transaksional) | ✅ | `internal/master/kfa/repository.go` |
| KFA Mapper (DTO → Entity, 58 kolom product) | ✅ | `internal/master/kfa/mapper.go` |
| KFA Tracker | 🟡 | Berbasis file `internal/master/kfa/kfa_tracker.txt` — perlu migrasi ke DB |
---
## 4. RBAC (Master Role)
| Sub-Modul | CQRS Command | CQRS Query | Service | Mapper | Status |
| :--- | :---: | :---: | :---: | :---: | :--- |
| `role/master` | ✅ | ✅ | ✅ | ✅ | ✅ |
| `role/pages` | ✅ | ✅ | ✅ | ✅ | ✅ |
| `role/permission` (tree + cache SHA-256) | ✅ | ✅ | ✅ | ✅ | ✅ |
| `role/accses` (agregasi GetRoleAccess) | ✅ | ✅ | ✅ | ✅ | ✅ |
| `role/component` | — | — | — | — | ⚪ Dikomentari di [main.go:22, 149-151](cmd/api/main.go#L149-L151) |
---
## 5. Auth
| Item | Status | Catatan |
| :--- | :--- | :--- |
| Provider pluggable (JWT/Keycloak/Static/Hybrid) | ✅ | Config `auth.type`, `auth.fallback_to` |
| Service + CQRS Repository | ✅ | `internal/auth/` |
| Login worker (internal `/auth/login`, `/auth/refresh`) | ✅ | `internal/worker/auth.go` — retry 6× pada startup |
| Kredensial worker login (`[email protected]` / `password123`) | ❌ | **Hardcoded** di [worker/auth.go:25-28](internal/worker/auth.go#L25-L28) — wajib pindah ke env |
---
## 6. Worker SatuSehat
### 6.1 Worker Aktif (terpasang di `worker.Manager.jobs`)
| Worker | Status | Catatan |
| :--- | :--- | :--- |
| **KFA Master Puller** | ✅ | Delay 5s, page size 100 |
### 6.2 Worker Ready-to-Activate (logika lengkap, dikomentari di `worker.go`)
| Worker | LOC `service.go` | Tracker | Mapping Harian | Status |
| :--- | :---: | :---: | :---: | :--- |
| `Medication` (Master) | 360 | `last_medication_id.txt` | ✅ | 🟢 |
| `MedicationRequest` | 366 | `last_medicationrequest_id.txt` | ✅ | 🟢 |
| `MedicationDispense` | 474 | `last_medicationdispense_id.txt` | ✅ | 🟢 |
| `ServiceRequest` (Default + Radiology) | 354 | `last_servicerequest_rad_time.txt` | — | 🟢 |
| `ImagingStudy` | 338 | `last_imagingstudy_id.txt` | ✅ | 🟢 |
| `Encounter` | 215 | (internal) | — | 🟢 |
### 6.3 Worker Stub (kerangka 93117 LOC, belum ada logika sinkron)
🟡 Implementasi minimum: `Config`, `Repository`, `Run()` skeleton — tidak ada tracker, KFA fetch, atau rate-limit handler.
| Worker | LOC | Worker | LOC |
| :--- | :---: | :--- | :---: |
| `AllergyIntolerance` | 93 | `Immunization` | 93 |
| `CarePlan` | 93 | `MedicationStatement` | 93 |
| `ClinicalImpression` | 93 | `Procedure` | 93 |
| `Composition` | 93 | `QuestionnaireResponse` | 93 |
| `Condition` | 117 | `Specimen` | 93 |
| `DiagnosticReport` | 93 | `Observation` | 117 |
| `EpisodeOfCare` | 93 | | |
---
## 7. Worker Lain
| Worker | Status | Catatan |
| :--- | :--- | :--- |
| `patient/migrator.go` (sinkron pasien dari SIMRS v4 legacy) | ❌ | Kode ada (~100+ LOC), **tidak dipanggil dari `main.go`/`worker.go`**; password default `1234` hardcoded |
---
## 8. Riwayat Commit Singkat
| Commit | Tanggal Indikatif | Ringkasan |
| :--- | :--- | :--- |
| `cc62620` | 2026-05 | Update worker medication, servicerequest, imagingstudy, medicationrequest, medicationdispense |
| `e8a0642` | 2026-04/05 | Pengambilan data KFA + pengiriman medication & service request |
| `24d25aa` | 2026-04 | Medication update |
| `9a15d74` | 2026-04 | Update worker SatuSehat |
| `35c1017` | 2026-04 | First commit (fondasi service-general) |
---
## 9. Pekerjaan Sedang Berjalan (WIP)
- [ ] Mengisi inisialisasi `satusehatClient` di `main.go` (saat ini `nil`).
- [ ] Mengaktifkan kembali worker `Medication` & turunannya setelah validasi end-to-end di staging.
- [ ] Migrasi tracker dari `.txt` ke tabel `sync_tracker` atau Redis hash (multi-replica readiness).
- [ ] Endpoint `/metrics` (Prometheus) di-wire ke HTTP router.
- [ ] gRPC `PermissionHandler` di-uncomment & di-test.
---
## 10. Bug & Hutang Teknis Diketahui
| ID | Lokasi | Deskripsi | Severity |
| :---: | :--- | :--- | :--- |
| BUG-001 | [main.go:235](cmd/api/main.go#L235) | `satusehatClient` di-pass `nil` ke Worker Manager | High |
| BUG-002 | [worker/auth.go:25-28](internal/worker/auth.go#L25-L28) | Kredensial login worker hardcoded | High |
| BUG-003 | [patient/migrator.go:23-26](internal/worker/patient/migrator.go#L23-L26) | Username/password default hardcoded jika worker diaktifkan | High |
| DEBT-001 | Semua worker | Tracker `.txt` lokal → tidak multi-pod safe | High |
| DEBT-002 | `internal/worker/satusehat/imagingstudy/service.go` & `medication/service.go` | Fungsi `truncate()` duplikat | Low |
| DEBT-003 | `main.go:198-200` | `permissionHandler` gRPC dikomentari, gRPC server tanpa handler aktif | Medium |
| DEBT-004 | `cmd/api/main.go:111-113` | `kafkaProducer` masih placeholder komentar — event-driven pipeline belum jalan | Medium |
| DEBT-005 | `internal/worker/satusehat/<13 resource>/` | Kerangka stub belum diisi | Medium |
---
*Disusun ulang: Tim Engineering GoPrint, 2026-05-13.*