Java Code Examples for ca.uhn.fhir.rest.api.MethodOutcome

The following examples show how to use ca.uhn.fhir.rest.api.MethodOutcome. 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
Source Project: cqf-ruler   Source File: LibraryOperationsProvider.java    License: Apache License 2.0 8 votes vote down vote up
@Operation(name = "$refresh-generated-content", type = Library.class)
public MethodOutcome refreshGeneratedContent(HttpServletRequest theRequest, RequestDetails theRequestDetails,
        @IdParam IdType theId) {
    Library theResource = this.libraryResourceProvider.getDao().read(theId);
    //this.formatCql(theResource);

    ModelManager modelManager = this.getModelManager();
    LibraryManager libraryManager = this.getLibraryManager(modelManager);

    CqlTranslator translator = this.dataRequirementsProvider.getTranslator(theResource, libraryManager, modelManager);
    if (translator.getErrors().size() > 0) {
        throw new RuntimeException("Errors during library compilation.");
    }
    
    this.dataRequirementsProvider.ensureElm(theResource, translator);
    this.dataRequirementsProvider.ensureRelatedArtifacts(theResource, translator, this);
    this.dataRequirementsProvider.ensureDataRequirements(theResource, translator);

    Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource);
    theResource.setText(n);

    return this.libraryResourceProvider.update(theRequest, theResource, theId,
            theRequestDetails.getConditionalUrl(RestOperationTypeEnum.UPDATE), theRequestDetails);
}
 
