From ccdf80a0071ba7327bf0e520166511db164eb62e Mon Sep 17 00:00:00 2001 From: Marko Jovanovic Date: Wed, 22 Oct 2025 18:22:19 +0200 Subject: [PATCH] Clean with short codes --- migrations/Version20251022085244.php | 32 +++++++++++++++++++++ migrations/Version20251022090715.php | 34 +++++++++++++++++++++++ migrations/Version20251022160213.php | 32 +++++++++++++++++++++ src/Command/CleanMobileCommand.php | 9 +++++- src/Command/ContactUncontactedCommand.php | 12 +++++++- src/Entity/Contacts.php | 26 +++++++++++++++++ 6 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 migrations/Version20251022085244.php create mode 100644 migrations/Version20251022090715.php create mode 100644 migrations/Version20251022160213.php diff --git a/migrations/Version20251022085244.php b/migrations/Version20251022085244.php new file mode 100644 index 0000000..89c2d4a --- /dev/null +++ b/migrations/Version20251022085244.php @@ -0,0 +1,32 @@ +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'); + } +} diff --git a/migrations/Version20251022090715.php b/migrations/Version20251022090715.php new file mode 100644 index 0000000..db3e0a8 --- /dev/null +++ b/migrations/Version20251022090715.php @@ -0,0 +1,34 @@ +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'); + } +} diff --git a/migrations/Version20251022160213.php b/migrations/Version20251022160213.php new file mode 100644 index 0000000..684170e --- /dev/null +++ b/migrations/Version20251022160213.php @@ -0,0 +1,32 @@ +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'); + } +} diff --git a/src/Command/CleanMobileCommand.php b/src/Command/CleanMobileCommand.php index 264bf74..e70ed8c 100644 --- a/src/Command/CleanMobileCommand.php +++ b/src/Command/CleanMobileCommand.php @@ -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++; diff --git a/src/Command/ContactUncontactedCommand.php b/src/Command/ContactUncontactedCommand.php index 3cade56..b5bbe49 100644 --- a/src/Command/ContactUncontactedCommand.php +++ b/src/Command/ContactUncontactedCommand.php @@ -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, diff --git a/src/Entity/Contacts.php b/src/Entity/Contacts.php index f5ea9e3..c809fb6 100644 --- a/src/Entity/Contacts.php +++ b/src/Entity/Contacts.php @@ -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; + } }