Panduan Cloud, Backend & Full Stack Engineer: Orkestrasi Telehealth Video Azure Communication Services (ACS) & Medplum FHIR

Spesialisasi Rekayasa Perangkat Lunak: Ditulis oleh Aldian Fazrihady — Senior Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend Engineer, AI Application Engineer & Full Stack Engineer.

1. Arsitektur Telehealth Berstandar HIPAA dengan Azure Communication Services (ACS) dan Medplum FHIR

Mengintegrasikan panggilan video real-time ke dalam platform kesehatan membutuhkan sinkronisasi ketat antara siklus hidup panggilan WebRTC di Azure Communication Services (ACS) dan model data klinis HL7 FHIR (Appointment, Encounter, Practitioner, dan Patient) di Medplum.

2. Penerbitan Token Identitas ACS di Backend & Manajemen State WebRTC di React/TypeScript

Sebagai Cloud Engineer, Backend Engineer, dan Full Stack Engineer, token akses ACS harus diterbitkan secara on-demand di sisi server dengan masa berlaku terbatas dan diikat ke referensi FHIR pengguna. Berikut adalah implementasi arsitektur dan kodenya:

import { AzureCommunicationTokenCredential } from '@azure/communication-common';
import { 
    CallWithChatComposite, 
    FluentThemeProvider, 
    createAzureCommunicationCallWithChatAdapter 
} from '@azure/communication-react';

const joinCall = useCallback(async (): Promise<void> => {
    if (!accessToken || !acsGroupId || !acsChatThreadId || !userId || !endpoint) return;

    setLoading(true);
    try {
        const tokenCredential = new AzureCommunicationTokenCredential(accessToken);
        const locator = {
            callLocator: { groupId: acsGroupId },
            chatThreadId: acsChatThreadId,
        };

        // Create unified ACS adapter
        const callAdapter = await createAzureCommunicationCallWithChatAdapter({
            userId: { communicationUserId: userId },
            displayName: patientName || 'Patient',
            credential: tokenCredential,
            endpoint,
            locator,
        });

        // Initially join with camera and microphone muted
        callAdapter.joinCall({ cameraOn: false, microphoneOn: false });
        setAdapter(callAdapter);
        setStep('waiting');
    } catch (err) {
        console.error('Failed to bootstrap ACS Adapter:', err);
        setError('Failed to initialize session.');
    } finally {
        setLoading(false);
    }
}, [accessToken, acsGroupId, acsChatThreadId, userId, endpoint]);
useEffect(() => {
    if (!adapter || step !== 'waiting') return;

    const onParticipantsJoined = (): void => {
        // Clinician joined - launch camera, unmute local mic, and start call
        adapter.startCamera().catch(console.error);
        adapter.unmute().catch(console.error);
        
        setStep('active-call');
        
        // Start call duration timer
        setElapsedSeconds(0);
        timerRef.current = setInterval(() => {
            setElapsedSeconds(prev => prev + 1);
        }, 1000);
    };

    adapter.on('callParticipantsJoined', onParticipantsJoined);
    return () => {
        adapter.off('callParticipantsJoined', onParticipantsJoined);
    };
}, [adapter, step]);
useEffect(() => {
    if (step !== 'post-call' || !appointmentId) return;

    const fetchClinicalNotes = async (): Promise<void> => {
        setLoadingNotes(true);
        try {
            const response = await fetch(botLambdaUrl, {
                method: 'POST',
                headers: { 'Content-Type': 'application/json' },
                body: JSON.stringify({
                    action: 'get-appointment-documents',
                    appointmentId,
                }),
            });
            const data = await response.json();
            if (data.success) {
                const notes = data.documents
                    .filter((d: any) => d.type === 'clinical-note')
                    .map((d: any) => ({
                        id: d.id,
                        title: d.title,
                        textContent: d.textContent,
                        date: d.date,
                    }));
                setClinicalNotes(notes);
            }
        } catch (err) {
            console.error('Failed to sync appointment notes:', err);
        } finally {
            setLoadingNotes(false);
        }
    };

    fetchClinicalNotes().catch(console.error);
}, [step, appointmentId]);

Ringkasan Arsitektur Produksi & Praktik Terbaik (Checklist Teknis)


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 25+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs