diff --git a/sql/load_demo_data.sql b/sql/load_demo_data.sql index 5f5ced19c..a0b6d8bcf 100644 --- a/sql/load_demo_data.sql +++ b/sql/load_demo_data.sql @@ -2994,21 +2994,21 @@ UNLOCK TABLES; LOCK TABLES `oh_medicaldsrward` WRITE; /*!40000 ALTER TABLE `oh_medicaldsrward` DISABLE KEYS */; -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('C',103,100,4,'AUTO_C_103',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('C',275,20,0,'7144453288242750524',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',99,100,0,'AUTO_F_99',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',105,1000,0,'AUTO_F_105',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',368,20,0,'1352158066768470913',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',404,10,0,'AUTO_F_404',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('F',415,200,0,'AUTO_F_415',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',40,100,0,'AUTO_I_40',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',50,40,0,'7460012206646986840',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',98,130,10,'AUTO_I_98',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',108,1600,0,'AUTO_I_108',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('I',415,1000,0,'AUTO_I_415',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('INV',124,9000,0,'202402AAC1',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('INV',264,100,0,'202402c',NULL,NULL,NULL,NULL,1); -INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`) VALUES ('M',98,70,2,'AUTO_M_98',NULL,NULL,NULL,NULL,1); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('C',103,100,4,'AUTO_C_103',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('C',275,20,0,'7144453288242750524',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',99,100,0,'AUTO_F_99',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',105,1000,0,'AUTO_F_105',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',368,20,0,'1352158066768470913',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',404,10,0,'AUTO_F_404',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('F',415,200,0,'AUTO_F_415',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',40,100,0,'AUTO_I_40',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',50,40,0,'7460012206646986840',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',98,130,10,'AUTO_I_98',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',108,1600,0,'AUTO_I_108',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('I',415,1000,0,'AUTO_I_415',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('INV',124,9000,0,'202402AAC1',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('INV',264,100,0,'202402c',NULL,NULL,NULL,NULL,1, 0); +INSERT INTO `oh_medicaldsrward` (`MDSRWRD_WRD_ID_A`, `MDSRWRD_MDSR_ID`, `MDSRWRD_IN_QTI`, `MDSRWRD_OUT_QTI`, `MDSRWRD_LT_ID_A`, `MDSRWRD_CREATED_BY`, `MDSRWRD_CREATED_DATE`, `MDSRWRD_LAST_MODIFIED_BY`, `MDSRWRD_LAST_MODIFIED_DATE`, `MDSRWRD_ACTIVE`, `MDSRWRD_LOCK`) VALUES ('M',98,70,2,'AUTO_M_98',NULL,NULL,NULL,NULL,1, 0); /*!40000 ALTER TABLE `oh_medicaldsrward` ENABLE KEYS */; UNLOCK TABLES; diff --git a/sql/step_a111_add_missing_lock_columns.sql b/sql/step_a111_add_missing_lock_columns.sql index 5b41a2d2f..4695e2992 100644 --- a/sql/step_a111_add_missing_lock_columns.sql +++ b/sql/step_a111_add_missing_lock_columns.sql @@ -31,3 +31,6 @@ ALTER TABLE `oh_pricesothers` ALTER TABLE `oh_visits` ADD COLUMN `VST_LOCK` INT(11) NOT NULL DEFAULT 0; + +ALTER TABLE `oh_medicaldsrward` + ADD COLUMN `MDSRWRD_LOCK` INT(11) NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java index a5d1ca50e..ad6e2154e 100644 --- a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java +++ b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java @@ -1,6 +1,6 @@ /* * Open Hospital (www.open-hospital.org) - * Copyright © 2006-2023 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) + * Copyright © 2006-2024 Informatici Senza Frontiere (info@informaticisenzafrontiere.org) * * Open Hospital is a free and open source software for healthcare data management. * @@ -28,6 +28,7 @@ import jakarta.persistence.EntityListeners; import jakarta.persistence.Table; import jakarta.persistence.Transient; +import jakarta.persistence.Version; import org.isf.medicals.model.Medical; import org.isf.medicalstock.model.Lot; @@ -36,7 +37,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Entity -@Table(name="OH_MEDICALDSRWARD") +@Table(name = "OH_MEDICALDSRWARD") @EntityListeners(AuditingEntityListener.class) @AttributeOverride(name = "createdBy", column = @Column(name = "MDSRWRD_CREATED_BY", updatable = false)) @AttributeOverride(name = "createdDate", column = @Column(name = "MDSRWRD_CREATED_DATE", updatable = false)) @@ -45,45 +46,51 @@ @AttributeOverride(name = "lastModifiedDate", column = @Column(name = "MDSRWRD_LAST_MODIFIED_DATE")) public class MedicalWard extends Auditable implements Comparable { - @EmbeddedId + @EmbeddedId MedicalWardId id; - - @Column(name="MDSRWRD_IN_QTI") + + @Column(name = "MDSRWRD_IN_QTI") private float in_quantity; - - @Column(name="MDSRWRD_OUT_QTI") + + @Column(name = "MDSRWRD_OUT_QTI") private float out_quantity; - + + /** + * Lock control + */ + @Version + @Column(name = "MDSRWRD_LOCK", columnDefinition = "INT(11) NOT NULL DEFAULT 0") + private int lock; @Transient private Double qty = 0.0; - + @Transient private volatile int hashCode; - + public MedicalWard() { super(); this.id = new MedicalWardId(); } - + public MedicalWard(Medical medical, Double qty) { super(); - this.id = new MedicalWardId(); + this.id = new MedicalWardId(); this.id.setMedical(medical); this.qty = qty; } - + public MedicalWard(Ward ward, Medical medical, float inQuantity, float outQuantity, Lot lot) { super(); - this.id = new MedicalWardId(ward, medical, lot); + this.id = new MedicalWardId(ward, medical, lot); this.in_quantity = inQuantity; this.out_quantity = outQuantity; - + } - + public MedicalWard(Medical med, double qanty, Lot lot) { super(); - this.id = new MedicalWardId(); - + this.id = new MedicalWardId(); + this.id.setMedical(med); this.id.setLot(lot); this.qty = qanty; @@ -92,33 +99,39 @@ public MedicalWard(Medical med, double qanty, Lot lot) { public MedicalWardId getId() { return id; } - + public void setId(Ward ward, Medical medical, Lot lot) { - this.id = new MedicalWardId(ward, medical, lot); + this.id = new MedicalWardId(ward, medical, lot); } - + public Lot getLot() { return id.getLot(); } - - public void setMedical(Medical medical) { - this.id.setMedical(medical); + public void setLot(Lot lot) { + id.setLot(lot); } - public Double getQty() { return qty; } - + public void setQty(Double qty) { this.qty = qty; } - + + public int getLock() { + return lock; + } + + public void setLock(int lock) { + this.lock = lock; + } + @Override public int compareTo(Object anObject) { Medical medical = id.getMedical(); if (anObject instanceof MedicalWard) { return (medical.getDescription().toUpperCase().compareTo( - ((MedicalWard) anObject).getMedical().getDescription().toUpperCase())); + ((MedicalWard) anObject).getMedical().getDescription().toUpperCase())); } return 0; } @@ -126,7 +139,7 @@ public int compareTo(Object anObject) { public Ward getWard() { return this.id.getWard(); } - + public void setWard(Ward ward) { this.id.setWard(ward); } @@ -134,51 +147,49 @@ public void setWard(Ward ward) { public Medical getMedical() { return this.id.getMedical(); } - - public void setLot(Lot lot) { - id.setLot(lot); + public void setMedical(Medical medical) { + this.id.setMedical(medical); } - public float getIn_quantity() { return this.in_quantity; } - + public void setIn_quantity(float inQuantity) { this.in_quantity = inQuantity; } - + public float getOut_quantity() { return this.out_quantity; } - + public void setOut_quantity(float outQuantity) { this.out_quantity = outQuantity; } - + @Override public boolean equals(Object obj) { if (this == obj) { return true; } - + if (!(obj instanceof MedicalWard ward)) { return false; } return (this.id.getMedical() == ward.id.getMedical()); } - + @Override public int hashCode() { - if (this.hashCode == 0) { - final int m = 23; - int c = 133; - - c = m * c + this.id.getMedical().getCode(); - - this.hashCode = c; - } - - return this.hashCode; - } + if (this.hashCode == 0) { + final int m = 23; + int c = 133; + + c = m * c + this.id.getMedical().getCode(); + + this.hashCode = c; + } + + return this.hashCode; + } } diff --git a/src/test/java/org/isf/medicalstock/Tests.java b/src/test/java/org/isf/medicalstock/Tests.java index 6ca64f7ee..2f1037703 100644 --- a/src/test/java/org/isf/medicalstock/Tests.java +++ b/src/test/java/org/isf/medicalstock/Tests.java @@ -75,6 +75,7 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -153,11 +154,6 @@ static void setUpClass() { testMedicalStock = new TestMedicalStock(); } - @BeforeEach - void setUp() throws OHException { - cleanH2InMemoryDb(); - } - @AfterAll static void tearDownClass() { testLot = null; @@ -170,6 +166,11 @@ static void tearDownClass() { testMedicalStock = null; } + @BeforeEach + void setUp() throws OHException { + cleanH2InMemoryDb(); + } + @ParameterizedTest(name = "Test with AUTOMATICLOT_IN={0}, AUTOMATICLOT_OUT={1}, AUTOMATICLOTWARD_TOWARD={2}") @MethodSource("automaticlot") void testLotGets(boolean in, boolean out, boolean toward) throws Exception { @@ -1106,7 +1107,7 @@ void testMgrValidateLotWithCostZero() { Movement movement = movementIoOperationRepository.findById(code).orElse(null); assertThat(movement).isNotNull(); Lot lot = movement.getLot(); - lot.setCost(new BigDecimal(0.0)); + lot.setCost(new BigDecimal("0.0")); lotIoOperationRepository.saveAndFlush(lot); List movements = new ArrayList<>(1); movements.add(movement); @@ -1520,7 +1521,7 @@ void testIoUpdateMedicalStockTableEmptyTableWithNegativeQuantity() throws Except method.invoke(medicalStockIoOperation, medical, newDate, quantity); } catch (InvocationTargetException e) { if (e.getCause() instanceof OHServiceException) { - throw (OHServiceException) e.getCause(); + throw e.getCause(); } else { throw e; } @@ -1529,6 +1530,20 @@ void testIoUpdateMedicalStockTableEmptyTableWithNegativeQuantity() throws Except .isInstanceOf(OHServiceException.class); } + @Test + void testMedicalWardLockGetterSetter() throws Exception { + int code = setupTestMovement(false); + Movement movement = movementIoOperationRepository.findById(code).orElse(null); + assertThat(movement).isNotNull(); + MovementType movementType = movement.getType(); + movementType.setType("-"); + MedicalWard medicalWard = new MedicalWard(movement.getWard(), movement.getMedical(), 0, 0, movement.getLot()); + + assertThat(medicalWard.getLock()).isZero(); + medicalWard.setLock(8); + assertThat(medicalWard.getLock()).isEqualTo(8); + } + private String setupTestLot(boolean usingSet) throws OHException { MedicalType medicalType = testMedicalType.setup(false); Medical medical = testMedical.setup(medicalType, false);