Java Code Examples for org.hl7.fhir.dstu3.model.Encounter

The following examples show how to use org.hl7.fhir.dstu3.model.Encounter. These examples are extracted from open source projects. 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
List<Resource> search(FhirContext ctx,

                          @OptionalParam(name = Encounter.SP_PATIENT) ReferenceParam patient
            , @OptionalParam(name = Encounter.SP_DATE) DateRangeParam date
            , @OptionalParam(name = Encounter.SP_EPISODEOFCARE) ReferenceParam episode
            , @OptionalParam(name = Encounter.SP_IDENTIFIER) TokenParam identifier
            , @OptionalParam(name= Encounter.SP_RES_ID) StringParam id
            , @IncludeParam(reverse=true, allow = {
            "Observation:context",
            "Encounter:part-of",
            "Procedure:context",
            "Condition:context",
            "MedicationRequest:context",
            "Immunization:encounter" ,
            "DocumentReference:context",
            "Composition:encounter",
            "ReferralRequest:encounter",
            "MedicationDispense:context",
            "MedicationAdministration:context",
            "*"
    }) Set<Include> reverseIncludes
            , @IncludeParam(allow = { "Encounter.participant" , "Encounter.service-provider", "Encounter.location", "*"
    }) Set<Include> includes
            , @OptionalParam(name = Encounter.SP_TYPE) TokenParam type
            , @OptionalParam(name = Encounter.SP_STATUS) TokenParam status
    );
 
Example 2
List<EncounterEntity> searchEntity(FhirContext ctx,
        @OptionalParam(name = Encounter.SP_PATIENT) ReferenceParam patient
        ,@OptionalParam(name = Encounter.SP_DATE) DateRangeParam date
        ,@OptionalParam(name = Encounter.SP_EPISODEOFCARE) ReferenceParam episode
        , @OptionalParam(name = Encounter.SP_IDENTIFIER) TokenParam identifier
        ,@OptionalParam(name= Encounter.SP_RES_ID) StringParam id
        , @IncludeParam(reverse=true, allow = {
        "Observation:context",
        "Encounter:part-of",
        "Procedure:context",
        "Condition:context",
        "MedicationRequest:context",
        "Immunization:encounter" ,
        "DocumentReference:context",
        "Composition:encounter",
        "ReferralRequest:encounter",
        "*"
}) Set<Include> reverseIncludes
        , @IncludeParam(allow = { "Encounter.participant" , "Encounter.subject", "Encounter.service-provider", "Encounter.location", "*"
}) Set<Include> includes
        , @OptionalParam(name = Encounter.SP_TYPE) TokenParam type
        , @OptionalParam(name = Encounter.SP_STATUS) TokenParam status
);
 
