Clean with short codes

This commit is contained in:
Marko Jovanovic 2025-10-22 18:22:19 +02:00
parent 18563c439a
commit ccdf80a007
6 changed files with 143 additions and 2 deletions

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251022085244 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE contacts ADD msg_content_type INT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE contacts DROP msg_content_type');
}
}

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251022090715 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE contacts ALTER msg_content_type SET DEFAULT 1');
$this->addSql('ALTER TABLE contacts ALTER msg_content_type SET NOT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE contacts ALTER msg_content_type DROP DEFAULT');
$this->addSql('ALTER TABLE contacts ALTER msg_content_type DROP NOT NULL');
}
}

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20251022160213 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE contacts ADD study_id_short VARCHAR(50) DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE contacts DROP study_id_short');
}
}

View File

@ -205,13 +205,20 @@ final class CleanMobileCommand extends Command
$contact->setStudyId($study_id);
$contact->setParsedFileLinenum($rowCount + 1);
$contact->setParsedFileLine(implode(';', $row));
$contact->setMsgContentType($rowCount % 2 ? 1 : 2);
try {
$this->http->request('POST', $this->backendApiURL . "/" . $study_id . "/" . $study_id_chain, [
$result = $this->http->request('POST', $this->backendApiURL . "/" . $study_id . "/" . $study_id_chain, [
'body' => '',
'headers' => [],
]);
if ($result->getStatusCode() == 200) {
$response = json_decode($result->getContent());
$shortCode = $response->{'subject_id_short'};
$contact->setStudyIdShort($shortCode);
}
$validContacts[] = $contact;
} catch (TransportExceptionInterface $e) {
$backendErrorCount++;

View File

@ -57,6 +57,7 @@ class ContactUncontactedCommand extends Command
// 1. Get uncontacted rows with a date in the past
$now = new DateTime();
/** @var Contacts[] $phoneNumbersToContact */
$phoneNumbersToContact = $this->entityManager->getRepository(Contacts::class)->createQueryBuilder('p')
->where('p.contacted = :state_contacted')
->andWhere('p.due_date < :now')
@ -82,6 +83,15 @@ class ContactUncontactedCommand extends Command
// 3. Contact the HTTP REST API
try {
$study_id = $phoneContact->getStudyId();
$msgContentType = $phoneContact->getMsgContentType();
$message = 'Liebe Patientin, lieber Patient, \ngerne möchten wir von Ihnen erfahren, wie zufrieden Sie mit uns sind. Wir freuen uns, wenn Sie sich die Zeit nehmen und uns Ihre Eindrücke mitteilen.\nIhre Anregungen gehen direkt zum Qualitäts- und Risikomanagement.\n\nhttps://umfragetool.ukbonn.de/login?id={$study_id} \n\nIhr UKB.\n\nSMS vom UKB abbestellen per E-Mail an: datenschutz@ukbonn.de';
switch ($msgContentType) {
case 1:
break;
case 2:
$message = '';
break;
}
$response = $this->httpClient->request('POST', self::$apiEndpoint, [
'headers' => [
'X-CM-PRODUCTTOKEN' => $this->sms_gateway_api_key,
@ -98,7 +108,7 @@ class ContactUncontactedCommand extends Command
],
'body': {
'type': 'auto',
'content': 'Liebe Patientin, lieber Patient, \ngerne möchten wir von Ihnen erfahren, wie zufrieden Sie mit uns sind. Wir freuen uns, wenn Sie sich die Zeit nehmen und uns Ihre Eindrücke mitteilen.\nIhre Anregungen gehen direkt zum Qualitäts- und Risikomanagement.\n\nhttps://umfragetool.ukbonn.de/login?id={$study_id} \n\nIhr UKB.\n\nSMS vom UKB abbestellen per E-Mail an: datenschutz@ukbonn.de'
'content': ''
},
'minimumNumberOfMessageParts': 1,
'maximumNumberOfMessageParts': 8,

View File

@ -43,6 +43,12 @@ class Contacts
#[ORM\Column(length: 50, nullable: true)]
private ?string $study_id = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $study_id_short = null;
#[ORM\Column(nullable: false, options: ['default' => 1])]
private ?int $msg_content_type = 1;
public function getId(): ?int
{
@ -158,4 +164,24 @@ class Contacts
{
$this->parsed_file_line = $parsed_file_line;
}
public function getMsgContentType(): ?int
{
return $this->msg_content_type;
}
public function setMsgContentType(?int $msg_content_type): void
{
$this->msg_content_type = $msg_content_type;
}
public function getStudyIdShort(): ?string
{
return $this->study_id_short;
}
public function setStudyIdShort(?string $study_id_short): void
{
$this->study_id_short = $study_id_short;
}
}