Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fine-spies-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ssecd/jkn': minor
---

Add lifecycle events
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ JKN_APOTEK_USER_KEY=
JKN_PCARE_USER_KEY=
JKN_ICARE_USER_KEY=
JKN_REKAM_MEDIS_USER_KEY=
JKN_APLICARES_USER_KEY=

TEST_SEP_NUM=
TEST_RM_NUM=
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,35 @@ function persistSep(sep: VClaimResponse<'sep', 'insertV2'>) {
}
```

## Events

- `onRequest`

```ts
onRequest: ((info: SendOption & { type: Type }) => MaybePromise<void>) | undefined = undefined;
```

- `onResponse`

```ts
onResponse: (<T extends Type = Type>(info: SendOption & { duration: number; type: T; }, result: SendResponse<unknown, unknown>[T]) => MaybePromise<void>) | undefined = undefined;
```

- `onError`

```ts
onError: ((error: unknown) => MaybePromise<void>) | undefined = undefined;
```

Contoh penggunaan event:

```ts
jkn.onResponse = (info, result) => {
console.log('>', Math.round(info.duration) + 'ms', info.type, info.name);
// > 279ms vclaim Peserta -> NIK
};
```

## Konfigurasi

Konfigurasi mengikuti interface berikut:
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
},
"type": "module",
"scripts": {
"vitest": "node --env-file=.env ./node_modules/vitest/vitest.mjs",
"test": "vitest",
"test": "node --env-file=.env ./node_modules/vitest/vitest.mjs",
"build": "tsc && dts-buddy dist/index.d.ts -m @ssecd/jkn:src/index.js",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
Expand Down
5 changes: 5 additions & 0 deletions src/antrean-fktp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class AntreanFKTP extends BaseApi<'pcare'> {
kodepoli: string;
}[];
}>({
name: this.name + 'Referensi Poli',
path: `/ref/poli/tanggal/${params.tanggal}`,
method: 'GET'
});
Expand All @@ -41,6 +42,7 @@ export class AntreanFKTP extends BaseApi<'pcare'> {
kapasitas: number;
}[];
}>({
name: this.name + 'Referensi Dokter',
path: `/ref/dokter/kodepoli/${params.kodePoli}/tanggal/${params.tanggal}`,
method: 'GET'
});
Expand Down Expand Up @@ -90,6 +92,7 @@ export class AntreanFKTP extends BaseApi<'pcare'> {
keterangan: string;
}) {
return this.send({
name: this.name + 'Tambah Antrean',
path: `/antrean/add`,
method: 'POST',
data
Expand Down Expand Up @@ -122,6 +125,7 @@ export class AntreanFKTP extends BaseApi<'pcare'> {
waktu: number;
}) {
return this.send({
name: this.name + 'Update Status / Panggil Antrean',
path: `/antrean/panggil`,
method: 'POST',
data
Expand All @@ -145,6 +149,7 @@ export class AntreanFKTP extends BaseApi<'pcare'> {
alasan: string;
}) {
return this.send({
name: this.name + 'Batal Antrean',
path: `/antrean/batal`,
method: 'POST',
data
Expand Down
17 changes: 17 additions & 0 deletions src/antrean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class Antrean extends BaseApi<'antrean'> {
kdpoli: string;
}[]
>({
name: 'Referensi Poli',
path: '/ref/poli',
method: 'GET'
});
Expand All @@ -30,6 +31,7 @@ export class Antrean extends BaseApi<'antrean'> {
kodedokter: number;
}[]
>({
name: 'Referensi Dokter',
path: '/ref/dokter',
method: 'GET'
});
Expand Down Expand Up @@ -60,6 +62,7 @@ export class Antrean extends BaseApi<'antrean'> {
kodedokter: number;
}[]
>({
name: 'Referensi Jadwal Dokter',
path: `/jadwaldokter/kodepoli/${params.poli}/tanggal/${params.tanggal}`,
method: 'GET'
});
Expand All @@ -77,6 +80,7 @@ export class Antrean extends BaseApi<'antrean'> {
namapoli: string;
}[]
>({
name: 'Referensi Poli Fingerprint',
path: '/ref/poli/fp',
method: 'GET'
});
Expand All @@ -98,6 +102,7 @@ export class Antrean extends BaseApi<'antrean'> {
tgllahir: string;
daftarfp: number;
}>({
name: 'Referensi Pasien Fingerprint',
path: `/ref/pasien/fp/identitas/${params.jenis}/noidentitas/${params.nomor}`,
method: 'GET'
});
Expand Down Expand Up @@ -142,6 +147,7 @@ export class Antrean extends BaseApi<'antrean'> {
}[];
}) {
return this.send({
name: 'Update Jadwal Dokter',
path: `/jadwaldokter/updatejadwaldokter`,
method: 'POST',
data
Expand Down Expand Up @@ -226,6 +232,7 @@ export class Antrean extends BaseApi<'antrean'> {
keterangan: string;
}) {
return this.send({
name: 'Tambah Antrean',
path: `/antrean/add`,
method: 'POST',
data
Expand All @@ -247,6 +254,7 @@ export class Antrean extends BaseApi<'antrean'> {
keterangan: string;
}) {
return this.send({
name: 'Tambah Antrean Farmasi',
path: `/antrean/farmasi/add`,
method: 'POST',
data
Expand Down Expand Up @@ -302,6 +310,7 @@ export class Antrean extends BaseApi<'antrean'> {
jenisresep?: 'Tidak ada' | 'Racikan' | 'Non racikan';
}) {
return this.send({
name: 'Update Waktu Antrean',
path: `/antrean/updatewaktu`,
method: 'POST',
data
Expand All @@ -321,6 +330,7 @@ export class Antrean extends BaseApi<'antrean'> {
keterangan: string;
}) {
return this.send({
name: 'Batal Antrean',
path: `/antrean/batal`,
method: 'POST',
data
Expand Down Expand Up @@ -350,6 +360,7 @@ export class Antrean extends BaseApi<'antrean'> {
kodebooking: string;
}[]
>({
name: 'List Waktu TaskId',
path: `/antrean/getlisttask`,
method: 'POST',
data: { kodebooking: params.kodeBooking }
Expand Down Expand Up @@ -379,6 +390,7 @@ export class Antrean extends BaseApi<'antrean'> {
waktu: string;
}) {
return this.send<{ list: AntreanDashboard[] }>({
name: 'Dashboard Per-Tanggal',
path: `/dashboard/waktutunggu/tanggal/${params.tanggal}/waktu/${params.waktu}`,
method: 'GET',
skipDecrypt: true
Expand Down Expand Up @@ -413,6 +425,7 @@ export class Antrean extends BaseApi<'antrean'> {
}) {
const bulan = String(params.bulan).padStart(2, '0');
return this.send<{ list: AntreanDashboard[] }>({
name: 'Dashboard Per-Bulan',
path: `/dashboard/waktutunggu/bulan/${bulan}/tahun/${params.tahun}/waktu/${params.waktu}`,
method: 'GET',
skipDecrypt: true
Expand All @@ -426,6 +439,7 @@ export class Antrean extends BaseApi<'antrean'> {
*/
async perTanggal(tanggal: string) {
return this.send<AntreanDetail[]>({
name: 'Antrean Per-Tanggal',
path: `/antrean/pendaftaran/tanggal/${tanggal}`,
method: 'GET'
});
Expand All @@ -438,6 +452,7 @@ export class Antrean extends BaseApi<'antrean'> {
*/
async perKodeBooking(kodeBooking: string) {
return this.send<AntreanDetail[]>({
name: 'Antrean Per-KodeBooking',
path: `/antrean/pendaftaran/kodebooking/${kodeBooking}`,
method: 'GET'
});
Expand All @@ -448,6 +463,7 @@ export class Antrean extends BaseApi<'antrean'> {
*/
async belumDilayani() {
return this.send<AntreanDetail[]>({
name: 'Antrean Belum Dilayani',
path: `/antrean/pendaftaran/aktif`,
method: 'GET'
});
Expand All @@ -470,6 +486,7 @@ export class Antrean extends BaseApi<'antrean'> {
jam: string;
}) {
return this.send<AntreanDetail[]>({
name: 'Antrean Belum Dilayani Per-(Poli, Dokter, Hari, dan Jam Praktik)',
path: `/antrean/pendaftaran/kodepoli/${params.poli}/kodedokter/${params.dokter}/hari/${params.hari}/jampraktek/${params.jam}`,
method: 'GET'
});
Expand Down
5 changes: 5 additions & 0 deletions src/aplicares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class Aplicares extends BaseApi<'aplicares'> {
},
{ totalitems: number }
>({
name: 'Referensi Kamar',
path: `/rest/ref/kelas`,
method: 'GET',
skipDecrypt: true
Expand All @@ -33,6 +34,7 @@ export class Aplicares extends BaseApi<'aplicares'> {
async update(data: AplicaresBedData) {
const { ppkCode } = await this.requiredConfig('ppkCode');
return this.send({
name: 'Update Ketersediaan Tempat Tidur',
path: `/rest/bed/update/${ppkCode}`,
method: 'POST',
skipContentTypeHack: true,
Expand All @@ -52,6 +54,7 @@ export class Aplicares extends BaseApi<'aplicares'> {
async create(data: AplicaresBedData) {
const { ppkCode } = await this.requiredConfig('ppkCode');
return this.send<undefined>({
name: 'Ruangan Baru',
path: `/rest/bed/create/${ppkCode}`,
method: 'POST',
skipContentTypeHack: true,
Expand Down Expand Up @@ -85,6 +88,7 @@ export class Aplicares extends BaseApi<'aplicares'> {
},
{ totalitems: number }
>({
name: 'Ketersediaan Kamar Faskes',
path: `/rest/bed/read/${ppkCode}/${params.start}/${params.limit}`,
method: 'GET',
skipDecrypt: true
Expand All @@ -103,6 +107,7 @@ export class Aplicares extends BaseApi<'aplicares'> {
}) {
const { ppkCode } = await this.requiredConfig('ppkCode');
return this.send<undefined>({
name: 'Hapus Ruangan',
path: `/rest/bed/delete/${ppkCode}`,
method: 'POST',
skipContentTypeHack: true,
Expand Down
1 change: 1 addition & 0 deletions src/apotek/monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Monitoring extends ApotekBaseApi {
}[];
};
}>({
name: this.name + 'Data Klaim',
path: `/monitoring/klaim/${params.bulan}/${params.tahun}/${params.jenisObat}/${params.status}`,
method: 'GET'
});
Expand Down
2 changes: 2 additions & 0 deletions src/apotek/obat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Obat extends ApotekBaseApi {
CatKhsObt: string;
}) {
return this.send<null>({
name: this.name + 'Simpan (Non-Racikan)',
path: `/obatnonracikan/v3/insert`,
method: 'POST',
data
Expand All @@ -41,6 +42,7 @@ export class Obat extends ApotekBaseApi {
CatKhsObt: string;
}) {
return this.send<null>({
name: this.name + 'Simpan (Racikan)',
path: `/obatracikan/v3/insert`,
method: 'POST',
data
Expand Down
3 changes: 3 additions & 0 deletions src/apotek/pelayanan-obat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class PelayananObat extends ApotekBaseApi {
tipeobat: string;
}) {
return this.send<string>({
name: this.name + 'Hapus',
path: `/pelayanan/obat/hapus/`,
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -52,6 +53,7 @@ export class PelayananObat extends ApotekBaseApi {
};
};
}>({
name: this.name + 'List/Daftar',
path: `/pelayanan/obat/daftar/${params.nomorSep}`,
method: 'GET'
});
Expand Down Expand Up @@ -85,6 +87,7 @@ export class PelayananObat extends ApotekBaseApi {
}[];
};
}>({
name: this.name + 'Riwayat',
path: `/riwayatobat/${params.awal}/${params.akhir}/${params.nomorKartu}`,
method: 'GET'
});
Expand Down
6 changes: 6 additions & 0 deletions src/apotek/referensi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class Referensi extends ApotekBaseApi {
aktif: string | null;
}[];
}>({
name: this.name + 'DPHO',
path: `/referensi/dpho`,
method: 'GET'
});
Expand All @@ -36,6 +37,7 @@ export class Referensi extends ApotekBaseApi {
nama: string;
}[];
}>({
name: this.name + 'Poli',
path: `/referensi/poli/${params.keyword}`,
method: 'GET'
});
Expand All @@ -61,6 +63,7 @@ export class Referensi extends ApotekBaseApi {
nama: string;
}[];
}>({
name: this.name + 'Fasilitas Kesehatan',
path: `/referensi/ppk/${params.jenis}/${params.nama}`,
method: 'GET'
});
Expand Down Expand Up @@ -88,6 +91,7 @@ export class Referensi extends ApotekBaseApi {
nippetugasapotek: string;
checkstock: 'True' | 'False';
}>({
name: this.name + 'Setting',
path: `/referensi/settingppk/read/${params.kodeApotek}`,
method: 'GET'
});
Expand All @@ -103,6 +107,7 @@ export class Referensi extends ApotekBaseApi {
nama: string;
}[];
}>({
name: this.name + 'Spesialistik',
path: `/referensi/spesialistik`,
method: 'GET'
});
Expand All @@ -129,6 +134,7 @@ export class Referensi extends ApotekBaseApi {
harga: string;
}[];
}>({
name: this.name + 'Cari Obat',
path: `/referensi/obat/${param.jenis}/${param.tanggal}/${filter}`,
method: 'GET'
});
Expand Down
3 changes: 3 additions & 0 deletions src/apotek/resep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class Resep extends ApotekBaseApi {
byVerRsp: string;
tglEntry: string;
}>({
name: this.name + 'Simpan',
path: `/sjpresep/v3/insert`,
method: 'POST',
data
Expand All @@ -68,6 +69,7 @@ export class Resep extends ApotekBaseApi {
noresep: string;
}) {
return this.send<null>({
name: this.name + 'Hapus',
path: `/hapusresep`,
method: 'DELETE',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -109,6 +111,7 @@ export class Resep extends ApotekBaseApi {
FASKESASAL: string;
};
}>({
name: this.name + 'List/Daftar',
path: `/daftarresep`,
method: 'POST',
data
Expand Down
Loading