Java Code Examples for ca.uhn.fhir.rest.api.MethodOutcome#setResource()

The following examples show how to use ca.uhn.fhir.rest.api.MethodOutcome#setResource() . 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: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updatePractitioner(HttpServletRequest theRequest, @ResourceParam Practitioner practitioner, @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 {
    Practitioner newPractitioner = practitionerDao.create(ctx,practitioner, theId, theConditional);
    method.setId(newPractitioner.getIdElement());
    method.setResource(newPractitioner);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 2
Source File: MedicationDispenseProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam MedicationDispense dispense) {

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

    method.setOperationOutcome(opOutcome);

    try {
    MedicationDispense newMedicationDispense = dispenseDao.create(ctx,dispense, null,null);
    method.setId(newMedicationDispense.getIdElement());
    method.setResource(newMedicationDispense);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 3
Source File: NamingSystemProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update()
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam NamingSystem namingSystem) {

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

    method.setOperationOutcome(opOutcome);


    try {
        NamingSystem newNamingSystem = namingSystemDao.create(ctx, namingSystem);
        method.setId(newNamingSystem.getIdElement());
        method.setResource(newNamingSystem);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method, ex);
    }


    return method;
}
 
Example 4
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 5
Source File: ClaimProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Claim claim) {

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

    method.setOperationOutcome(opOutcome);

    try {
        Claim newClaim = claimDao.create(ctx,claim, null,null);
        method.setId(newClaim.getIdElement());
        method.setResource(newClaim);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 6
Source File: EndpointProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateEndpoint(HttpServletRequest theRequest, @ResourceParam Endpoint endpoint, @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 {
    Endpoint newEndpoint = endpointDao.create(ctx, endpoint, theId, theConditional);
    method.setId(newEndpoint.getIdElement());
    method.setResource(newEndpoint);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example 7
Source File: RiskAssessmentProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam RiskAssessment riskAssessment) {

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

    method.setOperationOutcome(opOutcome);

    try {
        RiskAssessment newRiskAssessment = riskAssessmentDao.create(ctx,riskAssessment, null,null);
        method.setId(newRiskAssessment.getIdElement());
        method.setResource(newRiskAssessment);
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 8
Source File: MedicationDispenseProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationDispense dispense, @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 {
    MedicationDispense newMedicationDispense = dispenseDao.create(ctx,dispense, theId, theConditional);
    method.setId(newMedicationDispense.getIdElement());
    method.setResource(newMedicationDispense);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 9
Source File: ObservationDefinitionProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam ObservationDefinition observationDefinition)

{
    log.info("create method is called");
    resourcePermissionProvider.checkPermission("create");
    MethodOutcome method = new MethodOutcome();

    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        ObservationDefinition newObservationDefinition = observationDefinitionDao.create(ctx,observationDefinition, null);
        method.setCreated(true);
        method.setId(newObservationDefinition.getIdElement());
        method.setResource(newObservationDefinition);
    } catch (Exception ex) {
        log.info(ex.getMessage());
        ProviderResponseLibrary.handleException(method,ex);
    }
    return method;
}
 
Example 10
Source File: PractitionerRoleProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam PractitionerRole practitionerRole) {

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

    method.setOperationOutcome(opOutcome);

    try {
    PractitionerRole newPractitioner = practitionerRoleDao.create(ctx, practitionerRole,null,null);
    method.setId(newPractitioner.getIdElement());
    method.setResource(newPractitioner);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 11
Source File: ConceptMapProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update()
  public MethodOutcome update(HttpServletRequest theRequest,@ResourceParam  ConceptMap conceptMap) {
  		System.out.println("update method is called");
   	resourcePermissionProvider.checkPermission("update");
MethodOutcome method = new MethodOutcome();

try {
	ConceptMap newConceptMap = conceptMapDao.create(ctx,conceptMap);
	method.setCreated(false);
	method.setId(newConceptMap.getIdElement());
	method.setResource(newConceptMap);
} catch (BaseServerResponseException srv) {
	// HAPI Exceptions pass through
	throw srv;
} catch(Exception ex) {
	ProviderResponseLibrary.handleException(method,ex);
}

return method;
  }
 
Example 12
Source File: ValueSetProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update()
public MethodOutcome update(HttpServletRequest theRequest,@ResourceParam ValueSet valueSet) {

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

    method.setOperationOutcome(opOutcome);


    try {
        ValueSet newValueSet = valueSetDao.create(ctx, valueSet);
        method.setId(newValueSet.getIdElement());
        method.setResource(newValueSet);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 13
Source File: DocumentReferenceProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam DocumentReference documentReference, @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 {
    DocumentReference newDocumentReference = documentReferenceDao.create(ctx,documentReference, theId, theConditional);
    method.setId(newDocumentReference.getIdElement());
    method.setResource(newDocumentReference);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 14
Source File: ReferralRequestProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome createReferralRequest(HttpServletRequest theRequest, @ResourceParam ReferralRequest referral) {

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

    method.setOperationOutcome(opOutcome);

    try {
        ReferralRequest newReferralRequest = referralDao.create(ctx, referral,null,null);
        method.setId(newReferralRequest.getIdElement());
        method.setResource(newReferralRequest);

    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example 15
Source File: OrganizationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome createOrganization(HttpServletRequest theRequest,@ResourceParam Organization organization) {

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

    method.setOperationOutcome(opOutcome);
    try {
        Organization newOrganization = organisationDao.create(ctx, organization,null,null);
        method.setId(newOrganization.getIdElement());
        method.setResource(newOrganization);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example 16
Source File: CareTeamProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam CareTeam careTeam) {

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

    method.setOperationOutcome(opOutcome);

    try {
        CareTeam newCareTeam = careTeamDao.create(ctx,careTeam, null,null);
        method.setId(newCareTeam.getIdElement());
        method.setResource(newCareTeam);
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 17
Source File: EncounterProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@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 18
Source File: QuestionnaireResponseProvider.java    From careconnect-reference-implementation with Apache License 2.0 5 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam QuestionnaireResponse form, @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 {

    /* Moved to Validation interceptor
    MethodOutcome testMethod = resourceTestProvider.testResource(form,null,null);
    if (!resourceTestProvider.pass(testMethod)) {
        throw new ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException(ctx, testMethod.getOperationOutcome());
    }*/


        QuestionnaireResponse newForm = formDao.create(ctx, form, theId, theConditional);
        method.setId(newForm.getIdElement());
        method.setResource(newForm);

    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method, ex);
    }


    return method;
}
 
Example 19
Source File: CarePlanProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam CarePlan carePlan, @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 {
        CarePlan newCarePlan = carePlanDao.create(ctx,carePlan, theId, theConditional);
        method.setId(newCarePlan.getIdElement());
        method.setResource(newCarePlan);
    } catch (Exception ex) {
           ProviderResponseLibrary.handleException(method,ex);
    }




    return method;
}
 
Example 20
Source File: EpisodeOfCareProvider.java    From careconnect-reference-implementation with Apache License 2.0 4 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam EpisodeOfCare episode, @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 {
        EpisodeOfCare newEpisodeOfCare = episodeDao.create(ctx, episode, theId, theConditional);
        method.setId(newEpisodeOfCare.getIdElement());
        method.setResource(newEpisodeOfCare);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
}




    return method;
}