Example 3
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Encounter encounter, @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 {
        Encounter newEncounter = encounterDao.create(ctx, encounter, theId, theConditional);
        method.setId(newEncounter.getIdElement());
        method.setResource(newEncounter);
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 4
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Encounter encounter) {

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

    method.setOperationOutcome(opOutcome);

    try {
        Encounter newEncounter = encounterDao.create(ctx, encounter, null, null);
        method.setId(newEncounter.getIdElement());
        method.setResource(newEncounter);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 5
@Search
public List<Resource> search(HttpServletRequest theRequest,
                             @OptionalParam(name = Encounter.SP_PATIENT) ReferenceParam patient
        , @OptionalParam(name = Encounter.SP_DATE) DateRangeParam date
        , @OptionalParam(name = Encounter.SP_EPISODEOFCARE) ReferenceParam episode
        , @OptionalParam(name = Encounter.SP_IDENTIFIER) TokenParam identifier
        , @OptionalParam(name = Encounter.SP_RES_ID) StringParam resid
        , @IncludeParam(reverse=true, allow = {
        "Observation:context",
        "Encounter:part-of",
        "Procedure:context",
        "Condition:context",
        "MedicationRequest:context",
        "Immunization:encounter" ,
        "DocumentReference:context",
        "Composition:encounter",
        "ReferralRequest:encounter",
        "*"
}) Set<Include> reverseIncludes
        , @IncludeParam(allow = { "Encounter:participant" , "Encounter:patient" ,"Encounter:service-provider", "Encounter:location", "*"
}) Set<Include> includes
        , @OptionalParam(name = Encounter.SP_TYPE) TokenParam type
        , @OptionalParam(name = Encounter.SP_STATUS) TokenParam status
) {
    return encounterDao.search(ctx,patient,date,episode,identifier,resid,reverseIncludes, includes, type, status);
}
 
Example 6
public static void main(String[] args) {
	
	// Create an incomplete encounter (status is required)
	Encounter enc = new Encounter();
	enc.addIdentifier().setSystem("http://acme.org/encNums").setValue("12345");
	
	// Create a new validator
	FhirContext ctx = FhirContext.forDstu3();
	FhirValidator validator = ctx.newValidator();
	
	// Did we succeed?
	ValidationResult result = validator.validateWithResult(enc);
	System.out.println("Success: " + result.isSuccessful());
	
	// What was the result
	OperationOutcome outcome = (OperationOutcome) result.toOperationOutcome();
	IParser parser = ctx.newXmlParser().setPrettyPrint(true);
	System.out.println(parser.encodeResourceToString(outcome));
}
 
Example 7
public static void main(String[] args) {
   // Create an incomplete encounter (status is required)
   Encounter enc = new Encounter();
   enc.addIdentifier().setSystem("http://acme.org/encNums").setValue("12345");

   // Create a new validator
   FhirValidator validator = FhirContext.forDstu3().newValidator();

   // Cache this object! Supplies structure definitions
   DefaultProfileValidationSupport support = new DefaultProfileValidationSupport();

   // Create the validator
   FhirInstanceValidator module = new FhirInstanceValidator(support);
   validator.registerValidatorModule(module);

   // Did we succeed?
   IParser parser = FhirContext.forDstu3().newXmlParser().setPrettyPrint(true);
   System.out.println(parser.encodeResourceToString(validator.validateWithResult(enc).toOperationOutcome()));
}
 
Example 8
@Test
public void convertEncounter20() throws IOException {
	// encounter format of HAPI FHIR 2.0
	String oldContent = AllTests.getResourceAsString("/rsc/json/EncounterFormat20.json");
	assertFalse(FindingsFormatUtil.isCurrentFindingsFormat(oldContent));

	Optional<String> newContent = FindingsFormatUtil.convertToCurrentFindingsFormat(oldContent);
	assertTrue(newContent.isPresent());

	IBaseResource resource = AllTests.getJsonParser().parseResource(newContent.get());
	assertTrue(resource instanceof Encounter);
	Encounter encounter = (Encounter) resource;

	// indication changed to diagnosis
	List<DiagnosisComponent> diagnosis = encounter.getDiagnosis();
	assertNotNull(diagnosis);
	assertFalse(diagnosis.isEmpty());
	DiagnosisComponent component = diagnosis.get(0);
	Reference conditionRef = component.getCondition();
	assertNotNull(conditionRef);
	assertTrue(conditionRef.getReference().contains("CONDITIONA"));
	// patient changed to subject
	Reference subjectRef = encounter.getSubject();
	assertNotNull(subjectRef);
	assertTrue(subjectRef.getReference().contains("PATIENTID"));
}
 
Example 9
Source Project: org.hl7.fhir.core   Source File: CCDAConverter.java    License: 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 10
@Read()
public Encounter get(@IdParam IdType encounterId) {
	resourcePermissionProvider.checkPermission("read");
    Encounter encounter = encounterDao.read(ctx,encounterId);

    if ( encounter == null) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(
                new ResourceNotFoundException("No Encounter/ " + encounterId.getIdPart()),
                 OperationOutcome.IssueType.NOTFOUND);
    }

    return encounter;
}
 
Example 11
public Encounter.EncounterLocationStatus getStatus() {
    return status;
}
 
Example 12
public void setStatus(Encounter.EncounterLocationStatus status) {
    this.status = status;
}
 
Example 13
@Override
public Class<? extends IBaseResource> getResourceType() {
    return Encounter.class;
}
 
Example 14
@Validate
public MethodOutcome testResource(@ResourceParam Encounter resource,
                              @Validate.Mode ValidationModeEnum theMode,
                              @Validate.Profile String theProfile) {
    return resourceTestProvider.testResource(resource,theMode,theProfile);
}
 
Example 15
Encounter read(FhirContext ctx, IdType theId); 
Example 16
Encounter create(FhirContext ctx,Encounter encounter, @IdParam IdType theId, @ConditionalUrlParam String theConditional) throws OperationOutcomeException;