generated from HenriqueAmorim20/GEROcuidadoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from fga-eps-mds/hotfix/#225-CardMetrica-nao-a…
…tualiza Hotfix/#225 card metrica nao atualiza
- Loading branch information
Showing
19 changed files
with
266 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export enum ECategoriaMetrica { | ||
FREQUENCIA_CARDIACA = 'Frequência Cardíaca', | ||
PRESSAO_SANGUINEA = 'Pressão', | ||
TEMPERATURA = 'Temperatura', | ||
PESO = 'Peso', | ||
GLICEMIA = 'Glicemia', | ||
SATURACAO = 'Saturação', | ||
HORAS_DORMIDAS = 'Horas Dormidas', | ||
ALTURA = 'Altura', | ||
IMC = 'IMC', | ||
FREQUENCIA_CARDIACA = 'Frequência Cardíaca', | ||
PRESSAO_SANGUINEA = 'Pressão', | ||
TEMPERATURA = 'Temperatura', | ||
PESO = 'Peso', | ||
GLICEMIA = 'Glicemia', | ||
SATURACAO = 'Saturação', | ||
HORAS_DORMIDAS = 'Horas Dormidas', | ||
ALTURA = 'Altura', | ||
IMC = 'IMC', | ||
HIDRATACAO = 'Hidratação', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import { IsEnum, IsNotEmpty, IsNumber } from "class-validator"; | ||
import { ECategoriaMetrica } from "../classes/tipo-metrica.enum"; | ||
import { | ||
IsEnum, | ||
IsNotEmpty, | ||
IsNumber, | ||
IsOptional, | ||
IsString, | ||
} from 'class-validator'; | ||
import { ECategoriaMetrica } from '../classes/tipo-metrica.enum'; | ||
|
||
export class CreateMetricaDto { | ||
@IsNotEmpty() | ||
@IsNumber() | ||
idIdoso!: number; | ||
@IsNotEmpty() | ||
@IsNumber() | ||
idIdoso!: number; | ||
|
||
@IsNotEmpty() | ||
@IsEnum(ECategoriaMetrica) | ||
categoria?: ECategoriaMetrica; | ||
} | ||
@IsNotEmpty() | ||
@IsEnum(ECategoriaMetrica) | ||
categoria?: ECategoriaMetrica; | ||
|
||
@IsOptional() | ||
@IsString() | ||
valorMaximo?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { PartialType } from "@nestjs/mapped-types"; | ||
import { CreateMetricaDto } from "./create-metrica-dto"; | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateMetricaDto } from './create-metrica-dto'; | ||
|
||
export class UpdateMetricaDto extends PartialType(CreateMetricaDto) { } | ||
export class UpdateMetricaDto extends PartialType(CreateMetricaDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from "typeorm"; | ||
import { Idoso } from "../../idoso/entities/idoso.entity"; | ||
import { ECategoriaMetrica } from "../classes/tipo-metrica.enum"; | ||
import { CreateMetricaDto } from "../dto/create-metrica-dto"; | ||
import { UpdateMetricaDto } from "../dto/update-metrica-dto"; | ||
import { | ||
Column, | ||
Entity, | ||
JoinColumn, | ||
ManyToOne, | ||
OneToMany, | ||
PrimaryGeneratedColumn, | ||
} from 'typeorm'; | ||
import { Idoso } from '../../idoso/entities/idoso.entity'; | ||
import { ValorMetrica } from '../../valorMetrica/entities/valorMetrica.entity'; | ||
import { ECategoriaMetrica } from '../classes/tipo-metrica.enum'; | ||
import { CreateMetricaDto } from '../dto/create-metrica-dto'; | ||
import { UpdateMetricaDto } from '../dto/update-metrica-dto'; | ||
|
||
@Entity({ name: 'metrica' }) | ||
export class Metrica { | ||
@PrimaryGeneratedColumn() | ||
id!: number; | ||
@PrimaryGeneratedColumn() | ||
id!: number; | ||
|
||
@ManyToOne(() => Idoso) | ||
@JoinColumn({ name: 'idIdoso' }) | ||
idIdoso!: number; | ||
@ManyToOne(() => Idoso) | ||
@JoinColumn({ name: 'idIdoso' }) | ||
idIdoso!: number; | ||
|
||
@Column('enum', { enum: ECategoriaMetrica }) | ||
categoria!: ECategoriaMetrica; | ||
@OneToMany(() => ValorMetrica, (valorMetrica) => valorMetrica.idMetrica) | ||
valoresMetricas!: ValorMetrica[]; | ||
|
||
constructor(createMetricaDto: CreateMetricaDto | UpdateMetricaDto) { | ||
Object.assign(this, createMetricaDto); | ||
} | ||
} | ||
@Column('enum', { enum: ECategoriaMetrica }) | ||
categoria!: ECategoriaMetrica; | ||
|
||
@Column('varchar', { length: 20, nullable: true }) | ||
valorMaximo?: string; | ||
|
||
constructor(createMetricaDto: CreateMetricaDto | UpdateMetricaDto) { | ||
Object.assign(this, createMetricaDto); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CreateTableMetrica1701549606356 implements MigrationInterface { | ||
name = 'CreateTableMetrica1701549606356' | ||
name = 'CreateTableMetrica1701549606356'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TYPE "public"."metrica_categoria_enum" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação')`); | ||
await queryRunner.query(`CREATE TABLE "metrica" ("id" SERIAL NOT NULL, "categoria" "public"."metrica_categoria_enum" NOT NULL, "idIdoso" integer, CONSTRAINT "PK_37eda6d5162b9305738916e1712" PRIMARY KEY ("id"))`); | ||
await queryRunner.query(`ALTER TABLE "metrica" ADD CONSTRAINT "FK_574d03daab9657eaa6cc7d5d726" FOREIGN KEY ("idIdoso") REFERENCES "idoso"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "metrica" DROP CONSTRAINT "FK_574d03daab9657eaa6cc7d5d726"`); | ||
await queryRunner.query(`DROP TABLE "metrica"`); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum"`); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."metrica_categoria_enum" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação')`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "metrica" ("id" SERIAL NOT NULL, "categoria" "public"."metrica_categoria_enum" NOT NULL, "idIdoso" integer, CONSTRAINT "PK_37eda6d5162b9305738916e1712" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "metrica" ADD CONSTRAINT "FK_574d03daab9657eaa6cc7d5d726" FOREIGN KEY ("idIdoso") REFERENCES "idoso"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "metrica" DROP CONSTRAINT "FK_574d03daab9657eaa6cc7d5d726"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "metrica"`); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CreateTableValorMetrica1701559083238 implements MigrationInterface { | ||
name = 'CreateTableValorMetrica1701559083238' | ||
export class CreateTableValorMetrica1701559083238 | ||
implements MigrationInterface | ||
{ | ||
name = 'CreateTableValorMetrica1701559083238'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "valorMetrica" ("id" SERIAL NOT NULL, "valor" double precision NOT NULL, "dataHora" TIMESTAMP NOT NULL, "idMetrica" integer, CONSTRAINT "PK_9e8ca5a7cfc9169850aa35d4fe2" PRIMARY KEY ("id"))`); | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" ADD CONSTRAINT "FK_80f274382900aafd3a667034d46" FOREIGN KEY ("idMetrica") REFERENCES "metrica"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" DROP CONSTRAINT "FK_80f274382900aafd3a667034d46"`); | ||
await queryRunner.query(`DROP TABLE "valorMetrica"`); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "valorMetrica" ("id" SERIAL NOT NULL, "valor" double precision NOT NULL, "dataHora" TIMESTAMP NOT NULL, "idMetrica" integer, CONSTRAINT "PK_9e8ca5a7cfc9169850aa35d4fe2" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "valorMetrica" ADD CONSTRAINT "FK_80f274382900aafd3a667034d46" FOREIGN KEY ("idMetrica") REFERENCES "metrica"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "valorMetrica" DROP CONSTRAINT "FK_80f274382900aafd3a667034d46"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "valorMetrica"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,39 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AlterTableValorMetrica1701996752336 implements MigrationInterface { | ||
name = 'AlterTableValorMetrica1701996752336' | ||
name = 'AlterTableValorMetrica1701996752336'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TYPE "public"."metrica_categoria_enum" RENAME TO "metrica_categoria_enum_old"`); | ||
await queryRunner.query(`CREATE TYPE "public"."metrica_categoria_enum" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação', 'Horas Dormidas', 'Altura', 'IMC')`); | ||
await queryRunner.query(`ALTER TABLE "metrica" ALTER COLUMN "categoria" TYPE "public"."metrica_categoria_enum" USING "categoria"::"text"::"public"."metrica_categoria_enum"`); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum_old"`); | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" DROP COLUMN "valor"`); | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" ADD "valor" character varying(10) NOT NULL`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" DROP COLUMN "valor"`); | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" ADD "valor" double precision NOT NULL`); | ||
await queryRunner.query(`CREATE TYPE "public"."metrica_categoria_enum_old" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação')`); | ||
await queryRunner.query(`ALTER TABLE "metrica" ALTER COLUMN "categoria" TYPE "public"."metrica_categoria_enum_old" USING "categoria"::"text"::"public"."metrica_categoria_enum_old"`); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum"`); | ||
await queryRunner.query(`ALTER TYPE "public"."metrica_categoria_enum_old" RENAME TO "metrica_categoria_enum"`); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TYPE "public"."metrica_categoria_enum" RENAME TO "metrica_categoria_enum_old"`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."metrica_categoria_enum" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação', 'Horas Dormidas', 'Altura', 'IMC')`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "metrica" ALTER COLUMN "categoria" TYPE "public"."metrica_categoria_enum" USING "categoria"::"text"::"public"."metrica_categoria_enum"`, | ||
); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum_old"`); | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" DROP COLUMN "valor"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "valorMetrica" ADD "valor" character varying(10) NOT NULL`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "valorMetrica" DROP COLUMN "valor"`); | ||
await queryRunner.query( | ||
`ALTER TABLE "valorMetrica" ADD "valor" double precision NOT NULL`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."metrica_categoria_enum_old" AS ENUM('Frequência Cardíaca', 'Pressão', 'Temperatura', 'Peso', 'Glicemia', 'Saturação')`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "metrica" ALTER COLUMN "categoria" TYPE "public"."metrica_categoria_enum_old" USING "categoria"::"text"::"public"."metrica_categoria_enum_old"`, | ||
); | ||
await queryRunner.query(`DROP TYPE "public"."metrica_categoria_enum"`); | ||
await queryRunner.query( | ||
`ALTER TYPE "public"."metrica_categoria_enum_old" RENAME TO "metrica_categoria_enum"`, | ||
); | ||
} | ||
} |
Oops, something went wrong.