patient.addIdentifier().setSystem("urn:mrns").setValue("12345"); patient.addName().setFamily("Smith").addGiven("Tester").addGiven("Q");
p.addIdentifier().setSystem("urn:foo:identifiers").setValue("12345"); p.addTelecom().setSystem(ContactPointSystem.PHONE).setValue("416 123-4567");
@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.addIdentifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
/** * @return The first repetition of repeating field {@link #identifier}, creating it if it does not already exist */ public Identifier getIdentifierFirstRep() { if (getIdentifier().isEmpty()) { addIdentifier(); } return getIdentifier().get(0); }
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); } }
public static void main(String[] theArgs) { // Create a resource instance Patient pat = new Patient(); // Add a "name" element HumanName name = pat.addName(); name.setFamily("Simpson").addGiven("Homer").addGiven("J"); // Add an "identifier" element Identifier identifier = pat.addIdentifier(); identifier.setSystem("http://acme.org/MRNs").setValue("7000135"); // Model is designed to be chained pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("12345"); } }
@Override public Base addChild(String name) throws FHIRException { if (name.equals("identifier")) { return addIdentifier();
copyDomainResource(src, tgt); for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); tgt.setActive(src.getActive()); for (org.hl7.fhir.instance.model.HumanName t : src.getName())
public static void main(String[] args) { // Create an encounter with an invalid status and no class Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("Jay"); pat.addAddress().addLine("342 Evergreen Terrace").addLine("Springfield"); pat.addIdentifier().setSystem("http://acme.org/mrns").setValue("12345"); // Create a new context and enable the narrative generator FhirContext ctx = FhirContext.forDstu2(); ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(pat); System.out.println(res); }
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"); // Enumerated types are provided for many coded elements ContactPoint contact = pat.addTelecom(); contact.setUse(ContactPoint.ContactPointUse.HOME); contact.setSystem(ContactPoint.ContactPointSystem.PHONE); contact.setValue("1 (416) 340-4800"); pat.setGender(Enumerations.AdministrativeGender.MALE); } }
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"); // Enumerated types are provided for many coded elements ContactPoint contact = pat.addTelecom(); contact.setUse(ContactPoint.ContactPointUse.HOME); contact.setSystem(ContactPoint.ContactPointSystem.PHONE); contact.setValue("1 (416) 340-4800"); pat.setGender(Enumerations.AdministrativeGender.MALE); } }
public static void main(String[] theArgs) { // Create a Patient Patient pat = new Patient(); pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("J"); pat.addIdentifier().setSystem("http://acme.org/MRNs").setValue("7000135"); pat.addTelecom().setUse(ContactPointUse.HOME).setSystem(ContactPointSystem.PHONE).setValue("1 (416) 340-4800"); pat.setGender(AdministrativeGender.MALE); // Create a context FhirContext ctx = FhirContext.forDstu3(); // Create a JSON parser IParser parser = ctx.newJsonParser(); parser.setPrettyPrint(true); String encode = parser.encodeResourceToString(pat); System.out.println(encode); } }
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); }
@Override public Base makeProperty(int hash, String name) throws FHIRException { switch (hash) { case -1618432855: return addIdentifier(); case -1422950650: return getActiveElement(); case 3373707: return addName(); case -1429363305: return addTelecom(); case -1249512767: return getGenderElement(); case -1210031859: return getBirthDateElement(); case -1311442804: return getDeceased(); case 561497972: return getDeceased(); case -1147692044: return addAddress(); case 1756919302: return getMaritalStatus(); case -1764672111: return getMultipleBirth(); case -677369713: return getMultipleBirth(); case 106642994: return addPhoto(); case 951526432: return addContact(); case -1413116420: return getAnimal(); case -1035284522: return addCommunication(); case 1488292898: return addGeneralPractitioner(); case -2058947787: return getManagingOrganization(); case 3321850: return addLink(); default: return super.makeProperty(hash, name); } }
copyDomainResource(src, tgt); for (org.hl7.fhir.instance.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(convertIdentifier(t)); tgt.setActive(src.getActive()); for (org.hl7.fhir.instance.model.HumanName t : src.getName())