Skip to content

Andrew's style: what changed and why

I used the USPTO code as the reference for organization and naming. I kept the clinical rules, HTTP contracts, migration files and captured patient JSON intact. This is a style pass plus an explanatory data-model page, not a new clinical implementation.

The evidence below comes from ANDREW-STYLE-GUIDE.md. The Vue example is a small scaffold; the Angular repo provides the stronger evidence for separate services and models.

Area How Andrew writes it (USPTO evidence) What the demo does now Same or Different Why
Layers Services/PatentService.cs, Data/UsptoData.cs, Models/Entities/Patent.cs, sibling Interfaces/ folders Services, data access, helpers and models have separate files and folders. The API calls IClinicalService; sync uses IUnitOfWork. Same The entry point is small and the work has a named owner.
Namespace and file layout File-scoped Uspto.*; one type per file File-scoped namespaces; top-level production types split into files. Existing EF entity namespaces stay FhirDemo.Data. Nested implementation-only types stay with their owner; top-level Program remains the host entry point. Different Renaming EF entity identities would change the model snapshot. Nested parsers/coefficient helpers are not new public contracts.
Usings and braces Explicit usings, Allman braces, block methods Implicit usings disabled in src and tests; explicit imports and block-bodied production methods. Migration imports are explicit global usings so migration files remain untouched. Same Makes dependencies visible without rewriting migration history.
Locals and private fields var, target-typed new(), _camelCase, readonly dependencies Inferred locals where the inferred type is unchanged; readonly dependency fields. Mutable authentication token/expiry state remains mutable. Some explicitly typed numeric/multiple locals remain. Different Changing double x = 0 to var x = 0 changes its type. Token refresh needs mutable state.
Constructors and records Plain classes, ordinary constructors Production primary constructors replaced. Request/report/lakehouse result classes preserve init properties, constructor shape and explicit value equality. Clinical/risk records and SyncResult remain. Different ClinicalRecord, RawResource, RiskPatient and lab facts are copied with with in existing tests; OttehrIntakeTests compares SyncResult by value. The risk model family retains its existing value/copy contract.
Interfaces IPatentService, helpers and settings interfaces IClinicalService, ILakehouseReports, ISyncGate, ISyncService, ISyncServiceFactory, IUnitOfWork, settings and profiler interfaces. Pure static mapping/risk/formatting helpers and CLI entry points remain static. Different The injected stateful services now match the pattern. Converting every public static algorithm into a new injectable API is deferred to avoid changing existing consumers during a behavior-preserving pass.
Registration One fluent chain in Startup.cs AddFhirDemoServices contains the application registration chain. Framework hosting/auth/CORS registration stays in DemoApplication. Same One place owns application lifetimes. The sync gate and lakehouse reader remain singletons; the unit of work and clinical service remain scoped.
Settings Section-bound POCO and interface; capture IOptionsMonitor<T>.CurrentValue SourceSettings binds the Source section and is captured as ISourceSettings. Runtime root/provider are captured once in interface-backed RuntimeSettings. Different Source settings follow Andrew's pattern. Root/provider preserve the original host-time values instead of changing database/path selection during config reload.
Requests and responses *Request / *Response, init properties, empty nonnullable strings Named request/report/profile classes have init properties. Existing nullable allergy input and anonymous clinical JSON projections are retained. ReportItem keeps its existing name. Different Missing allergy fields must still fail the same validation, and projections must retain the same JSON shape/order and omit RawJson. Broader contract replacement is deferred, not claimed complete.
Persistence PatentContext : DbContext, IUnitOfWork, code-first migrations AppDbContext : DbContext, IUnitOfWork; sync and clinical services depend on the interface. Same Persistence is behind the same unit-of-work pattern.
Model configuration [Key], [StringLength], data annotations Existing Fluent API and migrations retained byte-for-byte in meaning; migration/snapshot files not edited. Different HasBaseType(null) is required for the separate concrete clinical tables. Table/column names, maximum lengths, indexes, composite intake key and generated-value behavior must not drift. The configuration inventory below states which mappings annotations could express.
HTTP entry points Azure Functions with thin functions ASP.NET Core minimal APIs in ClinicalEndpoints, calling IClinicalService Different This demo targets an ASP.NET Core REST API role. It keeps the thin entry-point/layered-service idea.
JSON JsonConvert System.Text.Json for application JSON; the existing Firely serializer for typed FHIR resources Different Keep the existing serializers and FHIR validation. No new serialization package or contract change.
Async Async suffix and last optional cancellation token Production Task methods and CLI local functions use Async and optional cancellationToken, propagated through async I/O. Test framework callbacks retain their required shapes. Same Cancellation reaches the database and HTTP calls.
EF reads Sync .Any() / .First() inside async services Async database queries; synchronous LINQ only over already-materialized/local collections Different Preserve nonblocking database access. A ChangeTracker/local collection query does not perform database I/O.
Errors Guard, log, friendly boundary message; lower-layer throw; Classic argument guards on sync/factory and profiler inputs; existing ProblemDetails boundary and specific validation/status codes retained. Structured sync completion logging added. Different A catch-all returning 400 or new blanket exception logging would change error semantics or risk leaking clinical/authentication content. Existing error handling remains authoritative.
Logging packages Serilog and Application Insights Existing ILogger<T>/host telemetry; no new Serilog or Application Insights package Different Keep tonight's dependency and telemetry behavior unchanged.
Comments Few comments; no XML docs or regions Keep FHIR eligibility, cursor, clinical provenance and security explanations; XML summaries converted to ordinary clinical/security comments; no regions Same Explain decisions that are easy to get wrong, not what each line does.
Test framework NUnit, Moq, AutoFixture, Bogus Existing xUnit suite retained, with fixture-derived profile and full risk-parity tests added Different Andrew explicitly allowed this fallback. A safe conversion requires one reviewed commit per file and a full suite after each. The required Clahadore gate is currently denied by the usage governor, even after a normal scan; no mixed-framework half-conversion or unused packages were introduced.
Vue components Vuetify 3; Vue example uses Options API; scaffold uses script setup Vuetify 3 and TypeScript retained; <script setup> with extracted views, models and services; two-space formatting Different Keep current typed composition and working state/cancellation behavior. The service organization is supported by Andrew's Angular sample.
HTTP in Vue Direct axios in Vue; HttpClient services in Angular Patient/report/sync service modules wrap the existing tested fetch adapter. New documentation assets use axios. Different Existing tests cover cancellation during body reads, stale responses, snapshot simulation and error redaction. Replacing that transport solely for appearance adds risk.
Security Front-end function key and app-only Graph credentials in the old examples No new keys or secrets; no browser credentials; existing server-only auth and URL protections retained Different A key shipped in a bundle is public. The new page uses local, synthetic artifacts only.
Concurrency Parallel.ForEach adding to a List in Patent.cs Existing sequential collection processing and singleton sync semaphore retained Different Avoid reproducing a shared-list race. No parallel mutation was introduced.
Retries Old UsptoData retries bad requests Existing retry allowlist retained; ordinary 4xx are not retried; existing 429 throttling handling remains Different Never add retries for validation/auth/client mistakes. Removing the existing 429 behavior would violate this pass's no-behavior-change rule.
Text files BOM/CRLF and usually no final newline Explicit UTF-8 files and final newlines; repository Git line-ending policy retained Different Do not churn migration bytes or rewrite the repository's line-ending policy just to imitate a Visual Studio default.
Language C# first Profiler, domain logic and backend are C#; existing Vue uses TypeScript Different Vue requires its existing browser toolchain. No Python or JavaScript substitute was added for backend profiling.

