dana-medical-site/deploy/price_policy.py

48 lines
3.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Publication-only policy; never changes prices, services or medical records."""
import re
CONSULT = re.compile(r"^(?:(?:первичная|повторная|первичный|повторный|послеоперационная)\s+)?(консультац|консултац|при[её]м\s+(врача|хирурга|пластического))", re.I)
OPERATION = re.compile(r"операци|оперативн|эктоми|ектоми|резекц|пластик|лапарос|лапаротом|лапараскоп|лапаратом|иссечени|кольпораф|перинеораф|конизаци|циркумци|лигирован|обрезани|гернио|экс[тц]ирпац|шунтир|хирургия|гастрошунт|аденотом|тонзиллотом|полипотом|френулотом|нефростом|остеосинтез|остеотом|варикоцеле|ампутац|гистероскоп|пекси|ректоцеле|вылущивани|дефлорац|эксцизи|перевязка\s+маточных\s+труб", re.I)
ANCILLARY = re.compile(r"послеоперац|предоперац|дооперац|после\s+операц|реабилитац|курсы\s+по|анестези|капельниц|восстановлени", re.I)
SURGICAL_REMOVAL = re.compile(r"^(удалени|вскрыти|рассечени|эксцизи|ушивани|разрез|энуклеац)", re.I)
SURGICAL_SECTIONS = {"hirurgiya-price", "urologiya-price", "proktologiya-price", "gyne-price", "travmatologiya-price", "lor"}
EXPLICIT_OPERATION_IDS = {10470, 10518, 10726, 11125, 11127, 11958, 12193, 12195, 12451, 12452, 12453, 12454, 12455, 12600, 12601, 12840}
COSMETIC = re.compile(r"биоревитализац|омоложени|моделирование\s+формы\s+половых\s+губ|увеличение\s+точки\s+g|введение\s+гиалуроновой\s+кислоты", re.I)
def reason(item):
name = item["name"].strip()
section = item["section"]
if section == "kosmetologiya-price":
return "cosmetology_not_offered"
if CONSULT.search(name):
return None
# The user explicitly requested consultation-only public surgical pricing.
if section in {"plasticheskaya_hirurgiya", "hirurgiya-price"}:
return "surgical_price_detail"
if item["id"] in EXPLICIT_OPERATION_IDS:
return "operative_correction_price"
if COSMETIC.search(name):
return "cosmetic_procedure_price"
if ANCILLARY.search(name) and not re.match(r"^(операци|оперативн|иссечени|удалени)", name, re.I):
return None
if OPERATION.search(name):
return "operation_price"
if SURGICAL_REMOVAL.search(name):
return "surgical_intervention_price"
if section == "gyne-price" and re.search(r"выскабливани|вакуумная\s+аспирац|гистерорезек|рассечени\s+синехи", name, re.I):
return "gynecological_surgery_price"
return None
if __name__ == "__main__":
import json
from collections import Counter
from pathlib import Path
root = Path(__file__).resolve().parent
prices = json.loads((root / "prices-before.json").read_text(encoding="utf-8-sig"))
targets = [{**item, "reason": reason(item)} for item in prices if item["published"] and reason(item)]
(root / "targets-review.json").write_text(json.dumps(targets, ensure_ascii=False, indent=2), encoding="utf-8")
print("TARGETS", len(targets), dict(Counter(item["section"] for item in targets)))
for item in targets:
if item["section"] not in {"kosmetologiya-price", "hirurgiya-price", "plasticheskaya_hirurgiya"}:
print(item["id"], item["section"], item["name"])