CODEX-CELIDA / execution-engine

Execution engine for mapping clinical guideline recommendations on OMOP CDM patient data
2 stars 0 forks source link

AssertionError: timing must be a ValueNumber #115

Closed theompm closed 8 months ago

theompm commented 8 months ago

Hi Gregor,

ich habe leider einen neuen Fehler.

covid19-inpatient-therapy/recommendation/covid19-abdominal-positioning-ards
Traceback (most recent call last):
  File "/home/theo/projects/execution-engine/scripts/execute.py", line 92, in <module>
    cdd = e.load_recommendation(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/execution_engine.py", line 275, in load_recommendation
    recommendation = self.load_recommendation_from_database(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/execution_engine.py", line 408, in load_recommendation_from_database
    recommendation = cohort.Recommendation.from_json(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/serializable.py", line 64, in from_json
    return cls.from_dict(json.loads(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/recommendation.py", line 273, in from_dict
    pi_pairs=[
             ^
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/recommendation.py", line 274, in <listcomp>
    cohort.PopulationInterventionPair.from_dict(c)
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/population_intervention_pair.py", line 252, in from_dict
    intervention=CriterionCombination.from_dict(data["intervention"]),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/combination.py", line 194, in from_dict
    combination.add(criterion_factory(**criterion))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/factory.py", line 64, in criterion_factory
    return class_map[class_name].from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/combination.py", line 194, in from_dict
    combination.add(criterion_factory(**criterion))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/factory.py", line 64, in criterion_factory
    return class_map[class_name].from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/procedure_occurrence.py", line 186, in from_dict
    isinstance(timing, ValueNumber) or timing is None
                                       ^^^^^^^^^^^^^^
AssertionError: timing must be a ValueNumber

unsere dtypes in procedure_occurrence:

"column_name"   "data_type"
"procedure_occurrence_id"   "integer"
"person_id" "integer"
"procedure_concept_id"  "integer"
"procedure_date"    "date"
"procedure_datetime"    "timestamp with time zone"
"procedure_end_date"    "date"
"procedure_end_datetime"    "timestamp with time zone"
"procedure_type_concept_id" "integer"
"modifier_concept_id"   "integer"
"quantity"  "integer"
"provider_id"   "integer"
"visit_occurrence_id"   "integer"
"visit_detail_id"   "integer"
"procedure_source_value"    "character varying"
"procedure_source_concept_id"   "integer"
"modifier_source_value" "character varying"
glichtner commented 8 months ago

Hi @theompm,

das ist ein Problem mit dem Datentyp in der FHIR Repräsentation, nicht in eurer Datenbank. Hast du den recommendation server mal neugestartet (und vorher sicherheitshalber nochmal gepullt)?

docker stop celida-recommendation-server
docker rm celida-recommendation-server
docker pull glichtner/celida-recommendation-server:latest
docker run \
   -e "GH_REPOSITORY=https://github.com/CODEX-CELIDA/celida-recommendations" \
   --name celida-recommendation-server \
   -dp 8000:80 \
   glichtner/celida-recommendation-server
theompm commented 8 months ago

Hallo @glichtner

Der Error wird leider immer noh ausgegeben

docker-compose.yml

version: '3.8'

name: 'celida-recommendation'

services:
  server:
    image: 'glichtner/celida-recommendation-server:latest'
    environment:
      GH_REPOSITORY: https://github.com/CODEX-CELIDA/celida-recommendations
    restart: always
    ports:
      - '8000:80'

pull

docker compose pull
[+] Pulling 1/1
 ✔ server Pulled

start server

docker compose up -d

[+] Running 2/2
 ✔ Network celida-recomendation_default     Created                                                                               0.1s
 ✔ Container celida-recomendation-server-1  Created                                                                               0.1s
Attaching to celida-recomendation-server-1
celida-recomendation-server-1  | Checking for script in /app/prestart.sh
celida-recomendation-server-1  | Running script /app/prestart.sh
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [1] [INFO] Starting gunicorn 20.1.0
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [1] [INFO] Listening at: http://0.0.0.0:80 (1)
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [1] [INFO] Using worker: uvicorn.workers.UvicornWorker
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [8] [INFO] Booting worker with pid: 8
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [9] [INFO] Booting worker with pid: 9
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [10] [INFO] Booting worker with pid: 10
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [11] [INFO] Booting worker with pid: 11
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [12] [INFO] Booting worker with pid: 12
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [13] [INFO] Booting worker with pid: 13
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [14] [INFO] Booting worker with pid: 14
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [15] [INFO] Booting worker with pid: 15
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [16] [INFO] Booting worker with pid: 16
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [17] [INFO] Booting worker with pid: 17
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [18] [INFO] Booting worker with pid: 18
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [19] [INFO] Booting worker with pid: 19
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [20] [INFO] Booting worker with pid: 20
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [21] [INFO] Booting worker with pid: 21
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [22] [INFO] Booting worker with pid: 22
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [23] [INFO] Booting worker with pid: 23
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [24] [INFO] Booting worker with pid: 24
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [25] [INFO] Booting worker with pid: 25
celida-recomendation-server-1  | [2024-03-08 08:08:35 +0000] [26] [INFO] Booting worker with pid: 26
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [27] [INFO] Booting worker with pid: 27
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [28] [INFO] Booting worker with pid: 28
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [29] [INFO] Booting worker with pid: 29
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [30] [INFO] Booting worker with pid: 30
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [31] [INFO] Booting worker with pid: 31
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [32] [INFO] Booting worker with pid: 32
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [33] [INFO] Booting worker with pid: 33
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [34] [INFO] Booting worker with pid: 34
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [35] [INFO] Booting worker with pid: 35
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [36] [INFO] Booting worker with pid: 36
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [37] [INFO] Booting worker with pid: 37
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [38] [INFO] Booting worker with pid: 38
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [39] [INFO] Booting worker with pid: 39
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [40] [INFO] Booting worker with pid: 40
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [41] [INFO] Booting worker with pid: 41
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [42] [INFO] Booting worker with pid: 42
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [43] [INFO] Booting worker with pid: 43
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [44] [INFO] Booting worker with pid: 44
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [45] [INFO] Booting worker with pid: 45
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [46] [INFO] Booting worker with pid: 46
celida-recomendation-server-1  | [2024-03-08 08:08:36 +0000] [47] [INFO] Booting worker with pid: 47

Load recommendations

covid19-inpatient-therapy/recommendation/therapeutic-anticoagulation
2024-03-08 09:19:23,329 - INFO - Loaded recommendation https://www.netzwerk-universitaetsmedizin.de/fhir/codex-celida/guideline/covid19-inpatient-therapy/recommendation/therapeutic-anticoagulation (version=1.0, package version=v1.3.1) from database.
2024-03-08 09:19:23,329 - INFO - Executing recommendation https://www.netzwerk-universitaetsmedizin.de/fhir/codex-celida/guideline/covid19-inpatient-therapy/recommendation/therapeutic-anticoagulation (execution engine version=2.0.0-rc1).
2024-03-08 09:19:23,394 - INFO - Observation window from 2020-01-01 00:00:00 +0100 to 2023-05-31 23:59:59 +0100

error

2024-03-08 09:00:21,583 - INFO - Worker process stopped.
2024-03-08 09:00:21,599 - INFO - All worker processes stopped.
covid19-inpatient-therapy/recommendation/covid19-abdominal-positioning-ards
Traceback (most recent call last):
  File "/home/theo/projects/execution-engine/scripts/execute.py", line 92, in <module>
    cdd = e.load_recommendation(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/execution_engine.py", line 275, in load_recommendation
    recommendation = self.load_recommendation_from_database(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/execution_engine.py", line 408, in load_recommendation_from_database
    recommendation = cohort.Recommendation.from_json(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/serializable.py", line 64, in from_json
    return cls.from_dict(json.loads(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/recommendation.py", line 273, in from_dict
    pi_pairs=[
             ^
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/recommendation.py", line 274, in <listcomp>
    cohort.PopulationInterventionPair.from_dict(c)
  File "/home/theo/projects/execution-engine/execution_engine/omop/cohort/population_intervention_pair.py", line 252, in from_dict
    intervention=CriterionCombination.from_dict(data["intervention"]),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/combination.py", line 194, in from_dict
    combination.add(criterion_factory(**criterion))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/factory.py", line 64, in criterion_factory
    return class_map[class_name].from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/combination.py", line 194, in from_dict
    combination.add(criterion_factory(**criterion))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/factory.py", line 64, in criterion_factory
    return class_map[class_name].from_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/theo/projects/execution-engine/execution_engine/omop/criterion/procedure_occurrence.py", line 186, in from_dict
    isinstance(timing, ValueNumber) or timing is None
                                       ^^^^^^^^^^^^^^
AssertionError: timing must be a ValueNumber
theompm commented 8 months ago

Hi @glichtner

SOLUTION

uncomment -> reload recommendations


# Optional: Truncate all tables before execution
with omopdb.begin() as con:
    con.execute(
        text(
            "TRUNCATE TABLE "
            "   celida.comment, "
            "   celida.recommendation, "
            "   celida.criterion, "
            "   celida.execution_run, "
            "   celida.result_interval, "
            "   celida.recommendation, "
            "   celida.population_intervention_pair "
            "RESTART IDENTITY"
        )
    )