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

The following examples show how to use org.hl7.fhir.dstu3.model.Composition. 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: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
protected SectionComponent processProceduresSection(Element section) throws Exception {
	ListResource list = new ListResource();
	for (Element entry : cda.getChildren(section, "entry")) {
		Element procedure = cda.getlastChild(entry);

		if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.14")) {
			processProcedure(list, procedure, ProcedureType.Procedure);
		} else if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.13")) {
			processProcedure(list, procedure, ProcedureType.Observation);
		} else if (cda.hasTemplateId(procedure, "2.16.840.1.113883.10.20.22.4.12")) {
			processProcedure(list, procedure, ProcedureType.Act);
		} else
			throw new Exception("Unhandled Section template ids: "+cda.showTemplateIds(procedure));
	}

	// todo: text
	SectionComponent s = new Composition.SectionComponent();
	s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section,  "code")));
	// todo: check subject
	s.addEntry(Factory.makeReference(addReference(list, "Procedures", makeUUIDReference())));
	return s;

}
 
Example #2
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
protected SectionComponent processAdverseReactionsSection(Element section) throws Exception {
	ListResource list = new ListResource();
	for (Element entry : cda.getChildren(section, "entry")) {
		Element concern = cda.getChild(entry, "act");
		if (cda.hasTemplateId(concern, "2.16.840.1.113883.10.20.22.4.30")) {
			processAllergyProblemAct(list, concern);
		} else
			throw new Exception("Unhandled Section template ids: "+cda.showTemplateIds(concern));
	}


	// todo: text
	SectionComponent s = new Composition.SectionComponent();
	s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section,  "code")));
	// todo: check subject
	s.addEntry(Factory.makeReference(addReference(list, "Allergies, Adverse Reactions, Alerts", makeUUIDReference())));
	return s;
}
 
Example #3
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
protected SectionComponent processSocialHistorySection(Element section) throws Exception {
	ListResource list = new ListResource();
	for (Element entry : cda.getChildren(section, "entry")) {
		Element observation = cda.getlastChild(entry);

		if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.38")) {
			processSocialObservation(list, observation, SocialHistoryType.SocialHistory);
		} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.15.3.8")) {
			processSocialObservation(list, observation, SocialHistoryType.Pregnancy);
		} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.78")) {
			processSocialObservation(list, observation, SocialHistoryType.SmokingStatus);
		} else if (cda.hasTemplateId(observation, "2.16.840.1.113883.10.20.22.4.85")) {
			processSocialObservation(list, observation, SocialHistoryType.TobaccoUse);
		} else
			throw new Exception("Unhandled Section template ids: "+cda.showTemplateIds(observation));
	}

	// todo: text
	SectionComponent s = new Composition.SectionComponent();
	s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section,  "code")));
	// todo: check subject
	s.addEntry(Factory.makeReference(addReference(list, "Procedures", makeUUIDReference())));
	return s;

}
 
Example #4
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
protected SectionComponent processVitalSignsSection(Element section) throws Exception {
	ListResource list = new ListResource();
	for (Element entry : cda.getChildren(section, "entry")) {
		Element organizer = cda.getlastChild(entry);

		if (cda.hasTemplateId(organizer, "2.16.840.1.113883.10.20.22.4.26")) {
			processVitalSignsOrganizer(list, organizer);
		} else
			throw new Exception("Unhandled Section template ids: "+cda.showTemplateIds(organizer));
	}

	// todo: text
	SectionComponent s = new Composition.SectionComponent();
	s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section,  "code")));
	// todo: check subject
	s.addEntry(Factory.makeReference(addReference(list, "Vital Signs", makeUUIDReference())));
	return s;

}
 
Example #5
Source File: NarrativeGenerator.java    From org.hl7.fhir.core with Apache License 2.0 6 votes vote down vote up
public XhtmlNode generateDocumentNarrative(Bundle feed) {
  /*
   When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order:
   * The Composition resource
   * The Subject resource
   * Resources referenced in the section.content
   */
  XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
  Composition comp = (Composition) feed.getEntry().get(0).getResource();
  root.getChildNodes().add(comp.getText().getDiv());
  Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference());
  if (subject != null && subject instanceof DomainResource) {
    root.hr();
    root.getChildNodes().add(((DomainResource)subject).getText().getDiv());
  }
  List<SectionComponent> sections = comp.getSection();
  renderSections(feed, root, sections, 1);
  return root;
}
 
