org.hl7.fhir.dstu3.model.DomainResource Java Examples

The following examples show how to use org.hl7.fhir.dstu3.model.DomainResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public ConditionCategory getCategory(DomainResource resource){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	if (!fhirCondition.getCategory().isEmpty()) {
		List<Coding> coding = fhirCondition.getCategory().get(0).getCoding();
		if (!coding.isEmpty()) {
			for (Coding categoryCoding : coding) {
				if (categoryCoding.getSystem()
					.equals("http://hl7.org/fhir/condition-category")) {
					return (ConditionCategory) categoryMapping
						.getLocalEnumValueByCode(categoryCoding.getCode().toUpperCase());
				}
			}
		}
	}
	return ConditionCategory.UNKNOWN;
}
 
Example #2
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public Optional<String> getEnd(DomainResource resource){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	try {
		if (fhirCondition.hasAbatementDateTimeType()) {
			DateTimeType dateTime = fhirCondition.getAbatementDateTimeType();
			if (dateTime != null) {
				Date date = dateTime.getValue();
				SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
				return Optional.of(format.format(date));
			}
		} else if (fhirCondition.hasAbatementStringType()) {
			return Optional.of(fhirCondition.getAbatementStringType().getValue());
		}
	} catch (FHIRException e) {
		LoggerFactory.getLogger(ConditionAccessor.class).error("Could not access end.", e);
	}
	return Optional.empty();
}
 
Example #3
Source File: ObservationAccessor.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void setCategory(DomainResource resource, ObservationCategory category){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	CodeableConcept categoryCode = new CodeableConcept();
	if (category.name().startsWith("SOAP_")) {
		// elexis soap categories
		categoryCode.setCoding(
			Collections.singletonList(new Coding(IdentifierSystem.ELEXIS_SOAP.getSystem(),
				category.getCode(), category.getLocalized())));
	} else {
		org.hl7.fhir.dstu3.model.codesystems.ObservationCategory fhirCategoryCode =
			(org.hl7.fhir.dstu3.model.codesystems.ObservationCategory) categoryMapping
				.getFhirEnumValueByEnum(category);
		if (fhirCategoryCode != null) {
			// lookup matching fhir category
			categoryCode
				.setCoding(Collections.singletonList(new Coding(fhirCategoryCode.getSystem(),
					fhirCategoryCode.toCode(), fhirCategoryCode.getDisplay())));
		} else {
			throw new IllegalStateException("Unknown observation category " + category);
		}
	}
	if (!categoryCode.getCoding().isEmpty()) {
		fhirObservation.setCategory(Collections.singletonList(categoryCode));
	}
}
 
Example #4
Source File: ShExGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
private ValueSet resolveBindingReference(DomainResource ctxt, Type reference) {
  if (reference instanceof UriType) {
    return context.fetchResource(ValueSet.class, ((UriType) reference).getValue().toString());
  }
  else if (reference instanceof Reference) {
    String s = ((Reference) reference).getReference();
    if (s.startsWith("#")) {
      for (Resource c : ctxt.getContained()) {
        if (c.getId().equals(s.substring(1)) && (c instanceof ValueSet))
          return (ValueSet) c;
      }
      return null;
    } else {
      return context.fetchResource(ValueSet.class, ((Reference) reference).getReference());
    }
  }
  else
    return null;
}
 
Example #5
Source File: EncounterAccessor.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public void setConsultationId(DomainResource resource, String consultationId) {
	org.hl7.fhir.dstu3.model.Encounter fhirEncounter = (org.hl7.fhir.dstu3.model.Encounter) resource;
	boolean identifierFound = false;
	List<Identifier> existing = fhirEncounter.getIdentifier();
	for (Identifier existingIdentifier : existing) {
		if (IdentifierSystem.ELEXIS_CONSID.getSystem().equals(existingIdentifier.getSystem())) {
			existingIdentifier.setValue(consultationId);
			identifierFound = true;
			break;
		}
	}
	if (!identifierFound) {
		Identifier identifier = fhirEncounter.addIdentifier();
		identifier.setSystem(IdentifierSystem.ELEXIS_CONSID.getSystem());
		identifier.setValue(consultationId);
	}
}
 
