Permalink
Browse files

added in and post theater drugs, surgery note

  • Loading branch information...
merovingienne committed Aug 22, 2017
1 parent 9dd4d34 commit eee0c3e7e4e2470fda4b44097ee866012717aabf
@@ -1,15 +1,12 @@
package org.openmrs.module.operationtheater;
import org.openmrs.Patient;
import org.openmrs.Provider;
import org.openmrs.*;
import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Set;
import org.openmrs.module.operationtheater.attribute.converter.time.LocalDateAttributeConverter;
import org.openmrs.module.operationtheater.attribute.converter.time.LocalDateTimeAttributeConverter;
/**
@@ -50,6 +47,13 @@
inverseJoinColumns = { @JoinColumn(name = "provider_id", nullable = false, updatable = false) })
private Set<Provider> surgicalTeam;
@OneToOne(cascade = { CascadeType.ALL })
@JoinTable(name = "surgery_info_obs",
joinColumns = { @JoinColumn(name="surgery_id", referencedColumnName = "surgery_id", nullable = true, updatable = true) },
inverseJoinColumns = { @JoinColumn(name = "obs_group_id", referencedColumnName = "obs_id", nullable = true, updatable = true) })
private Obs SurgeryObsGroup;
public int getSurgeryId() {
return surgeryId;
}
@@ -104,6 +108,14 @@ public void setSurgicalTeam(Set<Provider> surgicalTeam) {
this.surgicalTeam = surgicalTeam;
}
public Obs getSurgeryObsGroup() {
return SurgeryObsGroup;
}
public void setSurgeryObsGroup(Obs surgeryObsGroup) {
SurgeryObsGroup = surgeryObsGroup;
}
public LocalDateTime getDateFinished() {
return dateFinished;
}
@@ -119,4 +131,8 @@ public LocalDateTime getDateStarted() {
public void setDateStarted(LocalDateTime dateStarted) {
this.dateStarted = dateStarted;
}
}
@@ -326,4 +326,36 @@
referencedTableName="provider" referencedColumnNames="provider_id"/>
</changeSet>
<changeSet author="Chanuka Wijayakoon" id="operationtheater-201708061052">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="surgery_info_obs"/>
</not>
</preConditions>
<comment>
Create the surgical_info_obs table
</comment>
<createTable tableName="surgery_info_obs">
<column name="surgery_info_obs_id" type="integer" autoIncrement="true">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="surgery_id" type="integer">
<constraints nullable="false"/>
</column>
<column name="obs_group_id" type="integer">
<constraints nullable="false"/>
</column>
</createTable>
<addForeignKeyConstraint constraintName="surgery_info_surgery_id"
baseTableName="surgery_info_obs" baseColumnNames="surgery_id"
referencedTableName="surgery" referencedColumnNames="surgery_id"/>
<addForeignKeyConstraint constraintName="surgery_info_obs_group_id"
baseTableName="surgery_info_obs" baseColumnNames="obs_group_id"
referencedTableName="obs" referencedColumnNames="obs_id"/>
</changeSet>
</databaseChangeLog>
@@ -0,0 +1,37 @@
package org.openmrs.module.operationtheater.Util;
import org.openmrs.Location;
import org.openmrs.Obs;
import org.openmrs.Patient;
import org.openmrs.api.context.Context;
import org.openmrs.module.operationtheater.Surgery;
import java.util.Date;
public class SurgeryObsUtil {
/**
* Helper method to get the obs group for recording procedure information.
* @param surgery
* @param patient
* @return
*/
public static Obs getSurgeryObs(Surgery surgery, Patient patient){
Obs surgeryInfoObs = surgery.getSurgeryObsGroup();
if (surgeryInfoObs == null) {
System.out.println("INFO: Surgery info obs group null.");
surgeryInfoObs = new Obs();
surgeryInfoObs.setPerson(patient);
surgeryInfoObs.setConcept(Context.getConceptService().getConcept(200001));
surgeryInfoObs.setObsDatetime(new Date());
surgeryInfoObs.setLocation(new Location(1));
} else {
System.out.println("INFO: Surgery info obs group exists.");
}
return surgeryInfoObs;
}
}
Oops, something went wrong.

0 comments on commit eee0c3e

Please sign in to comment.