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

The following examples show how to use org.hl7.fhir.dstu3.model.ListResource. 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: MeasureOperationsProvider.java    From cqf-ruler with Apache License 2.0 6 votes vote down vote up
private void addEvaluatedResourcesToParameters(Bundle contained, Parameters parameters) {
    Map<String, Resource> resourceMap = new HashMap<>();
    if (contained.hasEntry()) {
        for (Bundle.BundleEntryComponent entry : contained.getEntry()) {
            if (entry.hasResource() && !(entry.getResource() instanceof ListResource)) {
                if (!resourceMap.containsKey(entry.getResource().getIdElement().getValue())) {
                    parameters.addParameter(new Parameters.ParametersParameterComponent().setName("resource")
                            .setResource(entry.getResource()));

                    resourceMap.put(entry.getResource().getIdElement().getValue(), entry.getResource());

                    resolveReferences(entry.getResource(), parameters, resourceMap);
                }
            }
        }
    }
}
 
Example #2
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 #3
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 #4
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 #5
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 #6
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome createList(HttpServletRequest theRequest, @ResourceParam ListResource list) {

	resourcePermissionProvider.checkPermission("create");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);
    try {
        ListResource newList = listDao.create(ctx, list,null,null);
        method.setId(newList.getIdElement());
        method.setResource(newList);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example #7
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateList(HttpServletRequest theRequest, @ResourceParam ListResource list, @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 {
    log.info(theId.getId());
    ListResource newList = listDao.create(ctx, list, theId, theConditional);
    method.setId(newList.getIdElement());
    method.setResource(newList);

} 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 ListEntryComponent addItemToList(ListResource list, DomainResource ai)
		throws Exception {
	list.getContained().add(ai);
	String n = nextRef();
	ai.setId(n);
	ListEntryComponent item = new ListResource.ListEntryComponent();
	list.getEntry().add(item);
	item.setItem(Factory.makeReference("#"+n));
	return item;
}
 
Example #9
Source File: CCDAConverter.java    From org.hl7.fhir.core with Apache License 2.0 5 votes vote down vote up
protected String processVitalSignsObservation(Element comp, ListResource list) throws Exception {
	Element observation = cda.getChild(comp, "observation");
	cda.checkTemplateId(observation, "2.16.840.1.113883.10.20.22.4.27");
	checkNoNegationOrNullFlavor(observation, "Vital Signs Observation");
	checkNoSubject(observation, "Vital Signs Observation");

	Observation obs = new Observation();

	//	SHALL contain at least one [1..*] id (CONF:7300).
	for (Element e : cda.getChildren(observation, "id"))
		obs.getIdentifier().add(convert.makeIdentifierFromII(e));

	// SHALL contain exactly one [1..1] code, which SHOULD be selected from ValueSet Vital Sign Result Value Set 2.16.840.1.113883.3.88.12.80.62 DYNAMIC (CONF:7301).
	obs.setCode(convert.makeCodeableConceptFromCD(cda.getChild(observation, "code"))); // all loinc codes

	// SHOULD contain zero or one [0..1] text (CONF:7302).
	// The text, if present, SHOULD contain zero or one [0..1] reference (CONF:15943).
	// The reference, if present, SHOULD contain zero or one [0..1] @value (CONF:15944).
	// This reference/@value SHALL begin with a '#' and SHALL point to its corresponding narrative (using the approach defined in CDA Release 2, section 4.3.5.1) (CONF:15945).
	// todo: put this in narrative if it exists?


	// SHALL contain exactly one [1..1] statusCode (CONF:7303).	This statusCode SHALL contain exactly one [1..1] @code="completed" Completed (CodeSystem: ActStatus 2.16.840.1.113883.5.14 STATIC) (CONF:19119).
	// ignore

	// SHALL contain exactly one [1..1] effectiveTime (CONF:7304).
	obs.setEffective(convert.makeMatchingTypeFromIVL(cda.getChild(observation, "effectiveTime")));

	//	SHALL contain exactly one [1..1] value with @xsi:type="PQ" (CONF:7305).
	obs.setValue(convert.makeQuantityFromPQ(cda.getChild(observation, "value")));

	// MAY contain zero or one [0..1] interpretationCode (CONF:7307).
	obs.setInterpretation(convert.makeCodeableConceptFromCD(cda.getChild(observation, "interpretationCode")));

	//	MAY contain zero or one [0..1] methodCode (CONF:7308).
	obs.setMethod(convert.makeCodeableConceptFromCD(cda.getChild(observation, "methodCode")));

	// MAY contain zero or one [0..1] targetSiteCode (CONF:7309).
	obs.setBodySite(convert.makeCodeableConceptFromCD(cda.getChild(observation, "targetSiteCode")));

	// MAY contain zero or one [0..1] author (CONF:7310).
	if (cda.getChild(observation, "author") != null)
		obs.getPerformer().add(makeReferenceToPractitionerForAssignedEntity(cda.getChild(observation, "author"), composition));

	// make a contained practitioner
	String n = nextRef();
	obs.setId(n);
	list.getContained().add(obs);
	return n;
}
 
Example #10
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Search
public List<ListResource> searchQuestionnaire(HttpServletRequest theRequest,
                                                       @OptionalParam(name = ListResource.SP_IDENTIFIER) TokenParam identifier,
                                                       @OptionalParam(name= ListResource.SP_RES_ID) StringParam id,
                                                       @OptionalParam(name = ListResource.SP_PATIENT) ReferenceParam patient
) {
    return listDao.searchListResource(ctx, identifier,id,patient);
}
 
Example #11
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Read()
public ListResource getList(@IdParam IdType listId) {
	resourcePermissionProvider.checkPermission("read");
    ListResource form = listDao.read(ctx,listId);

    if ( form == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No List/ " + listId.getIdPart()),
                 OperationOutcome.IssueType.NOTFOUND);
    }

    return form;
}
 
Example #12
Source File: CompositionSection.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public ListResource.ListMode getMode() {
    return mode;
}
 
Example #13
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Override
public Class<? extends IBaseResource> getResourceType() {
    return ListResource.class;
}
 
Example #14
Source File: ListRepository.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
List<ListEntity> searchListEntity(FhirContext ctx,
                                                                    @OptionalParam(name = ListResource.SP_IDENTIFIER) TokenParam identifier,
                                                                    @OptionalParam(name = ListResource.SP_RES_ID) StringParam id,
                                                                    @OptionalParam(name = ListResource.SP_PATIENT) ReferenceParam patient
);
 
Example #15
Source File: CompositionSection.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setMode(ListResource.ListMode mode) {
    this.mode = mode;
}
 
Example #16
Source File: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void processAllergiesSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Allergies", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-allergies");
	list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafallergylist");
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	list.setMode(ListMode.SNAPSHOT);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element apa = cda.getChild(c, "act"); // allergy problem act
		AllergyIntolerance ai = new AllergyIntolerance();
		ai.setId(context.baseId+"-allergy-"+Integer.toString(i));
		ai.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/allergyintolerance-daf-dafallergyintolerance");
		i++;
		ai.setPatient(context.subjectRef);

		ai.setAssertedDateElement(convert.makeDateTimeFromTS(cda.getChild(cda.getChild(apa, "effectiveTime"), "low")));
		boolean found = false;
		for (Element e : cda.getChildren(apa, "id")) {
			Identifier id = convert.makeIdentifierFromII(e);
			ai.getIdentifier().add(id);
		}
		if (!found) {
			list.addEntry().setItem(new Reference().setReference("AllergyIntolerance/"+ai.getId()));

			Element ao = cda.getChild(cda.getChild(apa, "entryRelationship"), "observation"); // allergy observation
			if (!cda.getChild(ao, "value").getAttribute("code").equals("419511003"))
				throw new Error("unexpected code");
			// nothing....

			// no allergy status observation
			List<Element> reactions = cda.getChildren(ao, "entryRelationship");
			Element pe = cda.getChild(cda.getChild(cda.getChild(ao, "participant"), "participantRole"), "playingEntity");
			Element pec = cda.getChild(pe, "code");
			if (pec == null || !Utilities.noString(pec.getAttribute("nullFlavor"))) {
				String n = cda.getChild(pe, "name").getTextContent();
				//				if (n.contains("No Known Drug Allergies") && reactions.isEmpty())
				//					ai.setSubstance(new CodeableConcept().setText(n)); // todo: what do with this?
				//				else
				ai.setCode(new CodeableConcept().setText(n));
			} else
				ai.setCode(inspectCode(convert.makeCodeableConceptFromCD(pec), null));
			recordAllergyCode(ai.getCode());
			if (!reactions.isEmpty()) {
				AllergyIntoleranceReactionComponent aie = ai.addReaction();
				for (Element er : reactions) {
					Element ro = cda.getChild(er, "observation");
					aie.addManifestation(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(ro, "value")), null));
				}
			}

			saveResource(ai);
		}
	}
	saveResource(list);
}
 
