Skip to content

Commit

Permalink
3.4.8 Build
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMayfield committed Jan 23, 2018
1 parent 0f1939b commit c21e8ff
Showing 1 changed file with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package uk.nhs.careconnect.ri.daointerface.transforms;

import org.apache.commons.collections4.Transformer;
import org.hl7.fhir.dstu3.model.CarePlan;
import org.hl7.fhir.dstu3.model.CodeableConcept;
import org.hl7.fhir.dstu3.model.Meta;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.*;
import org.springframework.stereotype.Component;

import uk.nhs.careconnect.ri.entity.carePlan.CarePlanCategory;
import uk.nhs.careconnect.ri.entity.carePlan.CarePlanEntity;
import uk.nhs.careconnect.ri.entity.carePlan.CarePlanIdentifier;
import uk.nhs.careconnect.ri.entity.carePlan.*;

@Component
public class CarePlanEntityToFHIRCarePlanTransformer implements Transformer<CarePlanEntity, CarePlan> {
Expand Down Expand Up @@ -40,6 +35,14 @@ public CarePlan transform(final CarePlanEntity carePlanEntity) {
.setSubject(new Reference("Patient/"+carePlanEntity.getPatient().getId())
.setDisplay(carePlanEntity.getPatient().getNames().get(0).getDisplayName()));
}

if (carePlanEntity.getStatus() != null) {
carePlan.setStatus(carePlanEntity.getStatus());
}

if (carePlanEntity.getIntent() != null) {
carePlan.setIntent(carePlanEntity.getIntent());
}


for (CarePlanCategory categoryEntity : carePlanEntity.getCategories()) {
Expand All @@ -48,7 +51,46 @@ public CarePlan transform(final CarePlanEntity carePlanEntity) {
.setSystem(categoryEntity.getCategory().getSystem())
.setCode(categoryEntity.getCategory().getCode())
.setDisplay(categoryEntity.getCategory().getDisplay());
carePlan.addCategory(concept);
}

if (carePlanEntity.getContextEncounter()!=null) {
carePlan.setContext(new Reference("Encounter/"+carePlanEntity.getContextEncounter().getId()));
}
if (carePlanEntity.getContextEpisodeOfCare()!=null) {
carePlan.setContext(new Reference("EpisodeOfCare/"+carePlanEntity.getContextEpisodeOfCare().getId()));
}
Period period = carePlan.getPeriod();
if (carePlanEntity.getPeriodStartDateTime() != null) {
period.setStart(carePlanEntity.getPeriodStartDateTime());
}
if (carePlanEntity.getPeriodEndDateTime() != null) {
period.setEnd(carePlanEntity.getPeriodEndDateTime());
}

for (CarePlanCondition condition : carePlanEntity.getAddresses()) {
carePlan.addAddresses(new Reference("Condition/"+condition.getCondition().getId())
.setDisplay(condition.getCondition().getCode().getDisplay()));
}

for (CarePlanActivity activity : carePlanEntity.getActivities()) {
CarePlan.CarePlanActivityComponent activityComponent = carePlan.addActivity();
for (CarePlanActivityDetail carePlanActivityDetail : activity.getDetails()) {
CarePlan.CarePlanActivityDetailComponent activityDetailComponent = activityComponent.getDetail();
activityDetailComponent.getCode().addCoding()
.setCode(carePlanActivityDetail.getCode().getCode())
.setDisplay(carePlanActivityDetail.getCode().getDisplay())
.setSystem(carePlanActivityDetail.getCode().getSystem());
if (carePlanActivityDetail.getStatus() != null) {
activityDetailComponent.setStatus(carePlanActivityDetail.getStatus());
}
if (carePlanActivityDetail.getCategory() != null) {
activityDetailComponent.getCategory().addCoding()
.setCode(carePlanActivityDetail.getCategory().getCode())
.setDisplay(carePlanActivityDetail.getCategory().getDisplay())
.setSystem(carePlanActivityDetail.getCategory().getSystem());
}

}
}

for (CarePlanIdentifier identifier : carePlanEntity.getIdentifiers()) {
Expand Down

0 comments on commit c21e8ff

Please sign in to comment.