Example #6
Source File: DocumentReferenceAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public List<ICoding> getDocumentClass(DomainResource resource){
	org.hl7.fhir.dstu3.model.DocumentReference fhirResource =
		(org.hl7.fhir.dstu3.model.DocumentReference) resource;
	CodeableConcept codeableConcept = fhirResource.getClass_();
	if (codeableConcept != null) {
		return ModelUtil.getCodingsFromConcept(codeableConcept);
	}
	return Collections.emptyList();
}
 
Example #7
Source File: Encounter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setConsultationId(String consultationId){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setConsultationId((DomainResource) resource.get(), consultationId);
		saveResource(resource.get());
	}
	getEntity().setConsultationId(consultationId);
}
 
Example #8
Source File: EncounterAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setType(DomainResource resource, List<ICoding> coding){
	org.hl7.fhir.dstu3.model.Encounter fhirEncounter =
		(org.hl7.fhir.dstu3.model.Encounter) resource;
	List<CodeableConcept> codeableConcepts = fhirEncounter.getType();
	if (!codeableConcepts.isEmpty()) {
		codeableConcepts.clear();
	}
	CodeableConcept codeableConcept = new CodeableConcept();
	ModelUtil.setCodingsToConcept(codeableConcept, coding);
	fhirEncounter.setType(Collections.singletonList(codeableConcept));
}
 
Example #9
Source File: Observation.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<ICoding> getCoding(){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		return accessor.getCoding((DomainResource) resource.get());
	}
	return Collections.emptyList();
}
 
Example #10
Source File: Observation.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setPatientId(String patientId){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setPatientId((DomainResource) resource.get(), patientId);
		saveResource(resource.get());
	}
	
	getEntity().setPatientId(patientId);
}
 
Example #11
Source File: Encounter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setStartTime(LocalDateTime time){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setStartTime((DomainResource) resource.get(), time);
		saveResource(resource.get());
	}
}
 
Example #12
Source File: Condition.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setDateRecorded(LocalDate date){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setDateRecorded((DomainResource) resource.get(), date);
		saveResource(resource.get());
	}
}
 
Example #13
Source File: ObservationAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Optional<String> getComment(DomainResource resource){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	if (fhirObservation.hasComment()) {
		return Optional.of(fhirObservation.getComment());
	}
	return Optional.empty();
}
 
Example #14
Source File: EncounterAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setIndication(DomainResource resource, List<ICondition> indication){
	org.hl7.fhir.dstu3.model.Encounter fhirEncounter =
		(org.hl7.fhir.dstu3.model.Encounter) resource;
	List<DiagnosisComponent> theIndication = new ArrayList<>();
	for (ICondition iCondition : indication) {
		theIndication.add(new DiagnosisComponent(new Reference(new IdDt("Condition", iCondition.getId()))));
	}
	fhirEncounter.setDiagnosis(theIndication);
}
 
Example #15
Source File: Condition.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setEnd(String end){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setEnd((DomainResource) resource.get(), end);
		saveResource(resource.get());
	}
}
 
Example #16
Source File: AbstractFindingModelAdapter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void addStringExtension(String theUrl, String theValue){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent() && resource.get() instanceof DomainResource) {
		DomainResource domainResource = (DomainResource) resource.get();
		Extension extension = new Extension(theUrl);
		extension.setValue(new StringType().setValue(theValue));
		domainResource.addExtension(extension);
		saveResource(domainResource);
	}
}
 
Example #17
Source File: ObservationAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Optional<BigDecimal> getNumericValue(DomainResource resource){
	org.hl7.fhir.dstu3.model.Observation fhirObservation =
		(org.hl7.fhir.dstu3.model.Observation) resource;
	if (fhirObservation.hasValueQuantity()) {
		Quantity quantity = (Quantity) fhirObservation.getValue();
		if (quantity.getValue() != null) {
			return Optional.of(quantity.getValue());
		}
	}
	return Optional.empty();
}
 
Example #18
Source File: Observation.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setComment(String comment){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setComment((DomainResource) resource.get(), comment);
		saveResource(resource.get());
	}
}
 
Example #19
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setStatus(DomainResource resource, ConditionStatus status){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	ConditionClinicalStatus fhirCategoryCode =
		(ConditionClinicalStatus) statusMapping.getFhirEnumValueByEnum(status);
	if (fhirCategoryCode != null) {
		fhirCondition.setClinicalStatus(fhirCategoryCode);
	}
}
 
