From 9f2ae92380988b6bd2c49c69d79ebb981243ff79 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 12 Nov 2024 10:43:25 +0100 Subject: [PATCH 1/7] update(OH2-409): Add lock field to medical ward --- sql/step_04_all_following_steps.sql | 1 + ...step_a112_add_medical_ward_lock_column.sql | 6 + .../medicalstockward/model/MedicalWard.java | 109 ++++++++++-------- 3 files changed, 67 insertions(+), 49 deletions(-) create mode 100644 sql/step_a112_add_medical_ward_lock_column.sql diff --git a/sql/step_04_all_following_steps.sql b/sql/step_04_all_following_steps.sql index 8ab9b42e5..786eb31ef 100644 --- a/sql/step_04_all_following_steps.sql +++ b/sql/step_04_all_following_steps.sql @@ -105,3 +105,4 @@ source step_a108_audit_dicom_type_and_dicom_data.sql; source step_a109_update_user_settings_table_constraints_and_add_usergroups_permissions.sql; source step_a110_update_operations_table_change_ope_for_to_enum.sql; source step_a111_add_missing_lock_columns.sql; +source step_a112_add_medical_ward_lock_column.sql; \ No newline at end of file diff --git a/sql/step_a112_add_medical_ward_lock_column.sql b/sql/step_a112_add_medical_ward_lock_column.sql new file mode 100644 index 000000000..e63b92d60 --- /dev/null +++ b/sql/step_a112_add_medical_ward_lock_column.sql @@ -0,0 +1,6 @@ +-- +-- Add lock (version) column in oh_medicaldsrward +-- + +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..7859e830d 100644 --- a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java +++ b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java @@ -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") + private Integer 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 Integer getLock() { + return lock; + } + + public void setLock(Integer 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; + } } From 8c27ad23e6370e618f48ecfc57e734f95bb0be6f Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 12 Nov 2024 10:54:43 +0100 Subject: [PATCH 2/7] chore: Update license header --- src/main/java/org/isf/medicalstockward/model/MedicalWard.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java index 7859e830d..525de2b68 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. * From 2d01835e72649051504a0e6c41a7b0b9bf5ee253 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 12 Nov 2024 15:53:25 +0100 Subject: [PATCH 3/7] chore: Update demo data and fix tests --- sql/load_demo_data.sql | 30 +++++++++---------- .../medicalstockward/model/MedicalWard.java | 8 ++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/sql/load_demo_data.sql b/sql/load_demo_data.sql index 8c11f7557..945f3b395 100644 --- a/sql/load_demo_data.sql +++ b/sql/load_demo_data.sql @@ -2991,21 +2991,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/src/main/java/org/isf/medicalstockward/model/MedicalWard.java b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java index 525de2b68..ad6e2154e 100644 --- a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java +++ b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java @@ -59,8 +59,8 @@ public class MedicalWard extends Auditable implements Comparable * Lock control */ @Version - @Column(name = "MDSRWRD_LOCK") - private Integer lock; + @Column(name = "MDSRWRD_LOCK", columnDefinition = "INT(11) NOT NULL DEFAULT 0") + private int lock; @Transient private Double qty = 0.0; @@ -118,11 +118,11 @@ public void setQty(Double qty) { this.qty = qty; } - public Integer getLock() { + public int getLock() { return lock; } - public void setLock(Integer lock) { + public void setLock(int lock) { this.lock = lock; } From abec92286a8815475b31ef1617a652a34637ebfe Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 13 Nov 2024 15:56:05 +0100 Subject: [PATCH 4/7] chore: Add medical ward lock getter/setter test --- src/test/java/org/isf/medicalstock/Tests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test/java/org/isf/medicalstock/Tests.java b/src/test/java/org/isf/medicalstock/Tests.java index 6ca64f7ee..02c0caef2 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; @@ -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()).isEqualTo(0); + 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); From a21fcc69853c4322f71225a687b378d5cd33011c Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Wed, 13 Nov 2024 15:56:35 +0100 Subject: [PATCH 5/7] chore: Reformat code --- src/test/java/org/isf/medicalstock/Tests.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/isf/medicalstock/Tests.java b/src/test/java/org/isf/medicalstock/Tests.java index 02c0caef2..a904ca988 100644 --- a/src/test/java/org/isf/medicalstock/Tests.java +++ b/src/test/java/org/isf/medicalstock/Tests.java @@ -153,12 +153,6 @@ static void setUpClass() { testSupplier = new TestSupplier(); testMedicalStock = new TestMedicalStock(); } - - @BeforeEach - void setUp() throws OHException { - cleanH2InMemoryDb(); - } - @AfterAll static void tearDownClass() { testLot = null; @@ -170,7 +164,10 @@ static void tearDownClass() { testSupplier = null; 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 { @@ -1107,7 +1104,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); @@ -1521,7 +1518,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; } From 00e2b38b6f67ade30523bb0581cdfa1d3321bde3 Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Thu, 14 Nov 2024 08:27:21 +0100 Subject: [PATCH 6/7] chore: Reformat and refactor code --- src/test/java/org/isf/medicalstock/Tests.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/isf/medicalstock/Tests.java b/src/test/java/org/isf/medicalstock/Tests.java index a904ca988..2f1037703 100644 --- a/src/test/java/org/isf/medicalstock/Tests.java +++ b/src/test/java/org/isf/medicalstock/Tests.java @@ -153,6 +153,7 @@ static void setUpClass() { testSupplier = new TestSupplier(); testMedicalStock = new TestMedicalStock(); } + @AfterAll static void tearDownClass() { testLot = null; @@ -164,10 +165,12 @@ static void tearDownClass() { testSupplier = null; 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 { @@ -1536,7 +1539,7 @@ void testMedicalWardLockGetterSetter() throws Exception { movementType.setType("-"); MedicalWard medicalWard = new MedicalWard(movement.getWard(), movement.getMedical(), 0, 0, movement.getLot()); - assertThat(medicalWard.getLock()).isEqualTo(0); + assertThat(medicalWard.getLock()).isZero(); medicalWard.setLock(8); assertThat(medicalWard.getLock()).isEqualTo(8); } From 2773aa282e1fea04b62f1b2d254f7993d71d934e Mon Sep 17 00:00:00 2001 From: SteveGT96 Date: Tue, 19 Nov 2024 15:31:51 +0100 Subject: [PATCH 7/7] chore: Reformat and refactor code --- .../java/org/isf/medicalstockward/model/MedicalWard.java | 5 +++++ src/test/java/org/isf/medicalstock/Tests.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java index ad6e2154e..71bf27736 100644 --- a/src/main/java/org/isf/medicalstockward/model/MedicalWard.java +++ b/src/main/java/org/isf/medicalstockward/model/MedicalWard.java @@ -61,6 +61,7 @@ public class MedicalWard extends Auditable implements Comparable @Version @Column(name = "MDSRWRD_LOCK", columnDefinition = "INT(11) NOT NULL DEFAULT 0") private int lock; + @Transient private Double qty = 0.0; @@ -107,9 +108,11 @@ public void setId(Ward ward, Medical medical, Lot lot) { public Lot getLot() { return id.getLot(); } + public void setLot(Lot lot) { id.setLot(lot); } + public Double getQty() { return qty; } @@ -147,9 +150,11 @@ public void setWard(Ward ward) { public Medical getMedical() { return this.id.getMedical(); } + public void setMedical(Medical medical) { this.id.setMedical(medical); } + public float getIn_quantity() { return this.in_quantity; } diff --git a/src/test/java/org/isf/medicalstock/Tests.java b/src/test/java/org/isf/medicalstock/Tests.java index 2f1037703..26f876329 100644 --- a/src/test/java/org/isf/medicalstock/Tests.java +++ b/src/test/java/org/isf/medicalstock/Tests.java @@ -1107,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(BigDecimal.ZERO); lotIoOperationRepository.saveAndFlush(lot); List movements = new ArrayList<>(1); movements.add(movement);