First Medicine request successful on API-Plateform auto generated doc
This commit is contained in:
parent
b8a3421b89
commit
c96e9640c9
0
api/data/bdpm/.gitkeep
Normal file
0
api/data/bdpm/.gitkeep
Normal file
8
api/data/database.links.txt
Normal file
8
api/data/database.links.txt
Normal file
@ -0,0 +1,8 @@
|
||||
CIS_bdpm.txt
|
||||
CIS_CIP_bdpm.txt
|
||||
CIS_COMPO_bdpm.txt
|
||||
CIS_HAS_SMR_bdpm.txt
|
||||
CIS_HAS_ASMR_bdpm.txt
|
||||
HAS_LiensPageCT_bdpm.txt
|
||||
CIS_CPD_bdpm.txt
|
||||
CIS_InfoImportantes.txt
|
20
api/data/utils/fill_database.php
Normal file
20
api/data/utils/fill_database.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Fill API backend SQL database with data from government open data.
|
||||
*/
|
||||
|
||||
// CIS_bdpm.txt
|
||||
// This database holds the list of medicines with status, holder, name, etc.
|
||||
|
||||
$URL = "http://localhost/";
|
||||
|
||||
function post($url, $data) {
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
12
api/data/utils/get_database.sh
Executable file
12
api/data/utils/get_database.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#! /usr/bin/env bash
|
||||
set -e
|
||||
|
||||
DATABASE_DOWNLOAD_ENDPOINT="https://base-donnees-publique.medicaments.gouv.fr/telechargement.php?fichier="
|
||||
|
||||
for file in $(cat ./data/database.links.txt); do
|
||||
if [[ -z "$file" ]]; then
|
||||
continue
|
||||
fi
|
||||
echo "Downloading $file"
|
||||
wget -O "./data/bdpm/${file}" "${DATABASE_DOWNLOAD_ENDPOINT}${file}"
|
||||
done
|
1
api/migrations/.gitignore
vendored
1
api/migrations/.gitignore
vendored
@ -0,0 +1 @@
|
||||
*
|
50
api/src/Entity/MedicineAdministrationWay.php
Normal file
50
api/src/Entity/MedicineAdministrationWay.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Link;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* A medicine administration way.
|
||||
* i.e. "comprime secable voie orale" for instance
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
class MedicineAdministrationWay
|
||||
{
|
||||
#[ORM\Id, ORM\Column,ORM\GeneratedValue]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* This CIS (Code Identifiant de Spécialité) id is the unique identifier of the medicine.
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $CIS = null;
|
||||
|
||||
/** The medicine that is admnistrate this way. */
|
||||
#[ORM\ManyToOne(inversedBy: 'ways')]
|
||||
public ?MedicineSpeciality $medicine = null;
|
||||
|
||||
/**
|
||||
* The drug administration way
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $administration_way = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCIS(): ?string
|
||||
{
|
||||
return $this->CIS;
|
||||
}
|
||||
|
||||
public function getAdministrationWay(): ?string
|
||||
{
|
||||
return $this->administration_way;
|
||||
}
|
||||
}
|
67
api/src/Entity/MedicineHolder.php
Normal file
67
api/src/Entity/MedicineHolder.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Link;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* A medicine holder (titulaire of an AMM).
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
class MedicineHolder
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* This CIS (Code Identifiant de Spécialité) id is the unique identifier of the medicine.
|
||||
*/
|
||||
#[ORM\Column(type: 'string', length: 11)]
|
||||
private ?string $CIS = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private string $name = '';
|
||||
|
||||
/** The medicament this entity holds */
|
||||
#[ORM\ManyToOne(inversedBy: 'holders')]
|
||||
private ?MedicineSpeciality $medicine;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getCIS(): ?string
|
||||
{
|
||||
return $this->CIS;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
public function setCIS(string $CIS): self
|
||||
{
|
||||
$this->CIS = $CIS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
295
api/src/Entity/MedicineSpeciality.php
Normal file
295
api/src/Entity/MedicineSpeciality.php
Normal file
@ -0,0 +1,295 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\Link;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* A medicine speciality.
|
||||
*
|
||||
* Medicine that is in the commercial distribution or that has been in commercial distribution since less than three years.
|
||||
*
|
||||
* From CIS_bdpm.txt
|
||||
* @see https://base-donnees-publique.medicaments.gouv.fr/telechargement.php
|
||||
*/
|
||||
#[ORM\Entity]
|
||||
#[ApiResource]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/'
|
||||
// )]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/{CIS}',
|
||||
// uriVariables: [
|
||||
// 'CIS' => new Link(fromClass: MedicineSpeciality::class, fromProperty: 'CIS'),
|
||||
// ]
|
||||
// )]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/{CIS}/holder',
|
||||
// uriVariables: [
|
||||
// 'CIS' => new Link(fromClass: MedicineSpeciality::class, fromProperty: 'CIS'),
|
||||
// ]
|
||||
// )]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/{CIS}/holder/{id}',
|
||||
// uriVariables: [
|
||||
// 'CIS' => new Link(fromClass: MedicineSpeciality::class, fromProperty: 'CIS'),
|
||||
// 'id' => new Link(fromClass: MedicineHolder::class, fromProperty: 'id'),
|
||||
// ]
|
||||
// )]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/{CIS}/way',
|
||||
// uriVariables: [
|
||||
// 'CIS' => new Link(fromClass: MedicineSpeciality::class, fromProperty: 'CIS'),
|
||||
// ]
|
||||
// )]
|
||||
// #[ApiResource(
|
||||
// uriTemplate: '/medicine/{CIS}/way/{id}',
|
||||
// uriVariables: [
|
||||
// 'CIS' => new Link(fromClass: MedicineSpeciality::class, fromProperty: 'CIS'),
|
||||
// 'id' => new Link(fromClass: MedicineAdministrationWay::class, fromProperty: 'id'),
|
||||
// ]
|
||||
// )]
|
||||
class MedicineSpeciality
|
||||
{
|
||||
|
||||
#[ORM\Id, ORM\Column,ORM\GeneratedValue]
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* This CIS (Code Identifiant de Spécialité) id is the unique identifier of the medicine.
|
||||
*/
|
||||
#[ORM\Column]
|
||||
#[ApiProperty(identifier: true)]
|
||||
private ?int $CIS = null;
|
||||
|
||||
/**
|
||||
* Name of the medicine.
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $denomination = null;
|
||||
|
||||
/**
|
||||
* Pharmaceutical form of the medicine.
|
||||
*
|
||||
*
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $form = null;
|
||||
|
||||
/**
|
||||
* Ways of drug administration of the medicine.
|
||||
* @var medicineAdministrationWay[] Available administration routes for this medicine.
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'medicine', targetEntity: MedicineAdministrationWay::class)]
|
||||
public iterable $ways;
|
||||
|
||||
/**
|
||||
* Administrative state of medicine's market authorization (AMM).
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $market_auth_status = null;
|
||||
|
||||
/**
|
||||
* Type of medicine market authorization process
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $market_auth_process_type = null;
|
||||
|
||||
/**
|
||||
* Date of medicine market authorization (AMM - * Autorisation de Mise sur le Marché)
|
||||
*/
|
||||
#[ORM\Column(type: 'date')]
|
||||
private ?\DateTimeInterface $market_auth_date = null;
|
||||
|
||||
/**
|
||||
* Market status
|
||||
*
|
||||
* State of medicine commercialization.
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $market_status = null;
|
||||
|
||||
/**
|
||||
* Bdm status
|
||||
*
|
||||
* either "alerte", "warning disponibilité"
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $bdm_status = null;
|
||||
|
||||
/**
|
||||
* European authorization code
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?int $european_auth_code = null;
|
||||
|
||||
/**
|
||||
* Holders(s)
|
||||
*
|
||||
* @var MedicineHolder[] Holders of the medicine market authorization (AMM)
|
||||
*/
|
||||
#[ORM\OneToMany(mappedBy: 'medicine', targetEntity: MedicineHolder::class, cascade: ['persist', 'remove'])]
|
||||
public iterable $holders;
|
||||
|
||||
/**
|
||||
* Enforced surveillance
|
||||
*
|
||||
* either 'Oui' or 'Non'
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $enforced_surveillance = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->holders = new ArrayCollection();
|
||||
$this->ways = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getCIS(): ?int
|
||||
{
|
||||
return $this->CIS;
|
||||
}
|
||||
|
||||
public function getDenomination(): ?string
|
||||
{
|
||||
return $this->denomination;
|
||||
}
|
||||
|
||||
public function getForm(): ?string
|
||||
{
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
public function getMarketAuthStatus(): ?string
|
||||
{
|
||||
return $this->market_auth_status;
|
||||
}
|
||||
|
||||
public function getMarketAuthProcessType(): ?string
|
||||
{
|
||||
return $this->market_auth_process_type;
|
||||
}
|
||||
|
||||
public function getMarketAuthDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->market_auth_date;
|
||||
}
|
||||
|
||||
public function getMarketStatus(): ?string
|
||||
{
|
||||
return $this->market_status;
|
||||
}
|
||||
|
||||
public function getBdmStatus(): ?string
|
||||
{
|
||||
return $this->bdm_status;
|
||||
}
|
||||
|
||||
public function getEuropeanAuthCode(): ?int
|
||||
{
|
||||
return $this->european_auth_code;
|
||||
}
|
||||
|
||||
public function getEnforcedSurveillance(): ?string
|
||||
{
|
||||
return $this->enforced_surveillance;
|
||||
}
|
||||
|
||||
public function getWays(): iterable
|
||||
{
|
||||
return $this->ways;
|
||||
}
|
||||
|
||||
public function getHolders(): iterable
|
||||
{
|
||||
return $this->holders;
|
||||
}
|
||||
|
||||
public function setCIS(?int $CIS): self
|
||||
{
|
||||
$this->CIS = $CIS;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setDenomination(?string $denomination): self
|
||||
{
|
||||
$this->denomination = $denomination;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setForm(?string $form): self
|
||||
{
|
||||
$this->form = $form;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMarketAuthStatus(?string $market_auth_status): self
|
||||
{
|
||||
$this->market_auth_status = $market_auth_status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMarketAuthProcessType(?string $market_auth_process_type): self
|
||||
{
|
||||
$this->market_auth_process_type = $market_auth_process_type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMarketAuthDate(?\DateTimeInterface $market_auth_date): self
|
||||
{
|
||||
$this->market_auth_date = $market_auth_date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMarketStatus(?string $market_status): self
|
||||
{
|
||||
$this->market_status = $market_status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setBdmStatus(?string $bdm_status): self
|
||||
{
|
||||
$this->bdm_status = $bdm_status;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEuropeanAuthCode(?int $european_auth_code): self
|
||||
{
|
||||
$this->european_auth_code = $european_auth_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setEnforcedSurveillance(?string $enforced_surveillance): self
|
||||
{
|
||||
$this->enforced_surveillance = $enforced_surveillance;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setWays(iterable $ways): self
|
||||
{
|
||||
$this->ways = $ways;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHolders(iterable $holders): self
|
||||
{
|
||||
$this->holders = $holders;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user