MedGuard · Guide
We need to output HTML fragment only, starting with the opening block exactly:

What is MedGuard?

Last updated: 2026-09-16

then the rest. Must keep the opening

exactly as first element? The instruction: "Keep the provided opening

EXACTLY as the first element. Do not delete the direct answer." But the opening block given is

What is MedGuard?

. Actually they say opening block (KEEP VERBATIM as first content):

What is MedGuard?

. Then later they say "Keep the provided opening

EXACTLY as the first element. Do not delete the direct answer." Possibly they refer to the opening

from existing thin body? The existing thin body after the heading includes a

Catch unsafe AI medical advice before a patient reads it.

. So we must keep that

exactly as first element after the heading? The opening block is the heading; then we must keep the provided opening

exactly as the first element (i.e., after heading). So we need to output:

What is MedGuard?

Catch unsafe AI medical advice before a patient reads it.

Then continue with rest. We must not include doctype, html/head/body, no FAQ section, no Related, no CTA. Also must not include the existing thin body's FAQ etc. We need to replace with our thickened content. We need 6-8

sections with

subpoints, lists, and ONE table. Include an

What this is NOT

honesty section (no guarantee / 100% / never miss). End with

References

we keep. We need to produce a thickened HTML fragment. Let's plan sections: After opening

, we can have:

Why a safety layer for patient‑facing AI

...

Then maybe

How MedGuard works

with subpoints

Rule ingestion

,

Real‑time validation

,

Flagging and blocking

. Include lists. Then

Core components

with subpoints. Then

Integration workflow

with subpoints. Then

Safety rule sources

with subpoints referencing OWASP and NIST. Then

What this is NOT

honesty section. Then

How MedGuard works

Rule ingestion

I collect safety rules from trusted sources such as drug interaction databases, clinical guidelines, and regulatory advisories. Each rule is expressed as a simple pattern: for example, “if the text mentions ‘warfarin’ and also mentions ‘aspirin’ without mentioning ‘INR monitoring’, flag”. I store these patterns in a JSON file that the service loads at start‑up.

Real‑time validation

When the AI returns a response, the service splits the text into sentences and runs each sentence through the pattern matcher. The matcher uses regular expressions that are pre‑compiled, so the evaluation takes a few milliseconds per sentence. I keep the matcher stateless so multiple requests can be processed in parallel.

Flagging and blocking

If any sentence matches a rule, the service creates a flag object that includes the rule ID, the matched sentence, and a suggested action. The UI can choose to show the flag beside the original text, replace the sentence with a safe placeholder, or block the entire message and show a fallback warning. I log every flag for later audit.

We could add a list under each h3 maybe. But we need lists somewhere; we can add a list of rule sources. Now section 3: Core components

Core components

Rule engine

The rule engine is the heart of MedGuard. It loads rule files, compiles patterns, and provides a simple API: evaluate(text) -> list of flags. I wrote it in Python because the ecosystem offers good regex performance and easy packaging.

API wrapper

Around the rule engine I built a thin HTTP wrapper that accepts JSON payloads with the AI response and returns JSON with flags or a cleaned version. The wrapper enforces a maximum request size of 64 KB to avoid abuse.

UI integration kit

To help developers add MedGuard to their apps I provide a small JavaScript snippet that intercepts fetch calls to the AI endpoint, sends the response to the MedGuard API, and updates the DOM based on the returned flags. The snippet is under 5 KB gzipped.

We could add a table here: maybe a table of component vs responsibility. Let's add a table after the h3s.
ComponentResponsibility
Rule engineLoads, compiles, matches safety patterns
API wrapperHandles HTTP, enforces limits, returns flags
UI kitCalls API, shows warnings, allows overrides
That's our ONE table. Now section 4: Integration workflow

Integration workflow

We'll describe steps with maybe an ordered list. We'll need to include inline references to the allowed URLs at least twice. We'll reference OWASP and NIST here maybe. We'll write paragraphs. We'll also include a list. Let's write.

Integration workflow

Safety rule sources

I curate rules from three main categories:

Each rule is written as a plain‑text pattern that can be evaluated with regular expressions. For example, a rule for NSAID use in patients with kidney disease might look like: “if the text mentions ‘ibuprofen’ and also mentions ‘creatinine > 1.5’ without mentioning ‘dose adjustment’, flag”.

I keep the rule set versioned in a Git repository so any change can be reviewed and rolled back if needed. The version number is included in every API response so downstream systems know which rule set was applied.

Now section 6: What this is NOT We need honesty section: no guarantee / 100% / never miss. We'll write:

What this is NOT

MedGuard does not promise to catch every possible unsafe suggestion. The rule‑based approach can miss novel phrasing or context‑dependent hazards that are not captured in the current rule set. I do not claim 100 % coverage, and I advise clinicians to treat the output as a decision‑support aid, not a replacement for professional judgment.

It is not a diagnostic tool. The system does not attempt to infer a patient’s condition or recommend a treatment plan; it only checks the AI‑generated text against known safety patterns.

It does not replace the need for a qualified clinician to review high‑risk messages. If a flag appears, the clinician should still evaluate the situation and make the final call.

Now section 7: References We need

References