What I'd say if asked

  • Namespace and file layout: "I separated the layers without renaming EF's persisted model identities."
  • Locals and private fields: "I use var when it keeps the same type; refreshable token state cannot be readonly."
  • Constructors and records: "The DTOs are classes. I kept value models where existing copies and equality are part of the contract."
  • Interfaces: "The stateful services are injected. The pure mapping functions still have their established static API."
  • Settings: "Source settings use my monitor pattern. The database root and provider remain fixed for the host's lifetime."
  • Requests and responses: "I kept the existing JSON contract and null handling; I have not claimed every projection is a new DTO."
  • Model configuration: "I kept the database schema stable. The unusual inheritance mapping still needs Fluent API."
  • HTTP entry points: "The job calls for ASP.NET Core REST APIs, so I kept the functions thin in spirit and used minimal API endpoints."
  • JSON: "System.Text.Json already handles the application contract; Firely handles FHIR."
  • EF reads: "Async database reads avoid blocking request threads."
  • Errors: "Validation stays a client error and server failures stay server errors. I did not turn every failure into a 400."
  • Logging packages: "ILogger is already wired up. I did not add a new telemetry stack for a style change."
  • Test framework: "NUnit is my usual stack. I kept the passing xUnit suite rather than doing an unreviewed overnight framework migration."
  • Vue components: "I kept Vue 3's typed Composition API and organized the views and services the way I organize the work."
  • HTTP in Vue: "The existing transport has cancellation and snapshot tests. The services hide it, so a later axios migration can be reviewed independently."
  • Security: "No browser key is secret, so I did not copy that older deployment pattern."
  • Concurrency: "I kept collection writes sequential and sync mutually exclusive."
  • Retries: "Client errors are not transient. Existing throttling handling is a separate documented exception."
  • Text files: "The repository's file policy matters more than copying old editor defaults."
  • Language: "The data pipeline is C#. TypeScript stays at the Vue boundary."

Fluent API inventory: intentionally unchanged

Mapping Could annotations express it? Why retained here
Clinical HasBaseType((Type?)null) No equivalent annotation for this configuration Each concrete clinical type owns a separate table despite sharing CLR properties.
Eight clinical ToTable mappings Yes, per concrete type Keep inherited metadata and snapshot unchanged; do not introduce a base-table mapping.
Clinical Id key, SQL fhir_id, 64-character Id/PatientId/VersionId Yes: Key, Column, StringLength Preserve existing metadata exactly; shared-base annotations need a separate model-diff review.
PatientId indexes on clinical tables Yes, class-level Index per concrete entity Existing generated index names and table ownership remain unchanged.
Intake (ResponseId, Ordinal) key; lengths and PatientId index Yes, PrimaryKey/StringLength/Index Preserve composite key order, lengths and existing index metadata.
Sync state table, ResourceType key/length Yes Avoid snapshot changes in a style-only pass.
Source binding table, key, ValueGeneratedNever, 512-character identity Yes, with DatabaseGenerated(None) Preserve singleton identity and provider behavior.
Staging, quarantine, outbox table names Yes Existing migrations remain the schema authority.

No new migration is needed. No foreign keys, length restrictions, enum conversions, clinical defaults or persisted values were added. The existing ReportItem name, anonymous response projections, static helper APIs and xUnit framework are recorded differences, not completed conversions.