<commit_before>define(
[
	openhmis.url.backboneBase + 'js/model/generic',
	openhmis.url.backboneBase + 'js/lib/i18n'
],
function(openhmis, __) {
	openhmis.Drug = openhmis.GenericModel.extend({
		meta: {
			name: "Drug",
			restUrl: "v1/drug"
		},
		
		schema: {
			name: { type: "Text" },
			description: { type: "Text" },
			dosageForm: { type: "Object" },
			doseStrength: { type: "Number" },
			maximumDailyDose: { type: "Number" },
			minimumDailyDose: { type: "Number" },
			units: { type: "Text" },
			concept: { type: "Object" },
			combination: { type: "Checkbox" },
			route: { type: "Object" }
		}
	});
	
	openhmis.DrugOrder = openhmis.GenericModel.extend({
		meta: {
			name: "Drug Order"
		},
		
		schema: {
			drug: { type: "NestedModel", model: openhmis.Drug, objRef: true },
			daw: { type: "Checkbox", title: "DAW" },
			frequency: { type: "Text" },
			prn: { type: "Checkbox", title: "PRN" },
			duration: { type: "Text" },
			quantity: { type: "Number" },
			instructions: { type: "TextArea"}
		},
		
		validate: function(attrs) {
			if (!attrs.drug || !attrs.drug.id) return { drug: __("Please choose a drug") };
			return null;
		}
	});
});<commit_msg>Added more validation to drug model.<commit_after>define(
[
	openhmis.url.backboneBase + 'js/model/generic',
	openhmis.url.backboneBase + 'js/lib/i18n'
],
function(openhmis, __) {
	openhmis.Drug = openhmis.GenericModel.extend({
		meta: {
			name: "Drug",
			restUrl: "v1/drug"
		},
		
		schema: {
			name: { type: "Text" },
			description: { type: "Text" },
			dosageForm: { type: "Object" },
			doseStrength: { type: "Number" },
			maximumDailyDose: { type: "Number" },
			minimumDailyDose: { type: "Number" },
			units: { type: "Text" },
			concept: { type: "Object" },
			combination: { type: "Checkbox" },
			route: { type: "Object" }
		}
	});
	
	openhmis.DrugOrder = openhmis.GenericModel.extend({
		meta: {
			name: "Drug Order"
		},
		
		schema: {
			drug: { type: "NestedModel", model: openhmis.Drug, objRef: true },
			daw: { type: "Checkbox", title: "DAW" },
			frequency: { type: "Text" },
			prn: { type: "Checkbox", title: "PRN" },
			duration: { type: "Text" },
			quantity: { type: "Number" },
			instructions: { type: "TextArea"}
		},
		
		validate: function(attrs) {
			if (!attrs.drug || !attrs.drug.id) return { drug: __("Please choose a drug") }
			if (!attrs.frequency) return { frequency: __("Please specify how often this drug should be taken.") }
			
			return null;
		}
	});
});
{'fraction_non_alphanumeric': 0.1874747474747475, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 3.3211169284467714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5892692', 'n_tokens_mistral': 1083, 'n_tokens_neox': 919, 'n_words': 204}