Files
go-ohif-proxy/README.md

5.3 KiB

GO-OHIF-Proxy

1. Gambaran Umum

Tujuan

App ini dibuat untuk menyalurkan dicomWeb request dari OHIF ke Google Healthcare. Proxy berperan hanya sebagai authenticator ke Google dengan service-account.json, tanpa merubah / menambah request

Berikut adalah cara clone project ini:

2. Alur Kerja Aplikasi

+----------------+      +----------------+      +----------------------+
|                |      |                |      |                      |
|  OHIF Viewer   |----->| GO-OHIF-Proxy |----->| Google Healthcare    |
|  (Web Client)  |<-----|                |<-----| DICOM API            |
|                |      |                |      |                      |
+----------------+      +----------------+      +----------------------+
  1. Permintaan Klien: OHIF Viewer mengirimkan permintaan DICOMweb (misalnya, untuk mengambil studi).
  2. Pemrosesan Proxy:
    • Proxy mencegat permintaan.
    • Menambahkan header autentikasi yang sesuai.
    • Meneruskan permintaan ke Google Cloud Healthcare API.
  3. Pemrosesan Google Cloud: Healthcare API memproses permintaan DICOM.
  4. Penanganan Respons: Proxy meneruskan respons kembali ke klien.

2b. Arsitektur

go-ohif-proxy/
│
├── cmd/
│   └── server/           # Application entry point
│       └── main.go       # Main server initialization
│
├── config/               # Configuration management
│   ├── config.go         # Configuration loader
│   └── config.yaml       # Application configuration
│
├── credentials/          # Authentication credentials
│   └── service-account.json  # Google Cloud service account
│
├── internal/
│   ├── api/              # API endpoints
│   │   ├── handler.go    # HTTP request handlers
│   │   ├── middleware.go # Request middleware
│   │   └── routes.go     # API route definitions
│   │
│   ├── auth/             # Authentication services
│   │   └── google.go     # Google Cloud authentication
│   │
│   ├── proxy/            # Proxy service
│   │   └── dicomweb.go   # DICOMweb request handling
│   │
│   └── utils/            # Utility functions
│       ├── http.go       # HTTP utilities
│       └── logger.go     # Logging functionality
│
├── test/                 # Testing resources
│   └── http/             # HTTP test requests
│
├── Dockerfile            # Container definition
├── docker-compose.yml    # Multi-container orchestration
├── go.mod                # Go module definition
├── go.sum                # Module dependency checksums
└── README.md             # Project documentation

3. Instalasi dan Penggunaan

Prasyarat

  • Go versi 1.19 atau lebih tinggi.
  • Akun Google Cloud dengan Healthcare API diaktifkan.
  • Kredensial akun layanan dengan akses ke DICOM store.

Clone dan Setup

# Clone repositori
git clone https://devone.aplikasi.web.id/gitea/mario/go-ohif-proxy.git
cd go-ohif-proxy

# Install dependencies
go mod download

Konfigurasi

  1. Salin file konfigurasi contoh:

    cp config/config.yaml.example config/config.yaml
    
  2. Edit config/config.yaml sesuai kebutuhan:

    server:
      port: 5555
      read_timeout_seconds: 30
      write_timeout_seconds: 30
      idle_timeout_seconds: 60
    
    log_level: "info"  # debug, info, warn, error
    
    google:
      project_id: "id-proyek-gcp-anda"
      location: "lokasi-anda"
      dataset: "nama-dataset-anda"
      dicom_store: "nama-dicom-store-anda"
      credentials_path: "./credentials/service-account.json"
    
    allowed_origins:
      - "http://localhost:3000"  # URL OHIF Viewer
    
  3. Letakkan kredensial akun layanan Google Cloud Anda di credentials/service-account.json.

Menjalankan Aplikasi

Build dan Jalankan Secara Langsung

# Build aplikasi
go build -o ohif-proxy ./cmd/server

# Jalankan aplikasi
./ohif-proxy

Menggunakan Docker

# Build image Docker
docker build -t go-ohif-proxy .

# Jalankan dengan Docker
docker run -p 5555:5555 -v $(pwd)/config:/app/config -v $(pwd)/credentials:/app/credentials go-ohif-proxy

Menggunakan Docker Compose

docker-compose up

Run Aplikasi Tanpa Build

  1. Transfer ./ohif-proxy ke server tujuan. Contoh:
    scp ohif-proxy pacs@152.42.173.210:/home/pacs/google-ohif-proxy
    
  2. Pastikan server tujuan terinstall go versi >1.19. Cek dengan:
  3. Buat direktori:
    mkdir -p ~/google-ohif-proxy
    mkdir -p ~/google-ohif-proxy/config
    mkdir -p ~/google-ohif-proxy/credentials
    
  4. Tambahkan config.go dan config.yaml.
    scp -r config/* pacs@152.42.173.210:/home/pacs/google-ohif-proxy/config/
    
  5. Tambahkan credential /credentials/service-account.json
    nano credentials/service-account.json
    # atau
    # scp dari local
    

Pengujian

Aplikasi ini menyertakan permintaan HTTP uji di direktori test/http yang dapat digunakan dengan klien REST seperti ekstensi REST Client di VSCode.

# Jalankan pengujian yang disertakan
make test

Untuk informasi lebih lanjut tentang OHIF: https://ohif.org/ Untuk informasi lebih lanjut tentang Google Cloud Healthcare API: https://cloud.google.com/healthcare