Example #6
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Composition composition) {

	resourcePermissionProvider.checkPermission("create");
	
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);
    try {
        Composition newComposition = compositionDao.create(ctx,composition, null,null);
        method.setId(newComposition.getIdElement());
        method.setResource(newComposition);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example #7
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Composition composition, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");
	
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);
    try {
        Composition newComposition = compositionDao.create(ctx,composition, theId, theConditional);
        method.setId(newComposition.getIdElement());
        method.setResource(newComposition);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #8
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected void makeDocument() throws Exception {
	composition = (Composition) ResourceFactory.createResource("Composition");
	addReference(composition, "Composition", makeUUIDReference());

	Element title = cda.getChild(doc, "title");
	composition.setTitle(title.getTextContent());

	if (cda.getChild(doc, "setId") != null) {
		feed.setId(convert.makeURIfromII(cda.getChild(doc, "id")));
		composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "setId")));
	} else
		composition.setIdentifier(convert.makeIdentifierFromII(cda.getChild(doc, "id"))); // well, we fall back to id

	composition.setDateElement(convert.makeDateTimeFromTS(cda.getChild(doc, "effectiveTime")));
	composition.setType(convert.makeCodeableConceptFromCD(cda.getChild(doc, "code")));
	composition.setConfidentiality(convertConfidentiality(cda.getChild(doc, "confidentialityCode")));
	if (cda.getChild(doc, "confidentialityCode") != null)
		composition.setLanguage(cda.getChild(doc, "confidentialityCode").getAttribute("value")); // todo - fix streaming for this

	Element ee = cda.getChild(doc, "componentOf");
	if (ee != null)
		ee = cda.getChild(ee, "encompassingEncounter");
	if (ee != null) {
		Encounter visit = new Encounter();
		for (Element e : cda.getChildren(ee, "id"))
			visit.getIdentifier().add(convert.makeIdentifierFromII(e));
		visit.setPeriod(convert.makePeriodFromIVL(cda.getChild(ee, "effectiveTime")));
		composition.getEvent().add(new Composition.CompositionEventComponent());
		composition.getEvent().get(0).getCode().add(convert.makeCodeableConceptFromCD(cda.getChild(ee, "code")));
		composition.getEvent().get(0).setPeriod(visit.getPeriod());
		composition.getEvent().get(0).getDetail().add(Factory.makeReference(addReference(visit, "Encounter", makeUUIDReference())));
	}

	// main todo: fill out the narrative, but before we can do that, we have to convert everything else
}
 
Example #9
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Read()
public Composition get(@IdParam IdType compositionId) {
	resourcePermissionProvider.checkPermission("read");
	
    Composition composition = compositionDao.read(ctx,compositionId);

    if ( composition == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No Composition/ " + compositionId.getIdPart()),
                OperationOutcome.IssueType.NOTFOUND);
    }

    return composition;
}
 
Example #10
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Search
public List<Composition> search(HttpServletRequest theRequest,
                              @OptionalParam(name = Composition.SP_PATIENT) ReferenceParam patient
        , @OptionalParam(name = Composition.SP_IDENTIFIER) TokenParam identifier
        , @OptionalParam(name = Composition.SP_RES_ID) StringParam resid
        , @OptionalParam(name = Composition.SP_TYPE) TokenParam type
        , @OptionalParam(name = Composition.SP_PERIOD) DateRangeParam date
                              ) {
    return compositionDao.search(ctx,patient,identifier,resid,type,date);
}
 
Example #11
Source File: CompositionRepository.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
List<Composition> search(FhirContext ctx,

              @OptionalParam(name = Condition.SP_PATIENT) ReferenceParam patient
            , @OptionalParam(name = Composition.SP_IDENTIFIER) TokenParam identifier
            , @OptionalParam(name = Composition.SP_RES_ID) StringParam id
            , @OptionalParam(name = Composition.SP_TYPE) TokenParam type
            , @OptionalParam(name = Composition.SP_PERIOD)DateRangeParam dateRange

    );
 
Example #12
Source File: CompositionRepository.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
List<CompositionEntity> searchEntity(FhirContext ctx,
          @OptionalParam(name = Composition.SP_PATIENT) ReferenceParam patient
        , @OptionalParam(name = Condition.SP_IDENTIFIER) TokenParam identifier
        , @OptionalParam(name = Condition.SP_RES_ID) StringParam id
        , @OptionalParam(name = Composition.SP_TYPE) TokenParam type
        , @OptionalParam(name = Composition.SP_PERIOD)DateRangeParam dateRange
);
 
Example #13
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Validate
public MethodOutcome testResource(@ResourceParam Composition resource,
                              @Validate.Mode ValidationModeEnum theMode,
                              @Validate.Profile String theProfile) {
    return resourceTestProvider.testResource(resource,theMode,theProfile);
}
 
Example #14
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends IBaseResource> getResourceType() {
    return Composition.class;
}
 
Example #15
Source File: CompositionEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public CompositionEntity setConfidentiality(Composition.DocumentConfidentiality confidentiality) {
    this.confidentiality = confidentiality;
    return this;
}
 
Example #16
Source File: CompositionEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public Composition.DocumentConfidentiality getConfidentiality() {
    return confidentiality;
}
 
Example #17
Source File: CompositionEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public CompositionEntity setStatus(Composition.CompositionStatus status) {
    this.status = status;
    return this;
}
 
Example #18
Source File: CompositionEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public Composition.CompositionStatus getStatus() {
    return status;
}
 
Example #19
Source File: CompositionRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
Composition create(FhirContext ctx, Composition composition, @IdParam IdType theId, @ConditionalUrlParam String theConditional) throws OperationOutcomeException; 
Example #20
Source File: CompositionRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
Composition read(FhirContext ctx, IdType theId);