npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

soyba-lib

v2.0.0

Published

Thư viện YBA (Sổ Y Bạ) - Chuẩn kết nối HIS V3.0 tinh gọn

Downloads

258

Readme

soyba-lib (v2.0.0)

Thư viện YBA (Sổ Y Bạ) phục vụ tích hợp và truy vấn lịch sử khám bệnh, hồ sơ bệnh án giữa Kiosk / Backend và HIS bệnh viện.

Hỗ trợ 100% Đặc tả kỹ thuật Sổ Y Bạ v3.0 (14/10/2026):

  • Tối ưu chỉ còn 2 API cốt lõi (/api/yba và /api/yba/kq).
  • Phục vụ cơ chế Direct Passthrough (Live Query): Gọi trực tiếp HIS theo thời gian thực, không lưu hay phụ thuộc cache database.

1. Định danh hỗ trợ

  • CCCD: Căn cước công dân (ưu tiên số 1 khi truy vấn)
  • MA_BN: Mã bệnh nhân trên HIS (dùng khi không có CCCD)
  • MA_LK: Mã đợt điều trị / lần khám duy nhất
  • MA_BA: Mã hồ sơ bệnh án (mới trong v3.0)

2. API v3.0 Chuẩn

2.1. API 01: Lấy danh sách lần khám & hồ sơ bệnh án

Endpoint: GET /api/yba?CCCD=... hoặc ?MA_BN=...

import YBAClient from 'soyba-lib';

const client = new YBAClient({
  baseUrl: process.env.API_SOYBA,
  apiKey: process.env.API_KEY,
  timeout: 5000
});

// Truy vấn theo CCCD (hoặc ma_bn nếu không có CCCD)
const result = await client.getYBaHistory({ cccd: '001000000000' });

console.log(result.lanKham);    // Danh sách các đợt khám (MA_LK)
console.log(result.hoSoBenhAn); // Danh sách hồ sơ bệnh án (MA_BA, IsNoiTru)
console.log(result.visits);     // Alias trỏ về lanKham

2.2. API 02: Lấy chi tiết lần khám hoặc phiếu khám bệnh án

Endpoint: GET /api/yba/kq?MA_LK=... hoặc ?MA_BA=...

// Cách 1: Lấy chi tiết 4 nhóm (thuoc, dvkt, cls, phieuKham) theo MA_LK
const visitDetail = await client.getChiTietLanKham({ ma_lk: '26PK00000001' });
console.log(visitDetail.data.thuoc);
console.log(visitDetail.data.dvkt);
console.log(visitDetail.data.cls);
console.log(visitDetail.data.phieuKham);

// Cách 2: Lấy danh sách phiếu khám theo Hồ sơ bệnh án MA_BA
const recordDocs = await client.getPhieuKhamHoSo({ ma_ba: 'BA0000000001' });
console.log(recordDocs.data.phieuKham);

3. Danh mục 11 LOAI_PHIEU_ENUM (v3.0)

import { LOAI_PHIEU_ENUM } from 'soyba-lib';

// Gồm 11 loại phiếu chuẩn hóa:
// - KET_QUA_XET_NGHIEM
// - KET_QUA_CHUP_CHIEU
// - DON_THUOC
// - GIAY_CHUNG_NHAN_THUONG_TICH
// - GIAY_NGHI_BHXH
// - GIAY_CHUNG_NHAN_PTTT
// - TOM_TAT_HSBA
// - GIAY_CHUNG_SINH
// - GIAY_CHUNG_TU
// - GIAY_RA_VIEN
// - BANG_KE_HOA_DON