Package org.openmrs

Examples of org.openmrs.Patient


       
        StringWriter writer = new StringWriter();
        IOUtils.copy(new FileInputStream(f), writer, "UTF-8");
        String xml = writer.toString();
       
        Patient p = null;
        if (pId != null) {
          p = Context.getPatientService().getPatient(pId);
        } else {
          p = HtmlFormEntryUtil.getFakePerson();
        }
View Full Code Here


    }
    else if ("edit".equalsIgnoreCase(modeParam)) {
            mode = Mode.EDIT;           
    }

        Patient patient = null;
      Encounter encounter = null;
      Form form = null;
      HtmlForm htmlForm = null;

      if (StringUtils.hasText(request.getParameter("encounterId"))) {
       
        Integer encounterId = Integer.valueOf(request.getParameter("encounterId"));
        encounter = Context.getEncounterService().getEncounter(encounterId);
        if (encounter == null)
          throw new IllegalArgumentException("No encounter with id=" + encounterId);
        patient = encounter.getPatient();
        patientId = patient.getPatientId();
            personId = patient.getPersonId();
           
            if (formId != null) { // I think formId is allowed to differ from encounter.form.id because of HtmlFormFlowsheet
                form = Context.getFormService().getForm(formId);
                htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(form);
                if (htmlForm == null)
                throw new IllegalArgumentException("No HtmlForm associated with formId " + formId);
            } else {
              form = encounter.getForm();
                htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(encounter.getForm());
                if (htmlForm == null)
                throw new IllegalArgumentException("The form for the specified encounter (" + encounter.getForm() + ") does not have an HtmlForm associated with it");
            }

      } else { // no encounter specified

        // get person from patientId/personId (register module uses patientId, htmlformentry uses personId)
      if (patientId != null) {
        personId = patientId;
      }
      if (personId != null) {
        patient = Context.getPatientService().getPatient(personId);
      }
     
      // determine form
      if (htmlFormId != null) {
            htmlForm = HtmlFormEntryUtil.getService().getHtmlForm(htmlFormId);
          } else if (formId != null) {
            form = Context.getFormService().getForm(formId);
            htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(form);
          }
          if (htmlForm == null) {
            throw new IllegalArgumentException("You must specify either an htmlFormId or a formId for a valid html form");
          }
     
      String which = request.getParameter("which");
      if (StringUtils.hasText(which)) {
          if (patient == null)
            throw new IllegalArgumentException("Cannot specify 'which' without specifying a person/patient");
          List<Encounter> encs = Context.getEncounterService().getEncounters(patient, null, null, null, Collections.singleton(form), null, null, false);
          if (which.equals("first")) {
            encounter = encs.get(0);
          } else if (which.equals("last")) {
            encounter = encs.get(encs.size() - 1);
          } else {
            throw new IllegalArgumentException("which must be 'first' or 'last'");
          }
        }
      }
     
    if (mode != Mode.ENTER && patient == null)
      throw new IllegalArgumentException("No patient with id of personId=" + personId + " or patientId=" + patientId);
               
        FormEntrySession session = null;
    if (mode == Mode.ENTER && patient == null) {
      patient = new Patient();     
    }
    if (encounter != null) {
      session = new FormEntrySession(patient, encounter, mode, htmlForm, request.getSession());
    }
    else {
View Full Code Here

        }
        else {
          message = "You must specify a file path to preview from file";
        }
       
    Patient p = HtmlFormEntryUtil.getFakePerson();
    HtmlForm fakeForm = new HtmlForm();
    fakeForm.setXmlData(xml);
        FormEntrySession fes = new FormEntrySession(p, null, Mode.ENTER, fakeForm, httpSession);
        fes.getHtmlToDisplay();
        HtmlFormSchema schema = fes.getContext().getSchema();
View Full Code Here

    HtmlForm hf = (HtmlForm) model.asMap().get("htmlForm");
    if (hf.getId() == null) {
      model.addAttribute("previewHtml", "");
    } else {
      try {
                Patient demo = HtmlFormEntryUtil.getFakePerson();
                FormEntrySession fes = new FormEntrySession(demo, hf.getXmlData(), httpSession);
                String html = fes.getHtmlToDisplay();
                if (fes.getFieldAccessorJavascript() != null) {
                  html += "<script>" + fes.getFieldAccessorJavascript() + "</script>";
                }
View Full Code Here

    @Test
    public void encounterLocationTag_shouldShowRetiredLocationIfPreviouslySelected() throws Exception {

        // create an encounter associated with a retired location
        Location location = Context.getLocationService().getLocation(3);
        Patient patient = Context.getPatientService().getPatient(2);
        Encounter encounter = Context.getEncounterService().getEncounter(101);

        // (sanity check)
        Assert.assertTrue(location.isRetired());
View Full Code Here

    private PatientService patientService;
    private Concept unknownConcept;

    @Before
    public void setUp() {
        patient = new Patient();
        encounter = new Encounter();
        encounter.setPatient(patient);

        unknownConcept = new Concept();
View Full Code Here

      public Patient getPatient() {
        // as a sanity check, make sure this relationship hasn't already been created
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
        Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return parent;
      };
View Full Code Here

        // as a sanity check, make sure this relationship hasn't already been created
       
        // now make sure the relationship has been created
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Person parent = Context.getPersonService().getPerson(6);
        Patient child = Context.getPatientService().getPatient(2);
        Assert.assertEquals(0, Context.getPersonService().getRelationships(parent, child, type).size());
       
        return child;
      };
     
View Full Code Here

     
      @Override
      public Patient getPatient() {
        // preemptively create a relationship
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
       
        Relationship rel = new Relationship(parent, child, type);
        Context.getPersonService().saveRelationship(rel);
       
View Full Code Here

     
      @Override
      public Patient getPatient() {
        // preemptively create a relationship
        RelationshipType type = Context.getPersonService().getRelationshipType(1);
        Patient parent = Context.getPatientService().getPatient(2);
        Person child = Context.getPersonService().getPerson(6);
       
        Relationship rel = new Relationship(parent, child, type);
        Context.getPersonService().saveRelationship(rel);
       
View Full Code Here

TOP

Related Classes of org.openmrs.Patient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.