use of org.openmrs.Form in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldPreferFormUuidOverIdIfBothArePresent.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldPreferFormUuidOverIdIfBothArePresent() throws Exception {
// save original encounter count
List<Encounter> encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Integer originalEncounters = encounters.size();
// process message
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||4^AMRS.ELD.FORMID~c156e1a8-6731-4ebd-89ff-d0d1c45eb004^AMRS.ELD.FORMUUID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20090714|||||||V\r" + "ORC|RE||||||||20090728165937|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|5497^CD4 COUNT^99DCT||123|||||||||20090714";
Message hl7message = parser.parse(hl7String);
router.processMessage(hl7message);
// make sure an encounter was added
encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Assert.assertEquals(originalEncounters + 1, encounters.size());
// get last encounter
Encounter enc = encounters.get(encounters.size() - 1);
// check the form uuid
Form form = enc.getForm();
Assert.assertEquals("c156e1a8-6731-4ebd-89ff-d0d1c45eb004", form.getUuid());
}
use of org.openmrs.Form in project openmrs-core by openmrs.
the class ORUR01HandlerTest method getForm_shouldPassIfReturnValueIsNotNullWhenUuidOrIdIsNotNull.
/**
* @see ORUR01Handler#getForm(MSH)
*/
@Test
public void getForm_shouldPassIfReturnValueIsNotNullWhenUuidOrIdIsNotNull() throws Exception {
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "NK1|1|Jones^Jane^Lee^^RN|3A^Parent^99REL||||||||||||F|19751016|||||||||||||||||2^^^L^PI\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20090714|||||||V\r" + "ORC|RE||||||||20090728165937|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|5497^CD4 COUNT^99DCT||123|||||||||20090714\r" + "OBR|3|||23^FOOD CONSTRUCT^99DCT\r" + "OBX|1|CWE|21^FOOD ASSISTANCE FOR ENTIRE FAMILY^99DCT||22^UNKNOWN^99DCT^2471^UNKNOWN^99NAM|||||||||20090714";
ORUR01Handler oruHandler = new ORUR01Handler();
Message hl7message = parser.parse(hl7String);
ORU_R01 oru = (ORU_R01) hl7message;
ca.uhn.hl7v2.model.v25.segment.MSH msh = oru.getMSH();
Form form = oruHandler.getForm(msh);
Assert.assertNotNull(form);
}
use of org.openmrs.Form in project openmrs-core by openmrs.
the class FormServiceTest method getFormField_shouldIgnoreFormFieldsPassedToIgnoreFormFields.
/**
* @see FormService#getFormField(Form,Concept,Collection<QFormField;>,null)
*/
@Test
public void getFormField_shouldIgnoreFormFieldsPassedToIgnoreFormFields() {
executeDataSet(INITIAL_FIELDS_XML);
executeDataSet("org/openmrs/api/include/FormServiceTest-formFields.xml");
FormField ff = Context.getFormService().getFormField(new Form(1), new Concept(1), null, false);
// sanity check
assertNotNull(ff);
// test that the first formfield is ignored when a second fetch
// is done on the same form and same concept
List<FormField> ignoreFormFields = new ArrayList<>();
ignoreFormFields.add(ff);
FormField ff2 = Context.getFormService().getFormField(new Form(1), new Concept(1), ignoreFormFields, false);
assertNotNull(ff2);
assertNotSame(ff, ff2);
}
use of org.openmrs.Form in project openmrs-core by openmrs.
the class FormServiceTest method purgeFormResource_shouldDeleteAFormResource.
/**
* @throws ParseException
* @see FormService#purgeFormResource(Form,String,String)
*/
@Test
public void purgeFormResource_shouldDeleteAFormResource() throws ParseException {
// save an original resource
Form form = Context.getFormService().getForm(1);
String name = "Start Date";
FormResource resource = new FormResource();
resource.setForm(form);
resource.setName(name);
resource.setDatatypeClassname("org.openmrs.customdatatype.datatype.DateDatatype");
Date previous = new SimpleDateFormat("yyyy-MM-dd").parse("2011-10-16");
resource.setValue(previous);
resource = Context.getFormService().saveFormResource(resource);
Integer resourceId = resource.getFormResourceId();
// clear the session
Context.clearSession();
// find and delete the resource
resource = Context.getFormService().getFormResource(resourceId);
Context.getFormService().purgeFormResource(resource);
// clear the session
Context.flushSession();
// try to find the resource
resource = Context.getFormService().getFormResource(resourceId);
Assert.assertNull(resource);
}
use of org.openmrs.Form in project openmrs-core by openmrs.
the class FormServiceTest method purgeForm_shouldDeleteGivenFormSuccessfully.
/**
* @see FormService#purgeForm(Form)
*/
@Test
public void purgeForm_shouldDeleteGivenFormSuccessfully() {
FormService fs = Context.getFormService();
createFormsLockedGPAndSetValue("false");
Form form = fs.getForm(1);
fs.purgeForm(form);
assertNull(fs.getForm(1));
}
Aggregations