Example #20
Source File: Encounter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setMandatorId(String mandatorId){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setMandatorId((DomainResource) resource.get(), mandatorId);
		saveResource(resource.get());
	}
	
	getEntity().setMandatorId(mandatorId);
}
 
Example #21
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setCategory(DomainResource resource, ConditionCategory category){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	CodeableConcept categoryCode = new CodeableConcept();
	org.hl7.fhir.dstu3.model.codesystems.ConditionCategory fhirCategoryCode =
		(org.hl7.fhir.dstu3.model.codesystems.ConditionCategory) categoryMapping
			.getFhirEnumValueByEnum(category);
	if (fhirCategoryCode != null) {
		categoryCode
			.setCoding(Collections.singletonList(new Coding(fhirCategoryCode.getSystem(),
				fhirCategoryCode.toCode(), fhirCategoryCode.getDisplay())));
		fhirCondition.setCategory(Collections.singletonList(categoryCode));
	}
}
 
Example #22
Source File: DocumentReferenceAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void setPracticeSetting(DomainResource resource, ICoding coding){
	org.hl7.fhir.dstu3.model.DocumentReference fhirResource =
		(org.hl7.fhir.dstu3.model.DocumentReference) resource;
	DocumentReferenceContextComponent fhirContext = fhirResource.getContext();
	if (fhirContext != null) {
		CodeableConcept codeableConcept = new CodeableConcept();
		ModelUtil.setCodingToConcept(codeableConcept, coding);
		fhirContext.setPracticeSetting(codeableConcept);
	}
}
 
Example #23
Source File: AbstractFindingModelAdapter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Map<String, String> getStringExtensions(){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent() && resource.get() instanceof DomainResource) {
		List<Extension> extensions = ((DomainResource) resource.get()).getExtension();
		return extensions.stream()
			.filter(extension -> extension.getValue() instanceof StringType)
			.collect(Collectors.toMap(extension -> extension.getUrl(),
				extension -> ((StringType) extension.getValue()).getValueAsString()));
	}
	return Collections.emptyMap();
}
 
Example #24
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Optional<LocalDate> getDateRecorded(DomainResource resource){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	Date date = fhirCondition.getAssertedDate();
	if (date != null) {
		return Optional.of(getLocalDate(date));
	}
	return Optional.empty();
}
 
Example #25
Source File: DocumentReferenceAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public List<ICoding> getPracticeSetting(DomainResource resource){
	org.hl7.fhir.dstu3.model.DocumentReference fhirResource =
		(org.hl7.fhir.dstu3.model.DocumentReference) resource;
	DocumentReferenceContextComponent fhirContext = fhirResource.getContext();
	if (fhirContext != null) {
		CodeableConcept codeableConcept = fhirContext.getPracticeSetting();
		if (codeableConcept != null) {
			return ModelUtil.getCodingsFromConcept(codeableConcept);
		}
	}
	return Collections.emptyList();
}
 
Example #26
Source File: DocumentReference.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setDocumentClass(ICoding coding){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		accessor.setDocumentClass((DomainResource) resource.get(), coding);
		saveResource(resource.get());
	}
}
 
Example #27
Source File: Encounter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<ICondition> getIndication(){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		return accessor.getIndication((DomainResource) resource.get());
	}
	return new ArrayList<>();
}
 
Example #28
Source File: AbstractFindingsAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public Optional<String> getText(DomainResource resource){
	Narrative narrative = ((DomainResource) resource).getText();
	if (narrative != null && narrative.getDivAsString() != null) {
		return ModelUtil.getNarrativeAsString(narrative);
	}
	return Optional.empty();
}
 
Example #29
Source File: Encounter.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Optional<LocalDateTime> getStartTime(){
	Optional<IBaseResource> resource = loadResource();
	if (resource.isPresent()) {
		return accessor.getStartTime((DomainResource) resource.get());
	}
	return Optional.empty();
}
 
Example #30
Source File: ConditionAccessor.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void removeNote(DomainResource resource, String text){
	org.hl7.fhir.dstu3.model.Condition fhirCondition =
		(org.hl7.fhir.dstu3.model.Condition) resource;
	List<Annotation> notes = new ArrayList<Annotation>(fhirCondition.getNote());
	notes = notes.stream().filter(annotation -> !text.equals(annotation.getText()))
		.collect(Collectors.toList());
	fhirCondition.setNote(notes);
}