Skip to content

Commit

Permalink
minor fixes in object instantiations
Browse files Browse the repository at this point in the history
  • Loading branch information
ismael-sarmento-jr committed Sep 1, 2015
1 parent 2595bcc commit c0b4f4e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())){
//
Expand All @@ -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 {
Expand All @@ -339,17 +335,15 @@ 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();
this.rangeLow = observation.getReferenceRangeFirstRep().getLow().getValue();
} 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -49,25 +44,25 @@ public IFhirResourceDao<T> 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<? extends IResource> getResourceType() {
Expand Down

0 comments on commit c0b4f4e

Please sign in to comment.