Example 2
@Update()
public MethodOutcome update(HttpServletRequest theRequest,@ResourceParam MessageDefinition messageDefinition) {

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

    method.setOperationOutcome(opOutcome);


    try {
        MessageDefinition newMessageDefinition = messageDefinitionDao.create(ctx, messageDefinition);
        method.setId(newMessageDefinition.getIdElement());
        method.setResource(newMessageDefinition);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 3
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam MedicationAdministration administration) {

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

    method.setOperationOutcome(opOutcome);

    try {
    MedicationAdministration newMedicationAdministration = administrationDao.create(ctx,administration, null,null);
    method.setId(newMedicationAdministration.getIdElement());
    method.setResource(newMedicationAdministration);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 4
/**
 * The "@Update" annotation indicates that this method supports replacing an existing
 * resource (by ID) with a new instance of that resource.
 *
 * @param theId      This is the ID of the patient to update
 * @param thePatient This is the actual resource to save
 * @return This method returns a "MethodOutcome"
 */
@Update()
public MethodOutcome updatePatient(@IdParam IdType theId, @ResourceParam Patient thePatient) {
   validateResource(thePatient);

   Long id;
   try {
      id = theId.getIdPartAsLong();
   } catch (DataFormatException e) {
      throw new InvalidRequestException("Invalid ID " + theId.getValue() + " - Must be numeric");
   }

   /*
    * Throw an exception (HTTP 404) if the ID is not known
    */
   if (!myIdToPatientVersions.containsKey(id)) {
      throw new ResourceNotFoundException(theId);
   }

   addNewVersion(thePatient, id);

   return new MethodOutcome();
}
 
Example 5
@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 6
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationAdministration administration, @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 {
    MedicationAdministration newMedicationAdministration = administrationDao.create(ctx,administration, theId, theConditional);
    method.setId(newMedicationAdministration.getIdElement());
    method.setResource(newMedicationAdministration);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 7
@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 8
@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 9
@Delete
public MethodOutcome delete
        (@IdParam IdType internalId) {
    resourcePermissionProvider.checkPermission("delete");
    MethodOutcome method = new MethodOutcome();

    try {
        OperationOutcome outcome = structureDefinitionDao.delete(ctx,internalId);
        method.setCreated(false);
        //method.setId(newStructureDefinition.getIdElement());
        method.setResource(outcome);
    } catch (Exception ex) {
        log.info(ex.getMessage());
        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example 10
@Create
  public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam ConceptMap conceptMap) {
log.info("create method is called");
resourcePermissionProvider.checkPermission("create");
MethodOutcome method = new MethodOutcome();

OperationOutcome opOutcome = new OperationOutcome();

method.setOperationOutcome(opOutcome);

try {
	ConceptMap newConceptMap = conceptMapDao.create(ctx,conceptMap);
	method.setCreated(true);
	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 11
@Create
public MethodOutcome createSlot(HttpServletRequest theRequest, @ResourceParam Slot slot) {

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

    method.setOperationOutcome(opOutcome);

    try {
        Slot newSlot = slotDao.create(ctx, slot,null,null);
        method.setId(newSlot.getIdElement());
        method.setResource(newSlot);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 12
@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
@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 14
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam DiagnosticReport diagnosticReport) {

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

    try {
    DiagnosticReport newDiagnosticReport = diagnosticReportDao.create(ctx,diagnosticReport, null,null);
    method.setId(newDiagnosticReport.getIdElement());
    method.setResource(newDiagnosticReport);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 15
@Create
public MethodOutcome createSchedule(HttpServletRequest theRequest, @ResourceParam Schedule schedule) {

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

    method.setOperationOutcome(opOutcome);

    try {
        Schedule newSchedule = scheduleDao.create(ctx, schedule,null,null);
        method.setId(newSchedule.getIdElement());
        method.setResource(newSchedule);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 16
public static void main(String[] theArgs) {

		// Create a client
      IGenericClient client = FhirContext.forDstu3().newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3");

      // Register some interceptors
      client.registerInterceptor(new CookieInterceptor("mycookie=Chips Ahoy"));
      client.registerInterceptor(new LoggingInterceptor());

      // Read a Patient
      Patient patient = client.read().resource(Patient.class).withId("example").execute();

		// Change the gender
		patient.setGender(patient.getGender() == AdministrativeGender.MALE ? AdministrativeGender.FEMALE : AdministrativeGender.MALE);

		// Update the patient
		MethodOutcome outcome = client.update().resource(patient).execute();
		
		System.out.println("Now have ID: " + outcome.getId());
	}
 
Example 17
@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 18
@Create
public MethodOutcome createEndpoint(HttpServletRequest theRequest, @ResourceParam Endpoint endpoint) {

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

    method.setOperationOutcome(opOutcome);
    try {
        Endpoint newEndpoint = endpointDao.create(ctx, endpoint,null,null);
        method.setId(newEndpoint.getIdElement());
        method.setResource(newEndpoint);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example 19
@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 20
@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 21
@Update
public MethodOutcome updateLocation(HttpServletRequest theRequest, @ResourceParam Location location, @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 {
    Location newLocation = locationDao.create(ctx, location, theId, theConditional);
    method.setId(newLocation.getIdElement());
    method.setResource(newLocation);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example 22
@Create
public MethodOutcome createLocation(HttpServletRequest theRequest, @ResourceParam Location location) {

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

    method.setOperationOutcome(opOutcome);
    try {
    Location newLocation = locationDao.create(ctx, location,null,null);
    method.setId(newLocation.getIdElement());
    method.setResource(newLocation);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example 23
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam QuestionnaireResponse form) {

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

    method.setOperationOutcome(opOutcome);
    try {

        QuestionnaireResponse newForm = formDao.create(ctx, form, null, null);
        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 24
@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 25
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Consent consent) {

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

    method.setOperationOutcome(opOutcome);

    try {

        Consent newConsent = consentDao.create(ctx,consent, null,null);
        method.setId(newConsent.getIdElement());
        method.setResource(newConsent);
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 26
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Immunization immunisation, @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 {
        Immunization newImmunisation = immunisationDao.create(ctx,immunisation, theId, theConditional);
        method.setId(newImmunisation.getIdElement());
        method.setResource(newImmunisation);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 27
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam Immunization immunisation) {

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

    try {
    Immunization newImmunisation = immunisationDao.create(ctx,immunisation, null, null);
    method.setId(newImmunisation.getIdElement());
    method.setResource(newImmunisation);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example 28
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam MedicationRequest prescription) {

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

    method.setOperationOutcome(opOutcome);

    try {
    MedicationRequest newMedicationRequest = prescriptionDao.create(ctx,prescription, null,null);
    method.setId(newMedicationRequest.getIdElement());
    method.setResource(newMedicationRequest);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example 29
@Create
public MethodOutcome create(HttpServletRequest theRequest, @ResourceParam GraphDefinition graph) {

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

    method.setOperationOutcome(opOutcome);


    try {
        GraphDefinition newGraphDefinition = graphDao.create(ctx, graph);
        method.setId(newGraphDefinition.getIdElement());
        method.setResource(newGraphDefinition);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }
    return method;
}
 
Example 30
@Update()
public MethodOutcome update(HttpServletRequest theRequest,@ResourceParam CodeSystem codeSystem) {

    resourcePermissionProvider.checkPermission("update");

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);


    try {
        CodeSystem newCodeSystem = codeSystemDao.create(ctx, codeSystem);
        method.setId(newCodeSystem.getIdElement());
        method.setResource(newCodeSystem);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}