From d6eb2abc68130b404126a40a74f62db0b917fda9 Mon Sep 17 00:00:00 2001 From: Abinaya U <77735030+abinaya-u@users.noreply.github.com> Date: Tue, 5 Mar 2024 18:16:33 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"[Phani=20|=20Abinaya]=20|=20A-1204949?= =?UTF-8?q?175348855=20:=20Save=20Patient=20Allergies=20as=20pa=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 71a445a02d12e4c486c92ae863350f11edefd501. --- bahmni-emr-api/pom.xml | 13 ------ .../allergy/contract/AllergenRequest.java | 34 -------------- .../contract/BahmniAllergyRequest.java | 45 ------------------- .../allergy/contract/ReactionRequest.java | 25 ----------- .../contract/BahmniEncounterTransaction.java | 10 ----- ...BahmniEncounterTransactionServiceImpl.java | 36 --------------- .../BahmniEncounterTransactionBuilder.java | 6 --- ...hmniEncounterTransactionServiceImplIT.java | 36 --------------- .../src/test/resources/allergyTestData.xml | 9 ---- 9 files changed, 214 deletions(-) delete mode 100644 bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/AllergenRequest.java delete mode 100644 bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/BahmniAllergyRequest.java delete mode 100644 bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/ReactionRequest.java delete mode 100644 bahmni-emr-api/src/test/resources/allergyTestData.xml diff --git a/bahmni-emr-api/pom.xml b/bahmni-emr-api/pom.xml index 4cb2ee1efe..2b098c90ec 100644 --- a/bahmni-emr-api/pom.xml +++ b/bahmni-emr-api/pom.xml @@ -179,19 +179,6 @@ javax.el 2.2.4 - - org.openmrs.module - webservices.rest-omod - ${openMRSWebServicesVersion} - jar - provided - - - org.openmrs.module - webservices.rest-omod-common - ${openMRSWebServicesVersion} - test - diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/AllergenRequest.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/AllergenRequest.java deleted file mode 100644 index 386d67ffbf..0000000000 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/AllergenRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.openmrs.module.bahmniemrapi.allergy.contract; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class AllergenRequest { - private String allergenKind; - private String codedAllergen; - private String nonCodedAllergen; - - public String getAllergenKind() { - return allergenKind; - } - - public void setAllergenKind(String allergenKind) { - this.allergenKind = allergenKind; - } - - public String getCodedAllergen() { - return codedAllergen; - } - - public void setCodedAllergen(String codedAllergen) { - this.codedAllergen = codedAllergen; - } - - public String getNonCodedAllergen() { - return nonCodedAllergen; - } - - public void setNonCodedAllergen(String nonCodedAllergen) { - this.nonCodedAllergen = nonCodedAllergen; - } -} diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/BahmniAllergyRequest.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/BahmniAllergyRequest.java deleted file mode 100644 index c6436ba2fa..0000000000 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/BahmniAllergyRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.openmrs.module.bahmniemrapi.allergy.contract; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; - -import java.util.List; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class BahmniAllergyRequest { - private AllergenRequest allergen; - private List reactions; - private String severity; - private String comment; - - public AllergenRequest getAllergen() { - return allergen; - } - - public void setAllergen(AllergenRequest allergen) { - this.allergen = allergen; - } - - public List getReactions() { - return reactions; - } - - public void setReactions(List reactions) { - this.reactions = reactions; - } - - public String getSeverity() { - return severity; - } - - public void setSeverity(String severity) { - this.severity = severity; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } -} diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/ReactionRequest.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/ReactionRequest.java deleted file mode 100644 index b136f51234..0000000000 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/allergy/contract/ReactionRequest.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.openmrs.module.bahmniemrapi.allergy.contract; - -import org.codehaus.jackson.annotate.JsonIgnoreProperties; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class ReactionRequest { - private String reaction; - private String nonCodedReaction; - - public String getReaction() { - return reaction; - } - - public void setReaction(String reaction) { - this.reaction = reaction; - } - - public String getNonCodedReaction() { - return nonCodedReaction; - } - - public void setNonCodedReaction(String nonCodedReaction) { - this.nonCodedReaction = nonCodedReaction; - } -} diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/contract/BahmniEncounterTransaction.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/contract/BahmniEncounterTransaction.java index 09cca29b2e..bf7df9c9f2 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/contract/BahmniEncounterTransaction.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/contract/BahmniEncounterTransaction.java @@ -5,7 +5,6 @@ import org.codehaus.jackson.map.annotate.JsonSerialize; import org.joda.time.DateTime; import org.openmrs.module.bahmniemrapi.accessionnote.contract.AccessionNote; -import org.openmrs.module.bahmniemrapi.allergy.contract.BahmniAllergyRequest; import org.openmrs.module.bahmniemrapi.diagnosis.contract.BahmniDiagnosis; import org.openmrs.module.bahmniemrapi.diagnosis.contract.BahmniDiagnosisRequest; import org.openmrs.module.emrapi.encounter.domain.EncounterTransaction; @@ -31,7 +30,6 @@ public class BahmniEncounterTransaction { private String visitType; private String patientId; private String reason; - private BahmniAllergyRequest allergy; public BahmniEncounterTransaction() { @@ -385,13 +383,5 @@ private EncounterTransaction.DrugOrder getOldestDrugOrder() { public boolean isAssociatedToPatientProgram() { return StringUtils.isNotBlank(getPatientProgramUuid()); } - - public BahmniAllergyRequest getAllergy() { - return allergy; - } - - public void setAllergy(BahmniAllergyRequest allergy) { - this.allergy = allergy; - } } diff --git a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImpl.java b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImpl.java index ba9893a3f2..9af62e65d8 100644 --- a/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImpl.java +++ b/bahmni-emr-api/src/main/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImpl.java @@ -7,11 +7,6 @@ import org.openmrs.Patient; import org.openmrs.Visit; import org.openmrs.VisitType; -import org.openmrs.Concept; -import org.openmrs.Allergen; -import org.openmrs.AllergenType; -import org.openmrs.Allergy; -import org.openmrs.AllergyReaction; import org.openmrs.api.EncounterService; import org.openmrs.api.LocationService; import org.openmrs.api.PatientService; @@ -20,9 +15,6 @@ import org.openmrs.api.context.Context; import org.openmrs.api.impl.BaseOpenmrsService; import org.openmrs.module.bahmniemrapi.BahmniEmrAPIException; -import org.openmrs.module.bahmniemrapi.allergy.contract.AllergenRequest; -import org.openmrs.module.bahmniemrapi.allergy.contract.BahmniAllergyRequest; -import org.openmrs.module.bahmniemrapi.allergy.contract.ReactionRequest; import org.openmrs.module.bahmniemrapi.encountertransaction.command.EncounterDataPostSaveCommand; import org.openmrs.module.bahmniemrapi.encountertransaction.command.EncounterDataPreSaveCommand; import org.openmrs.module.bahmniemrapi.encountertransaction.command.impl.BahmniVisitAttributeService; @@ -48,8 +40,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.ArrayList; -import java.util.Collections; @Transactional public class BahmniEncounterTransactionServiceImpl extends BaseOpenmrsService implements BahmniEncounterTransactionService { @@ -138,9 +128,6 @@ public BahmniEncounterTransaction save(BahmniEncounterTransaction bahmniEncounte //Get the saved encounter transaction from emr-api String encounterUuid = encounterTransaction.getEncounterUuid(); Encounter currentEncounter = encounterService.getEncounterByUuid(encounterUuid); - if(bahmniEncounterTransaction.getAllergy() != null){ - handleAllergy(bahmniEncounterTransaction, currentEncounter, patient); - } boolean includeAll = false; EncounterTransaction updatedEncounterTransaction = encounterTransactionMapper.map(currentEncounter, includeAll); @@ -151,29 +138,6 @@ public BahmniEncounterTransaction save(BahmniEncounterTransaction bahmniEncounte return bahmniEncounterTransactionMapper.map(updatedEncounterTransaction, includeAll); } - private void handleAllergy(BahmniEncounterTransaction bahmniEncounterTransaction, Encounter currentEncounter, Patient patient) { - - BahmniAllergyRequest allergyRequest = bahmniEncounterTransaction.getAllergy(); - AllergenRequest allergenRequest = allergyRequest.getAllergen(); - Concept allergenConcept = Context.getConceptService().getConceptByUuid(allergenRequest.getCodedAllergen()); - Allergen allergen = new Allergen(AllergenType.valueOf(allergenRequest.getAllergenKind()), allergenConcept,allergenRequest.getNonCodedAllergen()); - Concept severityConcept = Context.getConceptService().getConceptByUuid(allergyRequest.getSeverity()); - List reactions = allergyRequest.getReactions(); - List allergyReactions = new ArrayList<>(); - Allergy allergy = new Allergy(patient, allergen, severityConcept, allergyRequest.getComment(), Collections.emptyList()); - - reactions.forEach(reaction -> { - Concept reactionConcept = Context.getConceptService().getConceptByUuid(reaction.getReaction()); - AllergyReaction allergyReaction = new AllergyReaction(allergy, reactionConcept, reaction.getNonCodedReaction()); - allergyReactions.add(allergyReaction); - }); - - allergy.setEncounter(currentEncounter); - allergy.setReactions(allergyReactions); - - patientService.saveAllergy(allergy); - } - private void setEncounterTypeUuid(BahmniEncounterTransaction bahmniEncounterTransaction) { String encounterUuid = bahmniEncounterTransaction.getEncounterUuid(); if (!StringUtils.isBlank(encounterUuid)) { diff --git a/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/builder/BahmniEncounterTransactionBuilder.java b/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/builder/BahmniEncounterTransactionBuilder.java index 41b0e8ffb2..8f36a59cbb 100644 --- a/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/builder/BahmniEncounterTransactionBuilder.java +++ b/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/builder/BahmniEncounterTransactionBuilder.java @@ -1,6 +1,5 @@ package org.openmrs.module.bahmniemrapi.builder; -import org.openmrs.module.bahmniemrapi.allergy.contract.BahmniAllergyRequest; import org.openmrs.module.bahmniemrapi.diagnosis.contract.BahmniDiagnosisRequest; import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniEncounterTransaction; import org.openmrs.module.bahmniemrapi.encountertransaction.contract.BahmniObservation; @@ -83,9 +82,4 @@ public BahmniEncounterTransactionBuilder withDiagnoses(BahmniDiagnosisRequest... bahmniEncounterTransaction.setBahmniDiagnoses(Arrays.asList(bahmniDiagnosisRequests)); return this; } - - public BahmniEncounterTransactionBuilder withBahmniAllergyRequest(BahmniAllergyRequest bahmniAllergyRequest) { - bahmniEncounterTransaction.setAllergy(bahmniAllergyRequest); - return this; - } } diff --git a/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImplIT.java b/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImplIT.java index 53f759032e..2d9f0a42ba 100644 --- a/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImplIT.java +++ b/bahmni-emr-api/src/test/java/org/openmrs/module/bahmniemrapi/encountertransaction/impl/BahmniEncounterTransactionServiceImplIT.java @@ -10,16 +10,12 @@ import org.openmrs.Patient; import org.openmrs.Visit; import org.openmrs.VisitAttribute; -import org.openmrs.Allergies; import org.openmrs.api.EncounterService; import org.openmrs.api.OrderService; import org.openmrs.api.PatientService; import org.openmrs.api.VisitService; import org.openmrs.api.context.Context; import org.openmrs.module.bahmniemrapi.BaseIntegrationTest; -import org.openmrs.module.bahmniemrapi.allergy.contract.AllergenRequest; -import org.openmrs.module.bahmniemrapi.allergy.contract.BahmniAllergyRequest; -import org.openmrs.module.bahmniemrapi.allergy.contract.ReactionRequest; import org.openmrs.module.bahmniemrapi.builder.BahmniDiagnosisRequestBuilder; import org.openmrs.module.bahmniemrapi.builder.BahmniEncounterTransactionBuilder; import org.openmrs.module.bahmniemrapi.builder.BahmniObservationBuilder; @@ -91,7 +87,6 @@ public void setUp() throws Exception { executeDataSet("visitAttributeDataSet.xml"); executeDataSet("drugOrderTestData.xml"); executeDataSet("concepts.xml"); - executeDataSet("allergyTestData.xml"); } @Test @@ -689,37 +684,6 @@ public void shouldSaveDiagnoses(){ assertThat(savedEncounter.getAllObs(false).size(), is(equalTo(6))); } - @Test - public void shouldSaveAllergyForAPatient() { - - BahmniAllergyRequest bahmniAllergyRequest = new BahmniAllergyRequest(); - AllergenRequest allergenRequest = new AllergenRequest(); - allergenRequest.setAllergenKind("DRUG"); - allergenRequest.setCodedAllergen("a0a690fd-75a4-447t-bmc6-4e1c15f4ed6b"); - - ReactionRequest reactionRequest = new ReactionRequest(); - reactionRequest.setReaction("a0a690fd-75a4-447t-bmc6-4e1c15f4ed6c"); - bahmniAllergyRequest.setAllergen(allergenRequest); - bahmniAllergyRequest.setReactions(Arrays.asList(reactionRequest)); - bahmniAllergyRequest.setSeverity("a0a690fd-75a4-447t-bmc6-4e1c15f4ed6d"); - bahmniAllergyRequest.setComment("Onset Date"); - - BahmniEncounterTransaction bahmniEncounterTransaction = new BahmniEncounterTransactionBuilder() - .withVisitTypeUuid(VISIT_TYPE_UUID) - .withEncounterTypeUuid(ENCOUNTER_TYPE_UUID) - .withPatientUuid(PATIENT_UUID) - .withVisitUuid(VISIT_UUID) - .withBahmniAllergyRequest(bahmniAllergyRequest) - .build(); - - BahmniEncounterTransaction encounterTransaction = bahmniEncounterTransactionService.save(bahmniEncounterTransaction); - Context.flushSession(); - Context.clearSession(); - Allergies patientAllergies = patientService.getAllergies(patientService.getPatientByUuid(PATIENT_UUID)); - assertThat(patientAllergies.size(), is(equalTo(1))); - - } - @Test public void shouldRunAllRegisteredHandlers() { Date obsDate = new Date(); diff --git a/bahmni-emr-api/src/test/resources/allergyTestData.xml b/bahmni-emr-api/src/test/resources/allergyTestData.xml deleted file mode 100644 index 016d3186f5..0000000000 --- a/bahmni-emr-api/src/test/resources/allergyTestData.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file