Example #17
Source File: ListEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setMode(ListResource.ListMode mode) {
    this.mode = mode;
}
 
Example #18
Source File: ListEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public ListResource.ListMode getMode() {
    return mode;
}
 
Example #19
Source File: ListEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public void setStatus(ListResource.ListStatus status) {
    this.status = status;
}
 
Example #20
Source File: ListEntity.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
public ListResource.ListStatus getStatus() {
    return status;
}
 
Example #21
Source File: ArgonautConverter.java    From org.hl7.fhir.core with Apache License 2.0 4 votes vote down vote up
private void processVitalSignsSection(CDAUtilities cda, Convert convert, Element section, Context context) throws Exception {
	scanSection("Vital Signs", section);
	ListResource list = new ListResource();
	list.setId(context.baseId+"-list-vitalsigns");
	//. list.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/list-daf-dafproblemlist"); no list
	list.setSubject(context.subjectRef);
	list.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")), null));
	list.setTitle(cda.getChild(section, "title").getTextContent());
	list.setStatus(ListStatus.CURRENT);
	list.setMode(ListMode.SNAPSHOT);
	list.setDateElement(context.now);
	list.setSource(context.authorRef);
	buildNarrative(list, cda.getChild(section, "text"));

	int i = 0;
	for (Element c : cda.getChildren(section, "entry")) {
		Element org = cda.getChild(c, "organizer"); // problem concern act
		for (Element oc : cda.getChildren(org, "component")) {
			Element o = cda.getChild(oc, "observation"); // problem concern act
			Observation obs = new Observation();
			obs.setId(context.baseId+"-vitals-"+Integer.toString(i));
			obs.setUserData("profile", "http://hl7.org/fhir/StructureDefinition/observation-daf-vitalsigns-dafvitalsigns");
			i++;
			obs.setSubject(context.subjectRef);
			obs.setContext(new Reference().setReference("Encounter/"+context.encounter.getId()));
			obs.setCode(inspectCode(convert.makeCodeableConceptFromCD(cda.getChild(o, "code")), null));

			boolean found = false;
			for (Element e : cda.getChildren(o, "id")) {
				Identifier id = convert.makeIdentifierFromII(e);
				obs.getIdentifier().add(id);
			}

			if (!found) {
				list.addEntry().setItem(new Reference().setReference("Observation/"+obs.getId()));
				obs.setStatus(ObservationStatus.FINAL);
				obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(o, "effectiveTime")));
				String v = cda.getChild(o, "value").getAttribute("value");
				if (!Utilities.isDecimal(v, true)) {
					obs.setDataAbsentReason(inspectCode(new CodeableConcept().setText(v), null));
				} else
					obs.setValue(convert.makeQuantityFromPQ(cda.getChild(o, "value")));
				saveResource(obs, "-vs");
			}
		}
	}
	saveResource(list, "-vs");
}
 
Example #22
Source File: ListRepository.java    From careconnect-reference-implementation with Apache License 2.0 3 votes vote down vote up
List<ListResource> searchListResource(FhirContext ctx,

                                                            @OptionalParam(name = ListResource.SP_IDENTIFIER) TokenParam identifier,
                                                            @OptionalParam(name = ListResource.SP_RES_ID) StringParam id,
                                                            @OptionalParam(name = ListResource.SP_PATIENT) ReferenceParam patient

    );
 
Example #23
Source File: ListRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
ListResource read(FhirContext ctx, IdType theId); 
Example #24
Source File: ListRepository.java    From careconnect-reference-implementation with Apache License 2.0 votes vote down vote up
ListResource create(FhirContext ctx, ListResource questionnaire, @IdParam IdType theId, @ConditionalUrlParam String theConditional) throws OperationOutcomeException;