128 lines
3.2 KiB
Markdown
128 lines
3.2 KiB
Markdown
# CPONE Middleware Go
|
|
|
|
Service Go untuk endpoint:
|
|
|
|
```text
|
|
GET /api/cpone/paket
|
|
GET /api/cpone/paket/{id}
|
|
Authorization: Bearer <your-secure-token>
|
|
|
|
GET /api/cpone/layanan-mapping-harga?periodeTarifID=10&layananID=6413,6414,1309
|
|
Authorization: Bearer <your-secure-token>
|
|
|
|
POST /api/cpone/patients/lab-registration
|
|
Authorization: Bearer <your-secure-token>
|
|
Content-Type: application/json
|
|
|
|
POST /api/cpone/patients/lab-registration/{regId}/services
|
|
Authorization: Bearer <your-secure-token>
|
|
Content-Type: application/json
|
|
|
|
POST /api/cpone/patients/medrec
|
|
Authorization: Bearer <your-secure-token>
|
|
Content-Type: application/json
|
|
```
|
|
|
|
Format payload dan response dibuat mengikuti controller PHP CPONE terkait.
|
|
|
|
Contoh payload pembuatan pasien HIS:
|
|
|
|
```json
|
|
{
|
|
"rs": "PRIMAYA",
|
|
"nama": "BUDI SANTOS",
|
|
"jenis_kelamin": "L",
|
|
"tgl_lahir": "1990-01-15",
|
|
"jenis_nomer_sosial": "KTP",
|
|
"nomer_sosial": "3174011501900001",
|
|
"telepon": "081234567890",
|
|
"ponsel": "081234567890",
|
|
"email": "budi@example.com",
|
|
"tempat_lahir": "JAKARTA",
|
|
"alamat": "JL. CONTOH NO. 1",
|
|
"propinsi": "DKI JAKARTA",
|
|
"kabupaten": "JAKARTA",
|
|
"kecamatan": "KECAMATAN CONTOH",
|
|
"kelurahan": "KELURAHAN CONTOH",
|
|
"kode_pos": "12345",
|
|
"channel": "CPONE"
|
|
}
|
|
```
|
|
|
|
Endpoint mengembalikan `created`, `already_exists`, atau `possible_duplicate`
|
|
sesuai hasil pemeriksaan identitas dan kemiripan data pasien di HIS.
|
|
|
|
Contoh payload registrasi laboratorium:
|
|
|
|
```json
|
|
{
|
|
"medrec_id": "00001234",
|
|
"tanggal": "2026-08-18",
|
|
"departemen_id": "LAB",
|
|
"dokter_id": "DR01",
|
|
"dokter_pengirim_id": "DR02",
|
|
"perujuk": null,
|
|
"jenis_pasien_id": "0",
|
|
"periode_tarif_id": 10,
|
|
"kelas_id": "Default",
|
|
"shift_harian_id": null,
|
|
"diagnosa_kerja": "Pemeriksaan laboratorium",
|
|
"catatan": null,
|
|
"channel": "CPONE"
|
|
}
|
|
```
|
|
|
|
`dokter_pengirim_id` atau `perujuk` wajib diisi. Endpoint ini membuat
|
|
registrasi laboratorium tanpa layanan, sama seperti
|
|
`PatientController::registerLab`; layanan ditambahkan melalui endpoint terpisah.
|
|
|
|
Contoh payload penambahan layanan:
|
|
|
|
```json
|
|
{
|
|
"layanan": [
|
|
{
|
|
"layanan_id": "6413",
|
|
"jumlah": 1,
|
|
"cito": false,
|
|
"markup_cito": 0,
|
|
"catatan": null
|
|
}
|
|
],
|
|
"channel": "CPONE"
|
|
}
|
|
```
|
|
|
|
Harga, diskon publik, share, unit cost, layanan multiple, dan spesimen diambil
|
|
langsung dari master HIS. Layanan yang sudah ada akan dilewati dan dilaporkan
|
|
melalui `skipped_layanan_ids`.
|
|
|
|
## Config
|
|
|
|
Copy `.env.example` menjadi `.env`, lalu isi koneksi MySQL:
|
|
|
|
```text
|
|
APP_HOST=0.0.0.0
|
|
APP_PORT=8080
|
|
DB_HOST=127.0.0.1
|
|
DB_PORT=3306
|
|
DB_DATABASE=primaya
|
|
DB_USERNAME=root
|
|
DB_PASSWORD=
|
|
CPONE_BEARER_TOKEN=replace-with-a-secure-token
|
|
```
|
|
|
|
## Run
|
|
|
|
```bash
|
|
cd cpone-middleware
|
|
go mod tidy
|
|
go run ./cmd/server
|
|
```
|
|
|
|
## SQLC
|
|
|
|
File `sqlc.yaml`, `sqlc/schema.sql`, dan `sqlc/query.sql` sudah disiapkan.
|
|
|
|
Catatan penting: sqlc tidak bisa menerima nama tabel dinamis seperti `harga_layanan_{periodeTarifID}`. Implementasi runtime saat ini tetap memakai `database/sql` untuk menyusun nama tabel setelah `periodeTarifID` divalidasi angka, sama seperti PHP memakai `HargaLayanan::makeTableName()`. Kalau semua periode ingin digenerate oleh sqlc, buat query konkret per tabel periode, misalnya `harga_layanan_10`, `harga_layanan_11`, dan seterusnya.
|