@Read(version=true) public Patient readOrVread(@IdParam IdType theId) { Patient retVal = new Patient(); if (theId.hasVersionIdPart()) { // this is a vread } else { // this is a read } // ...populate... return retVal; } //END SNIPPET: vread
private static Patient createPatient(final String name) { final Patient patient = new Patient(); patient.getName().add(new HumanName().setFamily(name)); patient.setId(createId(counter, 1L)); counter++; return patient; }
@Read() public Patient readPatient(@IdParam IdType theId) { Patient retVal = new Patient(); // ..populate demographics, contact, or anything else you usually would.. // Populate some tags retVal.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example retVal.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example return retVal; } //END SNIPPET: readTags
@History() public List<Patient> getPatientHistory( @IdParam IdType theId, @Since InstantType theSince, @At DateRangeParam theAt ) { List<Patient> retVal = new ArrayList<Patient>(); Patient patient = new Patient(); patient.addName().setFamily("Smith"); // Set the ID and version patient.setId(theId.withVersion("1")); // ...populate the rest... return retVal; } //END SNIPPET: history
@SuppressWarnings("unused") public static void creatingContextHl7org() { // START SNIPPET: creatingContextHl7org // Create a context for DSTU3 FhirContext ctx = FhirContext.forDstu3(); // Working with RI structures is similar to how it works with the HAPI structures org.hl7.fhir.dstu3.model.Patient patient = new org.hl7.fhir.dstu3.model.Patient(); patient.addName().addGiven("John").setFamily("Smith"); patient.getBirthDateElement().setValueAsString("1998-02-22"); // Parsing and encoding works the same way too String encoded = ctx.newJsonParser().encodeResourceToString(patient); // END SNIPPET: creatingContextHl7org }
Patient patient = new Patient(); patient.addIdentifier().setSystem("urn:mrns").setValue("12345"); patient.addName().setFamily("Smith").addGiven("Tester").addGiven("Q");
public void validationIntro() { // START SNIPPET: validationIntro FhirContext ctx = FhirContext.forDstu3(); // Ask the context for a validator FhirValidator validator = ctx.newValidator(); // Create some modules and register them IValidatorModule module1 = new SchemaBaseValidator(ctx); validator.registerValidatorModule(module1); IValidatorModule module2 = new SchematronBaseValidator(ctx); validator.registerValidatorModule(module2); // Pass a resource in to be validated. The resource can // be an IBaseResource instance, or can be a raw String // containing a serialized resource as text. Patient resource = new Patient(); ValidationResult result = validator.validateWithResult(resource); String resourceText = "<Patient.....>"; ValidationResult result2 = validator.validateWithResult(resourceText); // The result object now contains the validation results for (SingleValidationMessage next : result.getMessages()) { System.out.println(next.getLocationString() + " " + next.getMessage()); } // END SNIPPET: validationIntro }
public void foo() { //START SNIPPET: subExtension Patient patient = new Patient(); // Add an extension (initially with no contents) to the resource Extension parent = new Extension("http://example.com#parent"); patient.addExtension(parent); // Add two extensions as children to the parent extension Extension child1 = new Extension("http://example.com#childOne", new StringType("value1")); parent.addExtension(child1); Extension child2 = new Extension("http://example.com#chilwo", new StringType("value1")); parent.addExtension(child2); //END SNIPPET: subExtension }
Patient p = new Patient(); p.addName().setFamily("Smith").addGiven("John").addGiven("Q"); p.addIdentifier().setSystem("urn:foo:identifiers").setValue("12345");
@Read() public Patient getResourceById(@IdParam IdType theId) { Patient retVal = new Patient(); // ...populate... retVal.addIdentifier().setSystem("urn:mrns").setValue("12345"); retVal.addName().setFamily("Smith").addGiven("Tester").addGiven("Q"); // ...etc... // if you know the version ID of the resource, you should set it and HAPI will // include it in a Content-Location header retVal.setId(new IdType("Patient", "123", "2")); return retVal; } //END SNIPPET: read
public void clientRead() { //START SNIPPET: clientReadTags IPatientClient client = FhirContext.forDstu2().newRestfulClient(IPatientClient.class, "http://foo/fhir"); Patient patient = client.readPatient(new IdType("1234")); // Access the tag list List<Coding> tagList = patient.getMeta().getTag(); for (Coding next : tagList) { // ..process the tags somehow.. } //END SNIPPET: clientReadTags //START SNIPPET: clientCreateTags Patient newPatient = new Patient(); // Populate the resource object newPatient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setValue("123"); newPatient.addName().setFamily("Jones").addGiven("Frank"); // Populate some tags newPatient.getMeta().addTag("http://animals", "Dog", "Canine Patient"); // TODO: more realistic example newPatient.getMeta().addTag("http://personality", "Friendly", "Friendly"); // TODO: more realistic example // ...invoke the create method on the client... //END SNIPPET: clientCreateTags }
Patient patient = new Patient(); patient.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Optional Patient if the report was requested for a single patient.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create MeasureReport.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Patient information, If the device is affixed to a person.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create Device.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (A link to a resource representing the person whom the delivered item is for.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create SupplyDelivery.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The person who this history concerns.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create FamilyMemberHistory.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (Indicates the patient whose record the detected issue is associated with.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create DetectedIssue.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient the recommendations are for.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create ImmunizationRecommendation.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
/** * @return {@link #patient} The actual object that is the target of the reference. The reference library doesn't populate this, but you can use it to hold the resource if you resolve it. (The patient/healthcare consumer to whom this consent applies.) */ public Patient getPatientTarget() { if (this.patientTarget == null) if (Configuration.errorOnAutoCreate()) throw new Error("Attempt to auto-create Consent.patient"); else if (Configuration.doAutoCreate()) this.patientTarget = new Patient(); // aa return this.patientTarget; }
public org.hl7.fhir.dstu3.model.Patient convertPatient(org.hl7.fhir.instance.model.Patient src) throws FHIRException { if (src == null || src.isEmpty()) return null; org.hl7.fhir.dstu3.model.Patient tgt = new org.hl7.fhir.dstu3.model.Patient(); copyDomainResource(src, tgt); for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier())