I'm working on a project for our healthcare clinic's software and could use some guidance. For regulatory and historical purposes, patient charts need to remain as "static" records—representing exactly what the provider saw and entered during a specific visit. However, in our system, patient charts are dynamic and consist of a series of forms tied to a parent note type.
For example, if a patient is seen for pain, there could be several forms included in the note type, such as an HPI, pain therapy forms, and pain assessments. Administrators can update these notes and forms, including the controls within the forms, to improve charting workflows or meet new requirements. This flexibility is useful but complicates maintaining historical integrity.
When notes and forms are updated, I need to ensure that providers can view previous visits exactly as they were documented, even if the structure of the notes and forms has since changed.
Example:
Visit 1: Provider A uses
Note.v1
withForm A.v1
.Later, an administrator updates the note to
Note.v2
and the form toForm A.v2
.Visit 2: Provider A now uses the updated
Note.v2
.However, when revisiting Visit 1, Provider A should see the original
Note.v1
andForm A.v1
, along with the historical data values from that visit.
Currently, this functionality exists in our system but was poorly implemented by the previous developers. They stored large chunks of HTML in string fields in the relational database and injected them as views. This made maintenance and data synchronization a nightmare, not to mention introducing risks due to improper handling of data.
I want to move away from that approach by rendering forms server-side based on a structured data model, abstracting away raw HTML. This would simplify maintenance, allow better state management, and avoid the need to parse the DOM to retrieve data (yes, that's what they did). While the original approach accidentally served as a snapshot mechanism for form versioning, it’s not scalable or maintainable.
I'm torn between two approaches:
Versioning Schema for Each Mutable Item
Create a versioning schema where every change to a note or form generates a new version and archives the previous one. Visits would be tied to specific versions of notes and forms, allowing the system to reconstruct views from the data model during the relevant time period.
Pros:
Robust and enterprise-friendly.
Accurate point-in-time reconstructions.
Cons:
Requires manual synchronization across multiple tables.
Complex to implement given my current tech stack (ASP.NET 3.1, EF Core 3.1.4, SQL Server 2017).
Temporal tables aren't an option without major refactoring.
JSON Snapshots for Each Visit
Capture a JSON snapshot of the form structure at the start of each new visit and store it with the visit record. When accessing a historical visit, the system would reconstruct the view using the JSON configuration.
Pros:
Simple to implement.
Efficient for real-world scenarios, as JSON deserialization is lightweight for this use case.
Cons:
- Slightly redundant storage.
I'm leaning towards option 2 for its simplicity (I'm a solo engineer). I would have loved to use modern tooling and all its conveniences but updating to an LTS framework isn't in the works right now.