if (thePayloadResource == null || thePayloadResource.isEmpty()) { if (thePayloadType != null) { operation = theClient.create().resource(thePayloadResource); } else { sendNotification(theMsg);
client.create().resource(custPatient).execute();
/** * Creates a {@link IBaseResource} on the server * * @param resource The resource to create * @param url The search URL to use. The format of this URL should be of the form <code>[ResourceType]?[Parameters]</code>, * for example: <code>Patient?name=Smith&identifier=13.2.4.11.4%7C847366</code>, may be null * @param preferReturn Add a <code>Prefer</code> header to the request, which requests that the server include * or suppress the resource body as a part of the result. If a resource is returned by the server * it will be parsed an accessible to the client via {@link MethodOutcome#getResource()}, may be null * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @return The {@link MethodOutcome} */ public MethodOutcome resource(IBaseResource resource, String url, PreferReturnEnum preferReturn, Map<ExtraParameters, Object> extraParameters) { ICreateTyped createTyped = client.create().resource(resource); processOptionalParams(url, preferReturn, createTyped); ExtraParameters.process(extraParameters, createTyped); return createTyped.execute(); }
/** * Creates a {@link IBaseResource} on the server * * @param resourceAsString The resource to create * @param url The search URL to use. The format of this URL should be of the form <code>[ResourceType]?[Parameters]</code>, * for example: <code>Patient?name=Smith&identifier=13.2.4.11.4%7C847366</code>, may be null * @param preferReturn Add a <code>Prefer</code> header to the request, which requests that the server include * or suppress the resource body as a part of the result. If a resource is returned by the server * it will be parsed an accessible to the client via {@link MethodOutcome#getResource()}, may be null * @param extraParameters see {@link ExtraParameters} for a full list of parameters that can be passed, may be NULL * @return The {@link MethodOutcome} */ public MethodOutcome resource(String resourceAsString, String url, PreferReturnEnum preferReturn, Map<ExtraParameters, Object> extraParameters) { ICreateTyped createTyped = client.create().resource(resourceAsString); processOptionalParams(url, preferReturn, createTyped); ExtraParameters.process(extraParameters, createTyped); return createTyped.execute(); }
public static void main(String[] theArgs) { Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); pat.setGender(AdministrativeGender.MALE); // Create a context FhirContext ctx = FhirContext.forDstu3(); // Create a client String serverBaseUrl = "http://fhirtest.uhn.ca/baseDstu3"; IGenericClient client = ctx.newRestfulGenericClient(serverBaseUrl); // Use the client to store a new resource instance MethodOutcome outcome = client .create() .resource(pat) .execute(); // Print the ID of the newly created resource System.out.println(outcome.getId()); } }
public static void step3_create_patient() { // Create a patient Patient newPatient = new Patient(); // Populate the patient with fake information newPatient .addName() .setFamily("DevDays2015") .addGiven("John") .addGiven("Q"); newPatient .addIdentifier() .setSystem("http://acme.org/mrn") .setValue("1234567"); newPatient.setGender(Enumerations.AdministrativeGender.MALE); newPatient.setBirthDateElement(new DateType("2015-11-18")); // Create a client FhirContext ctx = FhirContext.forDstu3(); IGenericClient client = ctx.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu3"); // Create the resource on the server MethodOutcome outcome = client .create() .resource(newPatient) .execute(); // Log the ID that the server assigned IIdType id = outcome.getId(); System.out.println("Created patient, got ID: " + id); }