Librería para interactuar con Google Healthcare API utilizando NestJS.
Módulo NestJS para integración con Google Cloud Healthcare API (FHIR) que simplifica las operaciones CRUD y manejo de recursos FHIR.
``bash`
npm install uma-healthcare-apio
yarn add uma-healthcare-api
1. Variables de entorno (en tu .env):`env`
PROJECT_ID=tu-project-id
HEALTHCARE_FHIR_STORE=projects/{project-id}/locations/{region}/datasets/{dataset-id}/fhirStores/{fhir-store-id}
2. Importar módulo (en tu app.module.ts):
`typescript
import { HealthcareModule } from 'uma-healthcare-api';
@Module({
imports: [
HealthcareModule.forRoot({
fhirStore: process.env.HEALTHCARE_FHIR_STORE,
projectId: process.env.PROJECT_ID
}),
],
})
export class AppModule {}
`
typescript
const newPatient: FhirPatient = {
resourceType: 'Patient',
name: [{ given: ['John'], family: 'Doe' }],
// ...otros campos
};await this.healthcareService.create(newPatient);
`$3
`typescript
// Obtener por ID
const patient = await this.healthcareService.findOne('123', 'Patient');// Buscar con filtros
const results = await this.healthcareService.findAll(
'Patient',
'name=Doe'
);
`$3
`typescript
const updates: OpPatch[] = [
{ op: 'replace', path: '/name/0/family', value: 'Smith' }
];await this.healthcareService.update('123', 'Patient', updates);
`Estructura del Módulo 📂
`
healthcare-api/
├── src/
│ ├── interfaces/ # Interfaces
│ ├── types/ # Tipos
│ ├── utils/ # Herramientas de conversión
│ ├── healthcare.module.ts
│ └── healthcare.service.ts
`Manejo de Errores ⚠️
El módulo incluye:
- Logs detallados de operaciones
- Tipado específico para errores de GCP
- Reconocimiento automático de errores 404
- Transformación de respuestas binarias a JSONEjemplo de manejo:
`typescript
try {
await this.healthcareService.create(resource);
} catch (error) {
if (error instanceof HealthcareErrorResponse) {
console.error('Error específico de GCP:', error.response.data);
}
// Manejo personalizado
}
``