Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ testem.log
test-results/
.playwright-mcp/
/sql-on-fhir-*.png
/cms125-*.png
/sql-pipeline-*.png
/.claude/

# System files
.DS_Store
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { ClipboardManagerComponent } from './components/clipboard-manager/clipbo
import { VsacBrowserComponent } from './components/vsac-browser/vsac-browser.component';
import { FhirRegistryImporterComponent } from './components/fhir-registry-importer/fhir-registry-importer.component';
import { SqlOnFhirComponent } from './components/sql-on-fhir/sql-on-fhir.component';
import { sqlOnFhirGuard } from './components/sql-on-fhir/sql-on-fhir.guard';

export const routes: Routes = [
// Normal app routes
Expand Down Expand Up @@ -69,7 +70,7 @@ export const routes: Routes = [
{ path: 'guidelines', component: GuidelinesComponent },
{ path: 'guidelines/:id/testing', component: GuidelinesComponent },
{ path: 'guidelines/:id', component: GuidelinesComponent },
{ path: 'sql', component: SqlOnFhirComponent },
{ path: 'sql', component: SqlOnFhirComponent, canActivate: [sqlOnFhirGuard] },
{ path: 'about', component: AboutComponent },
{ path: 'clipboard', component: ClipboardManagerComponent },

Expand Down
20 changes: 20 additions & 0 deletions src/app/components/sql-on-fhir/sql-on-fhir.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Author: Eugene Vestel
//
// Route guard for the experimental SQL-on-FHIR workspace (Issue #23).
// Mirrors the navigation menu gate (experimental + developer flags) so that
// direct navigation to /sql also respects the feature flag rather than only
// hiding the menu entry. Remove this guard when the feature flag is lifted.

import { inject } from '@angular/core';
import { CanActivateFn, Router } from '@angular/router';
import { SettingsService } from '../../services/settings.service';

export const sqlOnFhirGuard: CanActivateFn = () => {
const settings = inject(SettingsService).settings();
const enabled = settings.experimental && settings.developer;
if (enabled) {
return true;
}
// Feature flag off — send the user back to the dashboard.
return inject(Router).createUrlTree(['/']);
};
22 changes: 16 additions & 6 deletions src/app/services/translation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import {
} from '@cqframework/cql/cql-to-elm';
import { CqlLocatorUtilsService } from './cql-locator-utils.service';

/**
* `CqlTranslator.toJson()` exists at runtime and in the package's
* `kotlin/cql-to-elm.d.ts`, but the `@cqframework/cql/cql-to-elm` subpath export
* ships only `.mjs` with no paired `types` entry, so the method isn't visible
* to consumers under bundler module resolution. Until that's fixed upstream
* (https://github.com/cqframework/clinical_quality_language/issues/1768) we
* narrow the translator through this minimal interface rather than a bare cast.
*/
interface ElmJsonEmitter {
toJson(): string;
}

export interface TranslationResult {
elmXml: string | null;
elmJson: string | null;
Expand Down Expand Up @@ -207,9 +219,8 @@ export class TranslationService {

let elmJson: string | null = null;
try {
// `toJson` exists at runtime per kotlin/cql-to-elm.d.ts but isn't picked
// up by the @cqframework/cql/cql-to-elm subpath resolution — cast through unknown.
elmJson = (translator as unknown as { toJson: () => string }).toJson();
// See ElmJsonEmitter above re: upstream type-export gap (#1768).
elmJson = (translator as unknown as ElmJsonEmitter).toJson();
} catch (e) {
console.warn('Failed to generate ELM JSON:', e);
}
Expand Down Expand Up @@ -273,9 +284,8 @@ export class TranslationService {

let elmJson: string | null = null;
try {
// `toJson` exists at runtime per kotlin/cql-to-elm.d.ts but isn't picked
// up by the @cqframework/cql/cql-to-elm subpath resolution — cast through unknown.
elmJson = (translator as unknown as { toJson: () => string }).toJson();
// See ElmJsonEmitter above re: upstream type-export gap (#1768).
elmJson = (translator as unknown as ElmJsonEmitter).toJson();
} catch (e) {
console.warn('Failed to generate ELM JSON:', e);
}
Expand Down