Limpiar los avisos de estilo
This commit is contained in:
+208
-103
@@ -17,18 +17,17 @@ from fhir.resources.R4B.capabilitystatement import CapabilityStatement
|
||||
from fhir.resources.R4B.operationoutcome import OperationOutcome
|
||||
from fhir.resources.R4B.resource import Resource
|
||||
|
||||
from core import catalog
|
||||
from core import catalog, models
|
||||
from core import fhir as f
|
||||
from core import measures as m
|
||||
from core import models
|
||||
from core.cacu import currency
|
||||
from core.cacu import currency, risk_series
|
||||
from core.cacu import reference_risk as reference
|
||||
from core.cacu import risk_series
|
||||
from core.domains import Domain, measures, part
|
||||
from core.follow_up import window_start
|
||||
from core.pipeline import ID_PATTERN
|
||||
from persistance import config_log, gold as gold_reads, readers
|
||||
from persistance import config_log, readers
|
||||
from persistance import fhir as reads
|
||||
from persistance import gold as gold_reads
|
||||
from persistance import measures as measure_reads
|
||||
from webapi.ingest import submit
|
||||
from webapi.runs import dagster
|
||||
@@ -47,10 +46,12 @@ def fhir(resource: Resource) -> Response:
|
||||
|
||||
def outcome(status: int, text: str) -> Response:
|
||||
code = {404: "not-found", 409: "conflict"}.get(status, "invalid")
|
||||
issue = {"severity": "error", "code": code,
|
||||
"diagnostics": text} # fmt: skip
|
||||
return Response(OperationOutcome(issue=[issue]).model_dump_json(exclude_none=True),
|
||||
status_code=status, media_type=FHIR_JSON) # fmt: skip
|
||||
issue = {"severity": "error", "code": code, "diagnostics": text}
|
||||
return Response(
|
||||
OperationOutcome(issue=[issue]).model_dump_json(exclude_none=True),
|
||||
status_code=status,
|
||||
media_type=FHIR_JSON,
|
||||
)
|
||||
|
||||
|
||||
def _clinical(domain: Domain):
|
||||
@@ -79,19 +80,31 @@ def _history(domain: Domain, persons: list[str]) -> dict[str, list[dict]]:
|
||||
def _risks(domain: Domain, persons: list[str], cutoff: date) -> list[dict]:
|
||||
"""The models' risks that still apply to these persons at the cut-off, without those of
|
||||
models for development only."""
|
||||
rows = [r for r in reads.rows(domain.value, "risk", persons=persons)
|
||||
if r["model"] not in models.DEVELOPMENT] # fmt: skip
|
||||
rows = [
|
||||
r
|
||||
for r in reads.rows(domain.value, "risk", persons=persons)
|
||||
if r["model"] not in models.DEVELOPMENT
|
||||
]
|
||||
history = _history(domain, persons)
|
||||
gone = {person: currency.withheld(found, cutoff) for person, found in history.items()}
|
||||
return [r for r in rows if r["person_id"] not in gone or gone[r["person_id"]][2] is None
|
||||
or currency.current([r], history[r["person_id"]], cutoff)] # fmt: skip
|
||||
return [
|
||||
r
|
||||
for r in rows
|
||||
if r["person_id"] not in gone
|
||||
or gone[r["person_id"]][2] is None
|
||||
or currency.current([r], history[r["person_id"]], cutoff)
|
||||
]
|
||||
|
||||
|
||||
def _noted(domain: Domain, rows: list[dict], cutoff: date) -> list[dict]:
|
||||
"""The rows, each with why some of her risks are withheld at the cut-off, if any are."""
|
||||
history = _history(domain, [r["person_id"] for r in rows])
|
||||
return [{**r, "risk_withheld": currency.withheld(history[r["person_id"]], cutoff)[2]}
|
||||
if r["person_id"] in history else r for r in rows] # fmt: skip
|
||||
return [
|
||||
{**r, "risk_withheld": currency.withheld(history[r["person_id"]], cutoff)[2]}
|
||||
if r["person_id"] in history
|
||||
else r
|
||||
for r in rows
|
||||
]
|
||||
|
||||
|
||||
def _page(count: int | None, offset: int) -> tuple[int, int]:
|
||||
@@ -101,8 +114,15 @@ def _page(count: int | None, offset: int) -> tuple[int, int]:
|
||||
return count, offset
|
||||
|
||||
|
||||
def bundle(request: Request, matches: list[Resource], total: int, count: int, offset: int,
|
||||
included: list[Resource] = (), applied: dict | None = None) -> Response: # fmt: skip
|
||||
def bundle(
|
||||
request: Request,
|
||||
matches: list[Resource],
|
||||
total: int,
|
||||
count: int,
|
||||
offset: int,
|
||||
included: list[Resource] = (),
|
||||
applied: dict | None = None,
|
||||
) -> Response:
|
||||
"""A searchset page of `matches`, with links to its neighbours. The links carry the
|
||||
parameters as applied (`applied`: defaults the server chose)."""
|
||||
base = str(request.base_url).rstrip("/") + request.url.path.rsplit("/", 1)[0]
|
||||
@@ -117,14 +137,21 @@ def bundle(request: Request, matches: list[Resource], total: int, count: int, of
|
||||
if offset > 0:
|
||||
links.append(link("previous", max(offset - count, 0)))
|
||||
groups = (("match", matches), ("include", included))
|
||||
entries = [{"fullUrl": f"{base}/{r.get_resource_type()}/{r.id}", "resource": r,
|
||||
"search": {"mode": mode}} for mode, group in groups for r in group] # fmt: skip
|
||||
entries = [
|
||||
{
|
||||
"fullUrl": f"{base}/{r.get_resource_type()}/{r.id}",
|
||||
"resource": r,
|
||||
"search": {"mode": mode},
|
||||
}
|
||||
for mode, group in groups
|
||||
for r in group
|
||||
]
|
||||
found = Bundle(type="searchset", total=total, link=links, entry=entries or None)
|
||||
return fhir(found)
|
||||
|
||||
|
||||
def _sliced(found: list, count: int, offset: int) -> list:
|
||||
return found[offset:offset + count] # fmt: skip
|
||||
return found[offset : offset + count]
|
||||
|
||||
|
||||
# --- Patient ---------------------------------------------------------------------------------
|
||||
@@ -167,9 +194,12 @@ def _reference_facts(domain: Domain, id: str, cutoff: date | None) -> tuple[dict
|
||||
|
||||
|
||||
@router.get("/Patient/{id}/$reference-risk", responses=_OK, response_class=Response)
|
||||
def reference_risk(domain: Domain, id: str,
|
||||
cutoff: date | None = Query(None, description="Only what was reported by this day"),
|
||||
sample: date | None = Query(None, description="The cytology's sample day")) -> Response: # fmt: skip
|
||||
def reference_risk(
|
||||
domain: Domain,
|
||||
id: str,
|
||||
cutoff: date | None = Query(None, description="Only what was reported by this day"),
|
||||
sample: date | None = Query(None, description="The cytology's sample day"),
|
||||
) -> Response:
|
||||
"""EXPERIMENTAL, off unless CACU_NCI_REFERENCE=1. The NCI/ASCCP CIN3+ reference risk of one
|
||||
patient's cytology by a cut-off, how it was resolved and, beside it, the institutional models'
|
||||
risks when they measure the same thing. Research only: not validated, not a recommendation."""
|
||||
@@ -180,21 +210,39 @@ def reference_risk(domain: Domain, id: str,
|
||||
index = str(r["index_date"])[:10]
|
||||
if index > day.isoformat():
|
||||
continue
|
||||
found = latest.setdefault(r["model"], {"model": r["model"], "index_date": index,
|
||||
"title": models.title(r["model"]), "predictions": []})
|
||||
found = latest.setdefault(
|
||||
r["model"],
|
||||
{
|
||||
"model": r["model"],
|
||||
"index_date": index,
|
||||
"title": models.title(r["model"]),
|
||||
"predictions": [],
|
||||
},
|
||||
)
|
||||
if index > found["index_date"]:
|
||||
found.update(index_date=index, predictions=[])
|
||||
if index == found["index_date"]:
|
||||
found["predictions"].append({"years": int(r["horizon_years"]), "p": r["probability"],
|
||||
"low": r["ci_low"], "high": r["ci_high"]})
|
||||
comparison = reference.compare(resolution, list(latest.values())) if resolution["horizons"] else []
|
||||
found["predictions"].append(
|
||||
{
|
||||
"years": int(r["horizon_years"]),
|
||||
"p": r["probability"],
|
||||
"low": r["ci_low"],
|
||||
"high": r["ci_high"],
|
||||
}
|
||||
)
|
||||
comparison = (
|
||||
reference.compare(resolution, list(latest.values())) if resolution["horizons"] else []
|
||||
)
|
||||
return fhir(f.reference_risk(resolution, comparison, reference.tables()))
|
||||
|
||||
|
||||
@router.get("/Patient/{id}/$risk-series", responses=_OK, response_class=Response)
|
||||
def cacu_risk_series(domain: Domain, id: str,
|
||||
cutoff: date | None = Query(None, description="Only what was reported by this day"),
|
||||
sample: date | None = Query(None, description="The cytology's sample day")) -> Response: # fmt: skip
|
||||
def cacu_risk_series(
|
||||
domain: Domain,
|
||||
id: str,
|
||||
cutoff: date | None = Query(None, description="Only what was reported by this day"),
|
||||
sample: date | None = Query(None, description="The cytology's sample day"),
|
||||
) -> Response:
|
||||
"""EXPERIMENTAL, off unless CACU_NCI_REFERENCE=1. The risk series her record can choose to
|
||||
draw: institutional models and NCI tables, by outcome, with the published intervals."""
|
||||
facts, day = _reference_facts(domain, id, cutoff)
|
||||
@@ -238,16 +286,22 @@ def _with_identity(domain: Domain, rows: list[dict]) -> list[dict]:
|
||||
for r in reads.rows(domain.value, "replaces", persons=persons):
|
||||
replaces.setdefault(r["replaced_by"], []).append(r["person_id"])
|
||||
return [
|
||||
{**r, "names": names.get(p, []), "identifiers": ids.get(p, []),
|
||||
"replaces": replaces.get(p, [])}
|
||||
for r in rows if (p := r["person_id"])
|
||||
] # fmt: skip
|
||||
{
|
||||
**r,
|
||||
"names": names.get(p, []),
|
||||
"identifiers": ids.get(p, []),
|
||||
"replaces": replaces.get(p, []),
|
||||
}
|
||||
for r in rows
|
||||
if (p := r["person_id"])
|
||||
]
|
||||
|
||||
|
||||
def _folded(text: str) -> str:
|
||||
"""Lower case without accents: how names are compared."""
|
||||
return "".join(c for c in unicodedata.normalize("NFKD", text.casefold())
|
||||
if not unicodedata.combining(c)) # fmt: skip
|
||||
return "".join(
|
||||
c for c in unicodedata.normalize("NFKD", text.casefold()) if not unicodedata.combining(c)
|
||||
)
|
||||
|
||||
|
||||
def _matches(row: dict, name: str | None, identifier: str | None) -> bool:
|
||||
@@ -255,13 +309,17 @@ def _matches(row: dict, name: str | None, identifier: str | None) -> bool:
|
||||
`identifier` (token: `[system|]value`, the value's case ignored)."""
|
||||
if name:
|
||||
words = _folded(name).split()
|
||||
if not any(all(any(w.startswith(q) for w in _folded(n).split()) for q in words)
|
||||
for n in row["names"]): # fmt: skip
|
||||
if not any(
|
||||
all(any(w.startswith(q) for w in _folded(n).split()) for q in words)
|
||||
for n in row["names"]
|
||||
):
|
||||
return False
|
||||
if identifier:
|
||||
system, _, value = identifier.rpartition("|")
|
||||
if not any((not system or s == system) and v.casefold() == value.strip().casefold()
|
||||
for s, v in row["identifiers"]): # fmt: skip
|
||||
if not any(
|
||||
(not system or s == system) and v.casefold() == value.strip().casefold()
|
||||
for s, v in row["identifiers"]
|
||||
):
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -323,8 +381,9 @@ def search_patient(
|
||||
if birthdate:
|
||||
rows = [r for r in rows if all(_born(r, b) for b in birthdate)]
|
||||
if name or identifier:
|
||||
found = {r["person_id"] for r in _with_identity(domain, rows)
|
||||
if _matches(r, name, identifier)} # fmt: skip
|
||||
found = {
|
||||
r["person_id"] for r in _with_identity(domain, rows) if _matches(r, name, identifier)
|
||||
}
|
||||
rows = [r for r in rows if r["person_id"] in found]
|
||||
persons = [r["person_id"] for r in rows]
|
||||
risks: dict[str, list[dict]] = {}
|
||||
@@ -335,12 +394,14 @@ def search_patient(
|
||||
rows = fu.ordered(rows, sort, risks, horizon)
|
||||
page = _sliced(rows, count, offset)
|
||||
mine = {r["person_id"] for r in page}
|
||||
included = _included(domain, revinclude, include, sorted(mine), at,
|
||||
{p: v for p, v in risks.items() if p in mine}) # fmt: skip
|
||||
included = _included(
|
||||
domain, revinclude, include, sorted(mine), at, {p: v for p, v in risks.items() if p in mine}
|
||||
)
|
||||
applied = {"follow-up-cutoff": at.isoformat()} if window is not None else None
|
||||
patients = [f.patient(r, fu.STATUS_SYSTEM) for r in _with_identity(domain, _noted(domain, page, at))]
|
||||
return bundle(request, patients, len(rows), count, offset, included,
|
||||
applied) # fmt: skip
|
||||
patients = [
|
||||
f.patient(r, fu.STATUS_SYSTEM) for r in _with_identity(domain, _noted(domain, page, at))
|
||||
]
|
||||
return bundle(request, patients, len(rows), count, offset, included, applied)
|
||||
|
||||
|
||||
_COMPARE = {"gt": operator.gt, "ge": operator.ge, "lt": operator.lt, "le": operator.le}
|
||||
@@ -355,8 +416,14 @@ def _born(row: dict, asked: str) -> bool:
|
||||
return row["birth_date"] is not None and compare(str(row["birth_date"])[:10], str(day))
|
||||
|
||||
|
||||
def _included(domain: Domain, revinclude: list[str], include: list[str], persons: list[str],
|
||||
at: date, risks: dict[str, list[dict]]) -> list[Resource]: # fmt: skip
|
||||
def _included(
|
||||
domain: Domain,
|
||||
revinclude: list[str],
|
||||
include: list[str],
|
||||
persons: list[str],
|
||||
at: date,
|
||||
risks: dict[str, list[dict]],
|
||||
) -> list[Resource]:
|
||||
unknown = set(revinclude) - set(REVINCLUDES) | set(include) - {"DiagnosticReport:result"}
|
||||
if unknown:
|
||||
raise HTTPException(422, f"cannot include {sorted(unknown)}")
|
||||
@@ -405,8 +472,9 @@ def _studies(domain: Domain, persons: list[str], at: str) -> list[Resource]:
|
||||
def _risk_assessments(rows: list[dict]) -> list[Resource]:
|
||||
groups: dict[tuple, list[dict]] = {}
|
||||
for r in rows:
|
||||
groups.setdefault((r["model"], r["version"], r["person_id"], str(r["index_date"])),
|
||||
[]).append(r) # fmt: skip
|
||||
groups.setdefault(
|
||||
(r["model"], r["version"], r["person_id"], str(r["index_date"])), []
|
||||
).append(r)
|
||||
return [f.risk_assessment(g[0], g) for g in groups.values()]
|
||||
|
||||
|
||||
@@ -430,10 +498,13 @@ SUBJECT = "Patient/<id>, comma-separated"
|
||||
|
||||
|
||||
@router.get("/DiagnosticReport", responses=_OK, response_class=Response)
|
||||
def search_diagnostic_report(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_diagnostic_report(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""The domain's reports (each study of the catalog with a report), as known by the last
|
||||
day with data."""
|
||||
return _study_search("DiagnosticReport", request, domain, subject, _count, _offset)
|
||||
@@ -448,28 +519,37 @@ def _study_search(kind: str, request, domain, subject, count, offset) -> Respons
|
||||
|
||||
|
||||
@router.get("/Encounter", responses=_OK, response_class=Response)
|
||||
def search_encounter(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_encounter(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""Consultations: each study of the catalog without a report, as an encounter."""
|
||||
return _study_search("Encounter", request, domain, subject, _count, _offset)
|
||||
|
||||
|
||||
@router.get("/Observation", responses=_OK, response_class=Response)
|
||||
def search_observation(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_observation(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""Every result of the domain's reports, one per field of the catalog."""
|
||||
return _study_search("Observation", request, domain, subject, _count, _offset)
|
||||
|
||||
|
||||
@router.get("/Condition", responses=_OK, response_class=Response)
|
||||
def search_condition(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_condition(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""What clinical notes diagnosed (CaMa: and each recurrence)."""
|
||||
|
||||
def build(rows):
|
||||
@@ -479,10 +559,13 @@ def search_condition(request: Request, domain: Domain,
|
||||
|
||||
|
||||
@router.get("/Procedure", responses=_OK, response_class=Response)
|
||||
def search_procedure(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_procedure(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""The procedures the domain's timeline infers (CaCu: colposcopies and treatments;
|
||||
CaMa: each treatment, by its kind)."""
|
||||
|
||||
@@ -493,10 +576,13 @@ def search_procedure(request: Request, domain: Domain,
|
||||
|
||||
|
||||
@router.get("/RiskAssessment", responses=_OK, response_class=Response)
|
||||
def search_risk_assessment(request: Request, domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_risk_assessment(
|
||||
request: Request,
|
||||
domain: Domain,
|
||||
subject: str | None = Query(None, description=SUBJECT),
|
||||
_count: int | None = Query(None),
|
||||
_offset: int = Query(0),
|
||||
) -> Response:
|
||||
"""The champion models' risks, one per model and index date."""
|
||||
return _clinical_search("risk", _risk_assessments, request, domain, subject, _count, _offset)
|
||||
|
||||
@@ -518,8 +604,9 @@ def read_measure(domain: Domain, id: str) -> Response:
|
||||
|
||||
|
||||
@router.get("/Measure", responses=_OK, response_class=Response)
|
||||
def search_measure(request: Request, domain: Domain, _count: int | None = Query(None),
|
||||
_offset: int = Query(0)) -> Response: # fmt: skip
|
||||
def search_measure(
|
||||
request: Request, domain: Domain, _count: int | None = Query(None), _offset: int = Query(0)
|
||||
) -> Response:
|
||||
"""Every measure of the domain (none for a domain without them yet)."""
|
||||
count, offset = _page(_count, _offset)
|
||||
found = [f.measure(x, domain.value) for x in measures(domain).values()]
|
||||
@@ -588,9 +675,16 @@ def post_bundle(
|
||||
raise HTTPException(404, f"no pipeline {sender} to place what it sends")
|
||||
readers.receive(sender, bundle)
|
||||
run_id = submit(client, sender)
|
||||
entries = [{"response": {"status": "202 Accepted", "location":
|
||||
f"{e.resource.get_resource_type()}/{e.resource.id}"}}
|
||||
for e in parsed.entry or [] if e.resource is not None] # fmt: skip
|
||||
entries = [
|
||||
{
|
||||
"response": {
|
||||
"status": "202 Accepted",
|
||||
"location": f"{e.resource.get_resource_type()}/{e.resource.id}",
|
||||
}
|
||||
}
|
||||
for e in parsed.entry or []
|
||||
if e.resource is not None
|
||||
]
|
||||
answer = Bundle(type="batch-response", entry=entries or None)
|
||||
found = fhir(answer)
|
||||
found.status_code = 202
|
||||
@@ -616,37 +710,48 @@ def metadata(request: Request, domain: Domain) -> Response:
|
||||
_, kind, *rest = path.split("/")
|
||||
if rest and rest[-1].startswith("$"): # an operation, not a search
|
||||
continue # its parameters are not search parameters
|
||||
if kind == "metadata" or (kind != "Measure" and kind != "MeasureReport"
|
||||
and not clinical): # fmt: skip
|
||||
if kind == "metadata" or (kind != "Measure" and kind != "MeasureReport" and not clinical):
|
||||
continue
|
||||
entry = resources.setdefault(kind, {"type": kind, "interaction": [], "searchParam": []})
|
||||
if kind == "Patient" and not rest:
|
||||
entry |= {"searchInclude": ["DiagnosticReport:result"],
|
||||
"searchRevInclude": list(REVINCLUDES)} # fmt: skip
|
||||
entry |= {
|
||||
"searchInclude": ["DiagnosticReport:result"],
|
||||
"searchRevInclude": list(REVINCLUDES),
|
||||
}
|
||||
entry["interaction"].append({"code": "read" if rest else "search-type"})
|
||||
for param in route.dependant.query_params:
|
||||
name = param.alias
|
||||
if name.startswith("_") and name != "_id":
|
||||
continue
|
||||
declared = f.SEARCH_PARAMETERS.get(name)
|
||||
entry["searchParam"].append({
|
||||
"name": name,
|
||||
"type": declared[1] if declared else _STANDARD[name],
|
||||
**({"definition": f"{f.BASE}/SearchParameter/{name}"} if declared else {}),
|
||||
}) # fmt: skip
|
||||
statement = CapabilityStatement.model_validate({
|
||||
"resourceType": "CapabilityStatement",
|
||||
"status": "active",
|
||||
"date": date.today().isoformat(),
|
||||
"kind": "instance",
|
||||
"fhirVersion": f.FHIR_VERSION,
|
||||
"format": ["json"],
|
||||
"implementation": {"description": f"ISSSTELEON {domain.value}",
|
||||
"url": str(request.base_url).rstrip("/") + f"/{domain.value}/fhir"},
|
||||
"rest": [{"mode": "server",
|
||||
"resource": [{k: v for k, v in r.items() if v} for r in resources.values()],
|
||||
**({"interaction": system} if system else {})}],
|
||||
}) # fmt: skip
|
||||
entry["searchParam"].append(
|
||||
{
|
||||
"name": name,
|
||||
"type": declared[1] if declared else _STANDARD[name],
|
||||
**({"definition": f"{f.BASE}/SearchParameter/{name}"} if declared else {}),
|
||||
}
|
||||
)
|
||||
statement = CapabilityStatement.model_validate(
|
||||
{
|
||||
"resourceType": "CapabilityStatement",
|
||||
"status": "active",
|
||||
"date": date.today().isoformat(),
|
||||
"kind": "instance",
|
||||
"fhirVersion": f.FHIR_VERSION,
|
||||
"format": ["json"],
|
||||
"implementation": {
|
||||
"description": f"ISSSTELEON {domain.value}",
|
||||
"url": str(request.base_url).rstrip("/") + f"/{domain.value}/fhir",
|
||||
},
|
||||
"rest": [
|
||||
{
|
||||
"mode": "server",
|
||||
"resource": [{k: v for k, v in r.items() if v} for r in resources.values()],
|
||||
**({"interaction": system} if system else {}),
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
return fhir(statement)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user