Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Phani | Abinaya] | A-1204949175348855 : Save Patient Allergies as part of Bahmni Encounter Transaction" #255

Open
wants to merge 1 commit into
base: Bahmni-IPD-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions bahmni-emr-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,6 @@
<artifactId>javax.el</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest-omod</artifactId>
<version>${openMRSWebServicesVersion}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.openmrs.module</groupId>
<artifactId>webservices.rest-omod-common</artifactId>
<version>${openMRSWebServicesVersion}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,7 +30,6 @@ public class BahmniEncounterTransaction {
private String visitType;
private String patientId;
private String reason;
private BahmniAllergyRequest allergy;


public BahmniEncounterTransaction() {
Expand Down Expand Up @@ -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;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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<ReactionRequest> reactions = allergyRequest.getReactions();
List<AllergyReaction> 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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,7 +87,6 @@ public void setUp() throws Exception {
executeDataSet("visitAttributeDataSet.xml");
executeDataSet("drugOrderTestData.xml");
executeDataSet("concepts.xml");
executeDataSet("allergyTestData.xml");
}

@Test
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 0 additions & 9 deletions bahmni-emr-api/src/test/resources/allergyTestData.xml

This file was deleted.

Loading