Skip to content

Repository files navigation

TilsynsApp Daily Inspection Summary

OpenOrchestrator robot that, once per day, emails a summary of all inspections registered through the TilsynsApp that day.

What it does

  1. Queries the TilsynItems container in Cosmos for documents with last_inspected_at matching today's date.
  2. Flattens each document's inspections history into one row per real inspection performed today (hide/restore entries are filtered out).
  3. Builds an HTML table with a direct link to each case's origin system:
    • Permissionhttps://vejman.vd.dk/permissions/update.jsp?caseid={case_id}
    • Henstillinghttps://pez.giantleap.net/cases/view/{PEZUUID}/case
    • Indmeldthttps://vejmankassen.adm.aarhuskommune.dk/tilsyn
  4. Sends the table to the recipient stored in the VejArealMail OpenOrchestrator constant. Subject: "Dagens inspektioner".

If no inspections were registered today, no mail is sent and the robot exits quietly.

Columns in the email

Column Source
Tid inspected_at from the inspection record (formatted HH:MM)
Tilsynsførende Initial portion of inspector_email
Sagsnummer case_number (or HenstillingId for henstillinger), linked
Adresse full_address
Information rovm_equipment_type / Forseelse / title depending on type
Status selection (permission), mapped faktura_status (henstilling), or "Tilset" (indmeldt). For henstillinger, any kvadratmeter / end_date change is shown as a sub-line.
Kommentar Free-text comment from the inspector

OpenOrchestrator setup

Constants

  • VejArealMail — recipient address for the daily mail.

Credentials

  • AAKTilsynDB — Cosmos DB: username = endpoint URL, password = key.

Trigger

Schedule as a single daily trigger (e.g. 16:00) — uses the linear flow.

Dependencies

dependencies = [
    "OpenOrchestrator == 2.*",
    "azure-cosmos == 4.15.0",
]

SMTP host/port are read from robot_framework/config.py (SMTP_SERVER, SMTP_PORT) — same pattern as the existing RegelRytteren robot.

Robot-Framework V4

This repo is meant to be used as a template for robots made for OpenOrchestrator v2.

Quick start

  1. To use this template simply use this repo as a template (see Creating a repository from a template). Don't include all branches.

  2. Go to robot_framework/__main__.py and choose between the linear framework or queue based framework.

  3. Implement all functions in the files:

    • robot_framework/initialize.py
    • robot_framework/reset.py
    • robot_framework/process.py
  4. Change config.py to your needs.

  5. Fill out the dependencies in the pyproject.toml file with all packages needed by the robot.

  6. Feel free to add more files as needed. Remember that any additional python files must be located in the folder robot_framework or a subfolder of it.

When the robot is run from OpenOrchestrator the main.py file is run which results in the following:

  1. The working directory is changed to where main.py is located.
  2. A virtual environment is automatically setup with the required packages.
  3. The framework is called passing on all arguments needed by OpenOrchestrator.

Requirements

Minimum python version 3.11

Flow

This framework contains two different flows: A linear and a queue based. You should only ever use one at a time. You choose which one by going into robot_framework/__main__.py and uncommenting the framework you want. They are both disabled by default and an error will be raised to remind you if you don't choose.

Linear Flow

The linear framework is used when a robot is just going from A to Z without fetching jobs from an OpenOrchestrator queue. The flow of the linear framework is sketched up in the following illustration:

Linear Flow diagram

Queue Flow

The queue framework is used when the robot is doing multiple bite-sized tasks defined in an OpenOrchestrator queue. The flow of the queue framework is sketched up in the following illustration:

Queue Flow diagram

Linting and Github Actions

This template is also setup with flake8 and pylint linting in Github Actions. This workflow will trigger whenever you push your code to Github. The workflow is defined under .github/workflows/Linting.yml.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages