From c0b4f4ebd6b0804df748e3fd1be238ccce618895 Mon Sep 17 00:00:00 2001 From: Ismael Sarmento Date: Tue, 1 Sep 2015 17:59:14 -0400 Subject: [PATCH] minor fixes in object instantiations --- .../dstu2/entities/ConditionOccurrence.java | 15 +++---- .../DrugExposurePrescriptionDispensed.java | 9 ++-- .../DrugExposurePrescriptionWritten.java | 12 ++---- .../i3l/fhir/dstu2/entities/Observation.java | 18 +++----- .../i3l/fhir/dstu2/entities/Person.java | 3 +- .../providers/JpaResourceProviderDstu2.java | 43 ++++++++----------- 6 files changed, 38 insertions(+), 62 deletions(-) diff --git a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/ConditionOccurrence.java b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/ConditionOccurrence.java index 857f95d..74544fa 100644 --- a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/ConditionOccurrence.java +++ b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/ConditionOccurrence.java @@ -214,16 +214,14 @@ public IResourceEntity constructEntityFromResource(IResource resource) { Condition condition = (Condition) resource; Long patientRef = condition.getPatient().getReference().getIdPartAsLong(); if(patientRef != null){ - if(this.person == null) - this.person = new Person(); + this.person = new Person(); this.person.setId(patientRef); } OmopConceptMapping ocm = OmopConceptMapping.getInstance(); Long conditionConceptRef = ocm.get(condition.getCode().getCodingFirstRep().getCode()); if(conditionConceptRef != null){ - if(this.conditionConcept == null) - this.conditionConcept = new Concept(); + this.conditionConcept = new Concept(); this.conditionConcept.setId(conditionConceptRef); } IDatatype onSetDate = condition.getOnset(); @@ -237,15 +235,13 @@ public IResourceEntity constructEntityFromResource(IResource resource) { } Long encounterReference = condition.getEncounter().getReference().getIdPartAsLong(); - if(this.conditionTypeConcept == null) - this.conditionTypeConcept = new Concept(); + this.conditionTypeConcept = new Concept(); if (encounterReference == null) { // These concept_id's are defined for Omop 4.0 and have concet_code = "OMOP generated" this.conditionTypeConcept.setId(Omop4ConceptsFixedIds.EHR_PROBLEM_ENTRY.getConceptId()); } else { this.conditionTypeConcept.setId(Omop4ConceptsFixedIds.PRIMARY_CONDITION.getConceptId()); - if(this.encounter == null) - this.encounter = new VisitOccurrence(); + this.encounter = new VisitOccurrence(); this.encounter.setId(encounterReference); } @@ -256,8 +252,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { if (asserterReference.getIdPartAsLong() != null && asserterReference.getResourceType() != null && asserterReference.getResourceType().equalsIgnoreCase(Provider.RESOURCE_TYPE)) { long providerId = asserterReference.getIdPartAsLong(); - if(this.provider == null) - this.provider = new Provider(); + this.provider = new Provider(); this.provider.setId(providerId); } diff --git a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionDispensed.java b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionDispensed.java index c15be24..f2f68ab 100644 --- a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionDispensed.java +++ b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionDispensed.java @@ -156,8 +156,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { MedicationDispense md = (MedicationDispense) resource; /* Set drup exposure type */ - if(this.drugExposureType == null) - this.drugExposureType = new Concept(); + this.drugExposureType = new Concept(); Long destinationRef = md.getDestination().getReference().getIdPartAsLong(); if(destinationRef != null){ this.drugExposureType.setId(Omop4ConceptsFixedIds.PRESCRIPTION_DISP_MAIL_ORDER.getConceptId()); @@ -167,15 +166,13 @@ public IResourceEntity constructEntityFromResource(IResource resource) { /* Set drug concept(medication) */ Long medicationRef = md.getMedication().getReference().getIdPartAsLong(); if(medicationRef != null){ - if(this.medication == null) - this.medication = new Concept(); + this.medication = new Concept(); this.medication.setId(medicationRef); } /* Set patient */ Long patientRef = md.getPatient().getReference().getIdPartAsLong(); if(patientRef != null){ - if(this.person == null) - this.person = new Person(); + this.person = new Person(); this.person.setId(patientRef); } diff --git a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionWritten.java b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionWritten.java index a227264..168386a 100644 --- a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionWritten.java +++ b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/DrugExposurePrescriptionWritten.java @@ -287,30 +287,26 @@ public IResource getRelatedResource() { public IResourceEntity constructEntityFromResource(IResource resource) { MedicationPrescription mp = (MedicationPrescription) resource; /* Set drup exposure type */ - if(this.drugExposureType == null) - this.drugExposureType = new Concept(); + this.drugExposureType = new Concept(); this.drugExposureType.setId(Omop4ConceptsFixedIds.PRESCRIPTION_WRITTEN.getConceptId()); /* Set start date of prescription */ this.startDate = mp.getDateWritten(); /* Set VisitOccurrence */ Long encounterRef = mp.getEncounter().getReference().getIdPartAsLong(); if(encounterRef != null){ - if(this.visitOccurrence == null) - this.visitOccurrence = new VisitOccurrenceComplement(); + this.visitOccurrence = new VisitOccurrenceComplement(); this.visitOccurrence.setId(encounterRef); } /* Set Medication */ Long medicationRef = mp.getMedication().getReference().getIdPartAsLong(); if(medicationRef != null){ - if(this.medication == null) - this.medication = new Concept(); + this.medication = new Concept(); this.medication.setId(medicationRef); } /* Set patient */ Long patientRef = mp.getPatient().getReference().getIdPartAsLong(); if(patientRef != null){ - if(this.person == null) - this.person = new Person(); + this.person = new Person(); this.person.setId(patientRef); } return this; diff --git a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Observation.java b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Observation.java index e07b9e5..b325e5d 100644 --- a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Observation.java +++ b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Observation.java @@ -297,8 +297,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { IdDt reference = observation.getSubject().getReference(); if(reference.getIdPartAsLong() != null){ if("Patient".equals(reference.getResourceType())){ - if(this.person ==null) - this.person = new Person(); + this.person = new Person(); this.person.setId(reference.getIdPartAsLong()); } else if("Group".equals(reference.getResourceType())){ // @@ -312,21 +311,18 @@ public IResourceEntity constructEntityFromResource(IResource resource) { /*Set visit occurrence */ Long visitOccurrenceId = observation.getEncounter().getReference().getIdPartAsLong(); if(visitOccurrenceId != null){ - if(this.visitOccurrence == null) - this.visitOccurrence = new VisitOccurrence(); + this.visitOccurrence = new VisitOccurrence(); this.visitOccurrence.setId(visitOccurrenceId); } Long observationConceptId = ocm.get(observation.getCode().getCodingFirstRep().getCode(), OmopConceptMapping.LOINC_CODE); if(observationConceptId != null){ - if(this.observationConcept == null) - this.observationConcept = new Concept(); + this.observationConcept = new Concept(); this.observationConcept.setId(observationConceptId); } /* Set the type of the observation */ - if(this.type == null) - this.type = new Concept(); + this.type = new Concept(); if(observation.getMethod().getCodingFirstRep() != null){ this.type.setId(Omop4ConceptsFixedIds.OBSERVATION_FROM_LAB_NUMERIC_RESULT.getConceptId()); //assuming all results on this table are quantitative: http://hl7.org/fhir/2015May/valueset-observation-methods.html } else { @@ -339,8 +335,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { Long unitId = ocm.get(((QuantityDt) value).getUnits(), OmopConceptMapping.UCUM_CODE, OmopConceptMapping.UCUM_CODE_STANDARD, OmopConceptMapping.UCUM_CODE_CUSTOM); this.valueAsNumber = ((QuantityDt) value).getValue(); if(unitId != null){ - if(this.unit == null) - this.unit = new Concept(); + this.unit = new Concept(); this.unit.setId(unitId); } this.rangeHigh = observation.getReferenceRangeFirstRep().getHigh().getValue(); @@ -348,8 +343,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { } else if(value instanceof CodeableConceptDt){ Long valueAsConceptId = ocm.get(((CodeableConceptDt) value).getCodingFirstRep().getCode(), OmopConceptMapping.CLINICAL_FINDING); if(valueAsConceptId != null){ - if(this.valueAsConcept == null) - this.valueAsConcept = new Concept(); + this.valueAsConcept = new Concept(); this.valueAsConcept.setId(valueAsConceptId); } } else { diff --git a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Person.java b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Person.java index 9a9ff65..155b4eb 100644 --- a/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Person.java +++ b/gt-fhir-entities/src/main/java/edu/gatech/i3l/fhir/dstu2/entities/Person.java @@ -313,8 +313,7 @@ public IResourceEntity constructEntityFromResource(IResource resource) { this.dayOfBirth = c.get(Calendar.DAY_OF_MONTH); //TODO set deceased value in Person; Set gender concept (source value is set); list of addresses (?) // this.death = patient.getDeceased(); - if(this.genderConcept == null) - this.genderConcept = new Concept(); + this.genderConcept = new Concept(); this.genderConcept.setId(OmopConceptMapping.getInstance().get(patient.getGender(), OmopConceptMapping.GENDER)); LocationComplement location; diff --git a/gt-fhir-webapp/src/main/java/edu/gatech/i3l/fhir/jpa/providers/JpaResourceProviderDstu2.java b/gt-fhir-webapp/src/main/java/edu/gatech/i3l/fhir/jpa/providers/JpaResourceProviderDstu2.java index 7b07573..98395d1 100644 --- a/gt-fhir-webapp/src/main/java/edu/gatech/i3l/fhir/jpa/providers/JpaResourceProviderDstu2.java +++ b/gt-fhir-webapp/src/main/java/edu/gatech/i3l/fhir/jpa/providers/JpaResourceProviderDstu2.java @@ -1,8 +1,6 @@ package edu.gatech.i3l.fhir.jpa.providers; -import java.util.Date; - import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Required; @@ -13,17 +11,14 @@ import ca.uhn.fhir.rest.annotation.ConditionalUrlParam; import ca.uhn.fhir.rest.annotation.Create; import ca.uhn.fhir.rest.annotation.Delete; -import ca.uhn.fhir.rest.annotation.History; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.Read; import ca.uhn.fhir.rest.annotation.ResourceParam; -import ca.uhn.fhir.rest.annotation.Since; import ca.uhn.fhir.rest.annotation.Update; import ca.uhn.fhir.rest.annotation.Validate; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.server.EncodingEnum; -import ca.uhn.fhir.rest.server.IBundleProvider; import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import edu.gatech.i3l.fhir.jpa.dao.IFhirResourceDao; @@ -49,25 +44,25 @@ public IFhirResourceDao getDao() { return myDao; } - @History - public IBundleProvider getHistoryForResourceInstance(HttpServletRequest theRequest, @IdParam IdDt theId, @Since Date theDate) { - startRequest(theRequest); - try { - return myDao.history(theId, theDate); - } finally { - endRequest(theRequest); - } - } - - @History - public IBundleProvider getHistoryForResourceType(HttpServletRequest theRequest, @Since Date theDate) { - startRequest(theRequest); - try { - return myDao.history(theDate); - } finally { - endRequest(theRequest); - } - } +// @History +// public IBundleProvider getHistoryForResourceInstance(HttpServletRequest theRequest, @IdParam IdDt theId, @Since Date theDate) { +// startRequest(theRequest); +// try { +// return myDao.history(theId, theDate); +// } finally { +// endRequest(theRequest); +// } +// } +// +// @History +// public IBundleProvider getHistoryForResourceType(HttpServletRequest theRequest, @Since Date theDate) { +// startRequest(theRequest); +// try { +// return myDao.history(theDate); +// } finally { +// endRequest(theRequest); +// } +// } @Override public Class getResourceType() {